patternMinor
Modeling Subclass (or Subtype) Constraints in an Entity-Relationship Diagram
Viewed 0 times
constraintsmodelingsubclassdiagramsubtypeentityrelationship
Problem
Scenario description
Can someone help me out on how to model the situation that follows:
-
There is a superclass (or supertype) called
-
There exists another superclass denominated
-
I need to represent some rules that indicate that:
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.,
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?
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) named FOOD and SHOES.-
There exists another superclass denominated
CUSTOMERS, with the subclasses denominated SHOE STORE and GROCERY STORE.-
I need to represent some rules that indicate that:
FOODcan only be delivered toGROCERY STORES.
SHOEScan 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?
Solution
I think you can make an
Orders entity that is a relationship between Products and Customers. The Orders would have subclasses FoodOrders and ShoeOrders, which respectively would be the relationships between the subclasses of Food - GroceryStores and Shoes - ShoeStores. ┌───────────┐
│ Employees │
└─────┬─────┘
│
│
┌──────────┐ ┌────────┐ │ ┌───────────┐
│ Products ├─── contain ───┤ Orders ├─── deliver ───┤ Customers │
└────┬─────┘ └────┬───┘ └─────┬─────┘
│ │ │
│ │ │
isA isA isA
│ │ │ │ │ │
┌────┘ └────┐ ┌─────┘ └─────┐ ┌────┘ └────┐
│ │ │ │ │ │
┌───┴──┐ ┌───┴───┐ │ │ ┌───────┴───────┐ │
│ Food │ │ Shoes │ │ │ │ GroceryStores │ │
└───┬──┘ └───┬───┘ │ │ └───────┬───────┘ │
│ │ ┌─────┴──────┐ │ │ ┌─────┴──────┐
└───────────│───────┤ FoodOrders ├──────│────────────┘ │ ShoeStores │
│ └────────────┘ │ └─────┬──────┘
│ ┌─────┴──────┐ │
└─────────────────────┤ ShoeOrders ├─────────────────┘
└────────────┘
Context
StackExchange Database Administrators Q#126952, answer score: 6
Revisions (0)
No revisions yet.