Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
08-23-2020 07:06 AM
I'm creating my database model and I'm confident that I'm on the correct way, but when I have to move this to DDD I struggle creating my Domain.
My case is very simple
(Recipe) -> MADE_OFF {"quantity": 200} -> (Ingredient)
I have my Recipe and Ingredient entity.
Then I've created a Ingredient CRUD, easy just a name and Id.
The problem is when create a Recipe CRUD, with a list o ingredients, and each one have a quantity.
If I include a property Quantities to Ingredient Entity I can't avoid to feel it's dirty, Ingredients should don't know anything about it.
My idea is to create another object that wraps Ingredient + Quanitity.
Any tip?
Thanks!
08-23-2020 07:23 AM
Hi @danielbahe,
Why don't you keep it the way you have already model it? I mean, keeping the quantity
in the RelationshipEntity
CRUD.
You may consider the measurement unit as well tho.
H
08-23-2020 12:06 PM
Try this:
MERGE (r:Recipe {name: "Test1"})
MERGE (r1:Recipe {name: "Test2"})
MERGE (i:Ingredient {name: "Fish"})
MERGE (r)-[:MADE_OFF {recipe: "Test1", quantity: "6" }]->(i)
MERGE (r1)-[:MADE_OFF {recipe: "Test2", quantity: "8" }]->(i)
return r, r1, i
08-24-2020 01:18 AM
Hi, Daniel,
I think the Ameyasoft solution is a reasonable lemma.
You can start from the recipes of bbcgoodfood.com ex: https://www.bbcgoodfood.com/recipes/roast-chicken-peppers-feta
and the project of Ljubica Lazarevic and Mark Needham:
and a live interview
ciao
Alessio
08-25-2020 01:34 AM
My problem is not with neo4j graph modeling. My real problem is how to map this graph with C# DDD domain.
@Bennu this looks fine, but this way i think I'm breaking the DDD and Isolation principle.
My domain should represent the business logic and not the database logic.
Currently I have 3 layers: Api, Domain, DataAccess.
I'm using repository pattern to communicate domain and DataAccess ( Interfaces in domain, implementations in dataAccess)
I think I will create models in DataAccess layer and then map this models to my domain entities.
This way I'm isolating my domain from database framework and if in the future i want to move to Entity Framework or some other database I can do it without breaking my domain.
What do you think?
08-25-2020 04:32 PM
Hi @danielbahe,
That's the right approach! (according to me so don't trust me )
I'm working with DDD for project (java based) and during POC stage, while comparing Neo4J and another DB, we stablished the domain objects mainly as our DTO with few variations for small agreggations/denormalizations (against DDD but pro bussiness requirements). Our DAO objects were built for both DB's using correspondants CrudRepositories. So yes, they are 'linked' to the DB technology but you can port the whole Domain by just changing this objects (you can even keep the same DAO-DTO converter). So this way we had the same service able to work with both DBs.
I hope I explained my thoughts! Did you read the links suggested by @asperlinga? They are quite interesting. The don't have the concept of quantity tho but worth reading.
H
All the sessions of the conference are now available online