In a supertype/subtype hierarchy, where should attributes be assigned to maximize reuse and proper inheritance?
-
ASubtypes inherit only from their immediate supertype, and attributes belong low in the hierarchy.
-
BAttributes are assigned at the highest logical level.
-
CSubtypes at higher levels inherit from their immediate subtype.
-
DAttributes are assigned at the lowest logical level.
Answer
Correct Answer: Attributes are assigned at the highest logical level.
Explanation
Introduction / Context:Supertype/subtype modeling avoids duplication by placing shared characteristics at common ancestors. Correct placement improves integrity and reduces redundancy.
Given Data / Assumptions:
- Supertypes hold attributes common to all subtypes.
- Subtypes add only attributes unique to their specialization.
Concept / Approach:Assign attributes as high as possible in the hierarchy (the lowest common ancestor) so all relevant subtypes inherit them. Unique attributes stay with the specific subtype that requires them.
Step-by-Step Solution:
Identify common versus specialized attributes.Place common ones in the supertype → maximize reuse.Place unique ones in the subtype → preserve specificity.Verification / Alternative check:Normalization and inheritance principles both recommend elevating shared properties to the highest logical level.
Why Other Options Are Wrong:Assigning low: Duplicates data across subtypes. Higher levels inheriting from subtypes: Reverses inheritance. Immediate-only rule: Misstates how general attributes propagate.
Common Pitfalls:Copying the same attribute into multiple subtypes instead of using the supertype.
Final Answer:Attributes are assigned at the highest logical level.