Professional Documents
Culture Documents
Based on: Hoffer J. A., Ramesh V., Topi H. (2011): Modern Database Management
(10th ed.). Prentice-Hall, Inc.
Agenda
Introduction
Basic definitions
Properties of relations
Integrity constraints
Well-structured relations
Transforming E-R diagrams into relations
Mapping regular and weak entities
Mapping binary relationships
Mapping associative entities
Mapping unary relationships
Mapping ternary relationships
Mapping supertype/subtype relationships
Introduction
Each regular entity type in an E-R diagram is transformed into a relations. Each
simple attribute of the entity type becomes an attribute of the relation. The
identifier of the entity type becomes the primary key of the corresponding
relation.
Only the simple components of the composite attribute are included in the new
relation as its attributes. Compared to composite attributes, simple attributes
improve data accessibility and facilitate maintaining data quality
When the regular entity type contains a multivalued attribute, two new relations
(rather than one) are created. The first relation contains all of the attributes of
the entity type except the multivalued attribute. The second relation contains
two attributes that form the primary key of the second relation. The first of these
attributes is the primary key from the first relation, which becomes a foreign key
in the second relation. The second is the multivalued attribute. If an entity type
contains multiple multivalued attributes, each of them will be converted to a
separate relation.
Transforming regular entities
Transforming weak entities
For each weak entity type, create a new relation and include all of
the attributes as attributes of this relation. Then include the primary
key of the identifying relation as a foreign key attribute in this new
relation. The primary key of the new relation is the combination of
this primary key of the identifying and the partial identifier of the
weak entity type.
In practice, an alternative approach is often used to simplify the
primary key of the DEPENDENT relation: Create a new attribute
(called Dependent#), which will be used as a surrogate primary
key.
Dependent# is simply a serial number that is assigned to each
dependent of the identifying relation. Notice that this solution will
ensure unique identification for each dependent.
Transforming weak entities
Surrogate key
For a binary many-to-many (M:N) relationship between two entity types create
a new relation. Include as foreign key attributes in this new relations the primary
key of each of the two participating entity types. These attributes together
become the primary key of the new relation. Any nonekey attributes that are
associated with the M:N relationship are also included with the new relation.
Binary one-to-one relationships can be viewed as a special case of one-to-
many relationships. The process of mapping such a relationship to relations
requires two steps. First, two relations are created, one for each of the
participating entity types. Second, the primary key of one of the relations is
included as a foreign key in the other relation.
In a 1:1 relationship, the association in one direction is nearly always an optional
one, whereas the association in the other direction is mandatory one. You
should include in the relation on the optional side of the relationship the foreign
key of the entity type that has the mandatory participation in the 1:1
relationship. This approach will prevent the need to store null values in the
foreign key attribute. Any attributes associated with the relationship itself are
also included in the same relation as the foreign key.
Mapping binary relationships
Mapping associative entities
If an identifier was not assigned, the default primary key for the
associative relation consists of the two primary key attributes from
the other two relations. These attributes are then foreign keys that
reference the other two relations.
Sometimes a data modeler will assign a single-attribute identifier to
the associative entity type on the E-R diagram. In this case a new
(associative) relation is created to represent the associative entity.
However, the primary key for this relation is the identifier assigned on
the E-R diagram. The primary keys for the two participating entity
types are then included as foreign keys in the associative relation.
Mapping associative entities
Mapping associative entities
Mapping unary relationships