I am learning how to interpret Entity Relationship Diagrams into SQL DDL statements and I am confused by differences in notation. Consider a disjoint relationship as in the following diagram:
Would this be represented as:
I think these are other ways of writing the relationship:
I'm looking for a clear explanation of the difference in regard to what tables you'd end up with for each diagram.
A supertype is a generic entity type that has a relationship with one or more subtypes. A subtype is a sub-grouping of the entities in an entity type that is meaningful to the organization and that shares common attributes or relationships distinct from other subgroups.
In ER diagram, relationship type is represented by a diamond and connecting the entities with lines. A set of relationships of same type is known as relationship set.
Mapping ProcessCreate table for weak entity set. Add all its attributes to table as field. Add the primary key of identifying entity set. Declare all foreign key constraints.
Subtype - a subgroup of entities with unique attributes. Inheritance - the concept that subtype entities inherit the values of all supertype attributes.
There are several ER notations. I'm not familiar with the one you are using, but it's clear enough you are trying to represent a subtype (aka. inheritance, category, subclass, generalization hierarchy...). This is the relational cousin of the OOP inheritance.
When doing subtyping, you are generally concerned with the following design decisions:
Vehicle
exist without also being 2WD
or 4WD
?1
Vehicle
be both 2WD
and 4WD
?2
Bike
or a Plane
(etc...) could be later added to the database model?The Information Engineering notation differentiates between inclusive and exclusive subtype relationship. IDEF1X notation, on the other hand, doesn't (directly) recognize this difference, but it does differentiate between complete and incomplete subtype (which IE doesn't).
The following diagram from the ERwin Methods Guide (Chapter 5, Subtype Relationships) illustrates the difference:
Neither IE nor IDEF1X directly allow specifying abstract vs. concrete parent.
Unfortunately, practical databases don't directly support inheritance, so you'll need to transform this diagram to real tables. There are generally 3 approaches for doing so:
2WD
and 4WD
vehicles having the same ID). Can easily enforce inclusive vs. exclusive children and abstract vs. concrete parent (by just varying the CHECK).As you can see, the situation is less than ideal - you'll need to make compromises whatever approach you choose. The approach (3) should probably be your starting point, and only choose one of the alternatives if there is a compelling reason to do so.
1 I'm guessing this is what thickness of the line stands for in your diagrams.
2 I'm guessing this is what presence or absence of "disjoint" stands for in your diagrams.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With