I'm in the middle of creating domain model and I need help with some entities. I have a Sale entity (which represents the action of selling goods to buyers) and a Purchase entity (which represents the act of buying goods from supplier to fill the stocks). I see the two ways of how to deal with it:
- Create two entities
SellandPurchaseand additional entities for both of them named likeSell detailsandPurchase detailsrespectively, with attributes [sell_id/purchase_id,product_id, ...,quantity]. But in this case I will have two almost identical entities in my database which is obvious duplication of data. - The second approach I see is to create one entity
Orderwith additional attributeorder_type(and eponymous entity to store order types:purchaseandsell) andOrder_detailsentity so we can escape data duplication from the first approach.
Please share your experience how to deal with this case. Thanks.