Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Domain Driven Design alongside Graph database

I've been searching online for any information relating to using both Domain Driven Design and Graph databases such as Neo4j, I've got to say there's not a lot of information to be had!

My main queries come in with the apparent overlap between the two, i.e. both graph databases and DDD model the domain, Graph databases however only hold state, not behaviour. I'm not really sure how to mix the two... how do I mix in the behaviour? Perhaps using domain services? Creating domain entities/values for each graph node seems a ridiculous way to add behaviour.

Any ideas?

like image 988
raven-king Avatar asked Dec 15 '13 21:12

raven-king


2 Answers

They can co-exist in a way that graph databases are commonly used on the "read" side.

What people do sometimes is they apply CQRS to a given Bounded Context and use Graph DB for projections where it makes sense.

like image 142
Alexey Raga Avatar answered Nov 18 '22 16:11

Alexey Raga


This depends on your bounded context and how you use the data.

data consuming bounded context:

You could use a domain service to hide technolegy details. There is a very good example in the famous dddsample. They use a RoutingService to seperate routing knowledge(evloved as routing bounded context) from cargo booking bounded context.

The implementation behind the domain service is probably even not developed using ddd. You could develop it in a graph database friendly way.

data producing bounded context:

CQRS may be a good solution to fix the gap between domain model and graph database. In this case, domain models are used to to produce calculated nodes and relationships.

like image 43
Yugang Zhou Avatar answered Nov 18 '22 15:11

Yugang Zhou