Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
c
Our ultimate aim is to transform the ER
design into a set of definitions for relational
tables in a computerized database, which
we do through a set of transformation
rules.
Transformation Rule 1.
Each entity in an ER diagram is mapped to a single table
in a relational database; the table is named after the entity.
An identifier for an entity is mapped to a candidate key for the table, as
illustrated in Example 2.1 , and a primary identifier is mapped to a primary
key.
The primary key attribute for this table is the set of columns in p and a .
2.2
±ere is an example database of two tables reflecting the ER diagram for the
Employees entity and the attached multivalued attribute, hobbies , of ãigure 2.2 .
Review for clarification«
relationship occurrence or relationship instance
A particular occurrence of a relationship, corresponding to a tuple of entity
occurrences.
binary relationship
A relationship between two entities.
ãor example, the mployees entity is related to itself through the relationship
manages , where we say that one employee manages another.
NOT
1. In the case of a ring, the connecting lines are often labeled with the names of
the roles played by the entity instances involved. The two named roles are
manager of and reports to.
2. We often leave out attributes in an ER diagram to concentrate on
relationships between entities without losing our concentration in excessive
detail.
Cardinality of ntity articipation in a Relationship
FIGUR 2.6
Examples of relationships R between two entities E and ã.
ãigure 2.6 illustrates the concepts of V VVV VV
which an entity participates in a relationship.
ãigure 2.6(a), (b), and (c) represent entities E and ã on the left and right,
respectively, by two sets; elements of the two sets are connected by a line exactly
when a relationship R relates the two entity occurrences represented.
Note that the diagrams of ãigure 2.6 are not what we refer to as ER diagrams.
The minimum cardinality with which an entity takes part in a relationship is
the minimum number of lines that the DBA allows to be connected to each entity
instance.
NOT
1. The diagrams of ãigure 2.6 would normally only give examples of
relationships at a given moment, and the line connections might
change, just as the row content of a table can change, until some
entity instances have different numbers of lines connected.
Note
* However, we need to be careful in making such a rule, since it means that we will not be able to create a
new course section, enter it in the database, assign it a room and a class period, and allow students to
register for it, while putting off the decision of who is going to teach it.
The DBA might also make the rule that at most one instructor can be assigned to
teach a course section by writing max-card( Course sections , teaches ) = 1.
On the other hand, if more than one instructor were allowed to share the teaching of
a course section, the DBA would write max-card( Course sections , teaches ) = N.
This is clearly a significant difference. We probably don ¶ t want to make the rule that
every instructor teaches some course section (written as min-card( Instructors ,
teaches ) = 1), because an instructor might be on leave, so we settle on min-card(
Instructors , teaches ) = 0.
And in most universities the course load per instructor is greater than one in any
given term, so we would set max-card( Instructors , teaches ) = N.
2.5 ( DFINITION
Then in the ER diagram the connecting line between E and R can be labeled with
the ordered cardinality pair (x, y).
card(, R = (x, y .
According to the above definition and the assignments of Example 2.5 , the edge
connecting the entity Course sections to the relationship teaches should be
labeled with the pair (1, 1).
Every employee must work on at least one project (but may work on many);
A project might have no employees assigned during some periods (waiting for
staffing),
Some projects will have a large number of employees working on them;
An employee who acts in the manager of role (see discussion below) may be
managing no other employees at a given time and still be called a manager; and an
employee reports to at most one manager, but may report to none (this possibility
exists because there must always be a highest-level employee in a hierarchy who
has no manager).