Scenario description
Can someone help me out on how to model the situation that follows:
-
There is a superclass (or supertype) called
PRODUCTS
, which has the subclasses (or subtypes) namedFOOD
andSHOES
. -
There exists another superclass denominated
CUSTOMERS
, with the subclasses denominatedSHOE STORE
andGROCERY STORE
. -
I need to represent some rules that indicate that:
FOOD
can only be delivered toGROCERY STORES
.SHOES
can exclusively be distributed toSHOE STORES
.
Tentative diagrams
I have tried the two diagrams shown bellow:
Diagrams considerations
Top diagram
I really do not like the duplication of (a) the same entity type, i.e., ORDERS
, and (b) the relationships around it.
Bottom diagram
I am pretty sure this not the proper notation. Should I instead create the relationship on the superclass level and make a note that the restrictions will be implemented at the programming level?
Best Answer
I think you can make an
Orders
entity that is a relationship betweenProducts
andCustomers
. TheOrders
would have subclassesFoodOrders
andShoeOrders
, which respectively would be the relationships between the subclasses ofFood - GroceryStores
andShoes - ShoeStores
.