Database Design : Extended ERD


Binary versus n-ary Relationship Sets
Relationships in databases are often binary. Some relationships that appear to be nonbinary could actually be better represented by several binary relationships. For instance, one could create a ternary relationship parent, relating a child to his/her mother and father. However, such a relationship could also be represented by two binary relationships, mother and father, relating a child to his/her mother and father separately. Using the two relationships mother and father provides us a record of a child’s mother, even if we are not aware of the father’s identity; a null value would be required if the ternary relationship parent is used. Using binary relationship sets is preferable in this case.

(a) ternary relationship (b) three binary relationship

Specialization
An entity set may include subgroupings of entities that are distinct in some way from other entities in the set. For instance, a subset of entities within an entity set may have attributes that are not shared by all the entities in the entity set. The E-R model provides a means for representing these distinctive entity groupings. As an example, the entity set person may be further classified as one of the following :
employee.
student.

Each of these person types is described by a set of attributes that includes all the attributes of entity set person plus possibly additional attributes. For example, employee entities may be described further by the attribute salary, whereas student entities may be described further by the attribute tot cred. The process of designating subgroupings within an entity set is called specialization. The university could create two specializations of student, namely graduate and undergraduate. As we saw earlier, student entities are described by the attributes ID, name, address, and tot cred. The entity set graduate would have all the attributes of student and an additional attribute office number. The entity set undergraduate would have all the attributes of student, and an additional attribute residential college. We can apply specialization repeatedly to refine a design. For instance, university employees may be further classified as one of the following :
instructor.
secretary.

The way we depict specialization in an E-R diagram depends on whether an entity may belong to multiple specialized entity sets or if it must belong to at most one specialized entity set. The former case (multiple sets permitted) is called overlapping specialization, while the latter case (at most one permitted) is called disjoint specialization. For an overlapping specialization (as is the case for student and employee as specializations of person), two separate arrows are used. For a disjoint specialization (as is the case for instructor and secretary as specializations of employee), a single arrow is used. The specialization relationship may also be referred to as a superclass-subclass relationship.

Specialization/Generalization

Generalization
The refinement from an initial entity set into successive levels of entity subgroupings represents a top-down design process in which distinctions are made explicit. The design process may also proceed in a bottom-up manner, in which multiple entity sets are synthesized into a higher-level entity set on the basis of common features. The database designer may have first identified :
instructor entity set with attributes instructor id, instructor name, instructor salary, and rank.
secretary entity set with attributes secretary id, secretary name, secretary salary, and hours per week.

Attribute Inheritance
A crucial property of the higher- and lower-level entities created by specialization and generalization is attribute inheritance. The attributes of the higher-level entity sets are said to be inherited by the lower-level entity sets. Whether a given portion of an E-R model was arrived at by specialization or generalization, the outcome is basically the same :
A higher-level entity set with attributes and relationships that apply to all of its lower-level entity sets.
Lower-level entity sets with distinctive features that apply only within a particular lower-level entity set.

Constraints on Generalizations
Condition-defined. In condition-defined lower-levelentity sets, membership is evaluated on the basis of whether or not an entity satisfies an explicit condition or predicate.
User-defined. User-defined lower-level entity sets are not constrained by a membership condition; rather, the database user assigns entities to a given entity set.
Disjoint. A disjointness constraint requires that an entity belong to no more than one lower-level entity set.
Overlapping. In overlapping generalizations, the same entity may belong to more than one lower-level entity set within a single generalization.

The completeness constraint on a generalization or specialization, specifies whether or not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within the generalization / specialization. This constraint may be one of the following :
Total generalization or specialization. Each higher-level entity must belong to a lower-level entity set.
Partial generalization or specialization. Some higher-level entities may not belong to any lower-level entity set.

Source : Silberchatz, Korth & Sudarshan (2010) Database Systems Concepts, 6th Edition, McGraw-Hill

Comments