I've seen this post (How should I model an “either/or” relationship?) but it's not exactly what I'm looking for. both answers are suggesting creating a subtype instead of a relationship.
Say I have an entity MACHINE
, and I want to creat a relationship to connect it with another entity OS
, call it "installs" or whatsoever. And this OS
has 2 subtypes: WINDOWS
and MAC
(Linux and Unix also work but just for demo purpose they are not included). Not considering virtual machine or double OS, I can only choose one of these 2 subtypes of OS, how should I model this in the entity-relationship model?
Should I
-
Create 1 relationship between
MACHINE
andOS
. Or -
Create 2 relationship between
MACHINE
andWINDOWS
,MACHINE
andMAC
. Or -
Create 1 ternary relationship between
MACHINE
,WINDOWS
andMAC
.
And should I add additional attributes to the entities or the relationship?
Thanks:D
Best Answer
The most powerful design tool is still natural language, predicates, and constraints. So, when in doubt use a plain text editor. Simply focus on logic, as opposed to jargon (this-that relationship ..). The following is one possible version of this story:
Note:
Here is another example of design using natural language, predicates, and constraints to keep a DB in high
NF
.