ch4 Flashcards
Explain the concept of a subclass and superclass with the help of an example. What do we call a class/subclass relation?
Say you have an entity type PET with an attribute Species. Within the PET entity set, you might have a bunch of entities with Species=Cat. There might also be some additional attributes and relationships that only apply to PET instances with Species=Cat. So it could be useful to create a subclass CAT from the superclass PET. You could give the CAT subclass its own local (specific) attrs like ‘Num_of_lives’ and its own specific relationships like CHASES that it has with a MOUSE subclass. The CAT subclass will still inherit all of the attributes and relationships of the PET superclass, in addition to its own local attributes and relationships.
* what do we call a class/subclass relation? superclass/subclass relationship AKA supertype/subtype relationship AKA class/subclass relationship AKA IS-A relationship AKA IS-AN relationship
Define: superclass of a subclass
superclass: the ‘parent’ entity type to which a subclass belongs;
subclass: a meaningful subgrouping of entities of a particular type
Define: superclass/subclass relationship
AKA supertype/subtype relationship
AKA class/subclass relationship
AKA IS-A relationship
AKA IS-AN relationship
the relationship between a superclass and a subclass; entities of the subclass inherit the attribute(s) and relationships of the superclass; a member entity of the subclass represents the same real-world entity as some member of the superclass, but in a distinct specific role; an entity cannot exist in the DB merely by being a member of a subclass, it must also be a member of a superclass
Define: IS-A relationship
AKA superclass/subclass relationship AKA supertype/subtype relationship AKA class/subclass relationship AKA IS-A relationship AKA IS-AN relationship
the relationship between a superclass and a subclass; entities of the subclass inherit the attribute(s) and relationships of the superclass; a member entity of the subclass represents the same real-world entity as some member of the superclass, but in a distinct specific role; an entity cannot exist in the DB merely by being a member of a subclass, it must also be a member of a superclass
Define: specialization
the process of defining a set of subclasses of an entity type; [this entity type is called the superclass of the specialization]; the set of subclasses that forms a specialization is defined on the basis of some distinguishing characteristic of the entities in the superclass
Define: generalization
generalization is the inverse of specialization;
the process of defining a generalized entity type from the given entity types;
a reverse process of abstraction in which we supress the differences among several entity types, identify their common features, and generalize them into a single superclass [“generalized superclass”] of which the original entity types are special subclasses
Define: category
AKA union type; a subclass that represents a collection of entities that is a subset of the UNION of entities from distinct entity types
Define: specific (local) attributes
attributes that are specific to a subclass of a superclass
Define: specific relationships
relationships that are specific to a subclass of a superclass
Discuss the concept of type inheritance.
the type of an entity is defined by the attributes it possesses and the relationship types in which it participates. Because an entity in the subclass represents the same real-world entity from the superclass, it should possess values for its specific attributes as well as values as a member of the superclass. We say that an entity that is a member of a subclass inherits all the attributes of the entity member of the superclass. The entity also inherits all the relationships in which the superclass participates.
Discuss user-defined and predicate-defined subclasses, and identify the differences between the two.
predicate-defined subclasses: AKA condition-defined subclasses * when we can determine exactly the entitites that will become members of each subclass by placing a condition on the value of some attribute of the superclass; * defining predicate: the attribute of the superclass that the constraint is placed on
user-defined subclasses:
- when we do not have a condition for determining membership in a subclass
- Membership in a user-defined subclass is determined by the DB users when they apply the operation to add an entity to the subclass; hence membership is specified individually for each entity by the user, not by any condition that may be evaluated automatically
Explain disjointness and completeness constraints on specialization.
disjointness:
- a specialization may be disjoint or overlapping
- if the specialization is disjoint: that means that an entity can belong to at most ONE subclass in that specialization
- ex: superclass=PET, defining predicate=PET.Species = {subclass type}, subclasses=CAT, DOG, MOUSE; a member of the subclass CAT cannot also be a member of the subclasses DOG or MOUSE
- if the specialization is overlapping: that means that an entity can belong to more than one subclass in that specialization; overlapping is the default
- ex: superclass=PERSON, subclasses=EMPLOYEE, STUDENT, PARENT; a member of the EMPLOYEE subclass can also be a member of the STUDENT and/or PARENT subclasses
completeness:
- a specialization can be total or partial
- if the specialization is total: that means that it is required that every entity in the superclass MUST belong to at least one subclass in the specialization
- ex: superclass=BANK_ACCOUNT, subclasses=SAVINGS, CHECKING; a bank account must be either a savings or checking account
- if the specialization is partial: that means that entities of the superclass do not have to belong to any subclasses in the specialization
- ex: (like if a gym has some intramural sports teams but their policy states that only members can play on them) superclass=GYM_MEMBER, subclasses=BASKETBALL_PLAYER, BASEBALL_PLAYER; a member of the gym can play on a basketball or baseball team, but they don’t have to
List some of the insertion and deletion rules that apply to specialization (and generalization) as a consequence of the constraints specified on them.
- Deleting an entity from a superclass implies that it is automatically deleted from all the subclasses to which it belongs
- Inserting an entity in a superclass implies that the entitiy is mandatorily inserted in all predicate-defined (or attribute-defined) subclasses for which the entity satisfies the defining predicate
- Inserting an entity in a superclass of a total specialization implies that the entity is manditorily inserted in at least one of the subclasses of the specialization
What is the difference between a specialization heirarchy and a specialization lattice?
specialization heirarchy:
- has the constraint that every subclass participates as a subclass in only one class/subclass relationship
- that is each subclass has only one parent
- results in a tree structure or strict heirarchy
specialization lattice:
- a subclass can be a subclass in more than one class/subclass relationship
- that is each subclass can have more than one parent
What is the difference between specialization and generalization? Why do we not display this difference in schema diagrams?
- specialization and generalization are inverses of each other
- in general, a superclass that was defined thru the generalization process is usually total because the superclass is derived from the subclasses and hence contains only the entities that are in the subclasses
- in the specialization process, the DB designers typically start with an entity type and then define subclasses of the entity type by successive specialization; that is they repeatedly define more specific groupings of entity types
- top-down conceptual refinement
- in the generalization process, the DB designers start with a bunch of entity types and then generalize them
- bottom-up conceptual synthesis
- both can end up with the same heirarchy or lattice in the end
- in practice, its likely that a combo of the 2 processes is employed
- we do not distinguish between specialization and generalization on diagrams because the decision as to which process was followed in a particular situation is often subjective