Beruflich Dokumente
Kultur Dokumente
html
Click here for part A of an audio lecture that can be played using RealPlayer
Click here for part B of an audio lecture that can be played using RealPlayer
Click here for part C of an audio lecture that can be played using RealPlayer
1 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
2 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
3 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
ENTITY TYPES
An entity type is the set of entities having the same attributes
We can describe an entity type by an entity type schema
The real entities in the entity type are entity instances
entity type <-> entity instances
object type <-> object instances
relation <-> tuples (relation instances)
intension <-> extension
4 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
DOMAIN OF AN ATTRIBUTE
The domain of v1 is {1,4,5}
The domain of v2 is {A,B}
CARTESIAN PRODUCT
{1,4,5} X {A,B}
{1,A},{1,B},{4,A},{4,B},{5,A},{5,B}
The CAR entity type. Multivalued attributes are shown between braces {}. Components of a composite
attribute are shown between ():
5 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
6 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
PARTICIPATION CONSTRAINT
An employee MUST work for a department
An employee entity can exist only if it participates in a WORKS_FOR relationship instance
Thus its participation is TOTAL
A formal constraint: (min,max) where m, n are min and max number of times an entity participates in a
relationship instance. For example, (0,10) means partial participation, and (1,max) means total participation.
7 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
8 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
The recursive relationship SUPERVISION - EMPLOYEE plays two roles of "supervisor" and "supervisee":
9 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
The 1:1 relationship MANAGES, with partical participation of EMPLOYEE and total participation of
DEPARTMENT:
10 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
11 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
12 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
Such entity types are called WEAK ENTITY TYPES, where entities may not be distinct.
(They still correspond to same real-life object)
Weak entity type must be OWNED by some owner entity type. For example, the EMPYLOEE entity type
owns the DEPENDENT entity type.
How can you eliminate weak entity types?
PROJECT
Name, Number, Location, ControllingDepartment
EMPLOYEE
Name, SSN, Sex, Address, Salary, BirthData, Department, Supervisor, {WorksOn(Project, Hours)}
DEPENDENT
Employee, DependentName, Sex, BirthDate, Relationship
Note: {} indicates multivalued attributes, and () indicates component attributes of a composite attribute
WORKS_FOR (1:N)
DEPARTMENT total
EMPLOYEE total
CONTROLS (1:N)
PROJECT total
DEPARTMENT partial
WORKS_ON (M:N)
13 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
EMPLOYEE total
PROJECT total
Attribute: Hours
DEPENDENTS_OF (1:N)
EMPLOYEE partial
DEPENDENT total
(Weak Entity Type)
The ER Diagram
ER diagram is a graphical design tool
ER diaram for the COMPANY schema with all role names included and with structural constraints on
relationships specified using the (min,max) notation:
14 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
15 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
An example of ER diagram for the library is shown below, where a key icon indicates the relationship is
linked to the key attribute, and a ring icon indicates the relationship is linked to an attribute (which could be
part of the key).
16 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
CAN_TEACH: relates a course to the instructors who can teach that course
(i,c)
TAUGHT_DURING: relates a semester to the instructors who taught some course during that semester
(i,s)
OFFERED_DURING: relates a semester to the courses offered during that semester by ANY instructor
(s,c)
OFFERS: relates an instrcutor who offers a course during a semester
(i,c,s)
Constraint: (i,c,s) cannot exist unless (i,c),(i,s),(s,c) exist, but converse is not true.
The following figures illustrate (a) ternary relationship type SUPPLY; (b) three binary relationship types are
not equivalent to one ternary relationship type SUPPLY; (c) another example of ternary versus binary
relationship type:
17 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
18 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
For database modeling, the most useful part of UML is the Class Diagram and Object Diagram. We can use
these diagrams for object-oriented database design.
19 of 20 09/21/2015 09:45 PM
Entity-Relationship Model http://people.cs.pitt.edu/~chang/156/03ERmodel.html
The BORROW relation type is one-to-many. Participation of BOOK is partial Participation of STUDENT is
partial
20 of 20 09/21/2015 09:45 PM