I designed an entity relationship diagram (ERD) with the goal of creating two child entities (INSTITUTION and SPACECRAFT) of a parent entity (LOCATION), which is distinguished depending on the value of a boolean attribute (IS_SPACECRAFT). Implementing this in MongoDB, I'd like to link the INSTITUTION entity to another separate entity when IS_SPACECRAFT is false (0), and the SPACECRAFT entity to this other separate entity when IS_SPACECRAFT is true (1).
Right now, I am doing this manually by creating two attributes (SPACECRAFT_ID and INSTITUTION_ID) in this unrelated entity and pasting the object ID of either the INSTITUTION or SPACECRAFT entity in this attribute depending on the value of IS_SPACRECRAFT. But this inevitably leads to one of those attributes being NULL, which I think is poor database design and is something I'd like to avoid. With that in mind, is there a way to link another entity (i.e., as a foreign key) depending on a Boolean value in MongoDB?
Attached below is the ERD I mentioned earlier so the hierarchy is clear. The discriminator (d) is meant to represent a disjoint (overlapping) subtype, and the double lines represent a total completeness constraint, such that all the member of the parent LOCATION entity are in either SPACECRAFT or LOCATION, but not both.
For reference, a disjoint subtype is defined as:
Disjoint subtypes, also known as nonoverlapping subtypes, are subtypes that contain a unique subset of the supertype entity set; in other words, each entity instance of the supertype can appear in only one of the subtypes.
And total completeness is defined as:
The completeness constraint specifies whether each entity supertype occurrence must also be a member of at least one subtype. The completeness constraint can be partial or total. Partial completeness means that not every supertype occurrence is a member of a sub-type; some supertype occurrences may not be members of any subtype. Total completeness means that every supertype occurrence must be a member of at least one subtype.
//www.google.com/books/edition/Database_Systems_Design_Implementation_M/4JN4CgAAQBAJ
Chapter 05: Advanced Data Modeling
True / False
1. The entity supertype contains common characteristics, and the entity subtypes each contain their own unique
characteristics.
a. True
b. Fals
e
ANSWER: True
DIFFICULTY: Difficulty: Easy
REFERENCES: 5-1a Entity Supertypes and Subtypes
LEARNING OBJ
ECTIVES:
05.01 -
Describe the main extended entity relationship (EER) model constructs and
how they are represented in ERDs and EERDs
2. Entity supertypes and subtypes are organized in a specialization hierarchy.
a. True
b. Fals
e
ANSWER: True
DIFFICULTY: Difficulty: Easy
REFERENCES: 5-1b Specialization Hierarchy
LEARNING OBJ
ECTIVES:
05.01 -
Describe the main extended entity relationship (EER) model constructs and
how they are represented in ERDs and EERDs
3. The relationships depicted within the specialization hierarchy are sometimes described in terms of “is-a” relationships.
a. True
b. Fals
e
ANSWER: True
DIFFICULTY: Difficulty: Moderate
REFERENCES: 5-1b Specialization Hierarchy
LEARNING OBJ
ECTIVES:
05.01 -
Describe the main extended entity relationship (EER) model constructs and
how they are represented in ERDs and EERDs
4. Within a specialization hierarchy, a supertype can exist only within the context of a subtype.
a. True
b. Fals
e
ANSWER: False
DIFFICULTY: Difficulty: Easy
REFERENCES: 5-1b Specialization Hierarchy
LEARNING OBJ
ECTIVES:
05.01 -
Describe the main extended entity relationship (EER) model constructs and
how they are represented in ERDs and EERDs
Copyright Cengage Learning. Powered by Cognero.Page 1