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.
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
?1Vehicle
be both 2WD
and 4WD
?2Bike
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.