Question

New to DDD here and have a architecture question which should be a typical problem.

I have a StockItem entity and a Store entity. I assign a StockItem to multiple Stores and set different ParLevels for each store. I then need to have transactions (sale, purchase, transfer-in etc) that adjust the quantity on hand at the various store.

What is the preferred way to model this solution? In my DB I would have the following simplied table structure: [StockItem] StockItemID pk, Name

[Store] StoreID pk, Name

[Store_StockItem] StoreStockItemID pk, StoreID fk, StockItemID fk, ParlLevel, QuantityOnHand

[StockItemTransaction] StockItemTransactionID pk, StockItemStoreID fk, StockItemTransactionTypeID fk, Quantity

Any advice greatly appreciated

Was it helpful?

Solution

I don't think that anyone here can really give you the answer you want, because the whole point of Domain Driven Design is that your own specific business domain should guide the object model.

The only piece of advice I would offer is that you shouldn't worry about how the database models these relationships when working on the domain. You should normalise your database according to the rules of normalisation, and create your domain model according to the actual business domain.

Remember that the data model and the domain model don't map to each other in a 1:1 way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top