Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SSN
Name
Major
Rank (0,1)
ThesisTitle (0,1)
Option (0,1)
(p,e)
Graduate
Student
ThesisTitle
(1,1)
Advisor
(1,n)
Professor
Student
SSN
Name
Major
Exchange
Student
Option
(0,1)
(1,1)
Visits
(0,1)
Advisor
(1,n)
(1,n)
University
Professor
Visits
(1,n)
3 attributes of subentities
University
Attributes of Employee (SSN, Name), and relationships WorksOn and Supervision are
made explicit for each subentity
SSN is an identifier for each of Secretary, Engineer, and Manager
Constraint: the values of SSN must be unique across all three entity types
Employee
SSN
Name
(0,1)
WorksOn
Skills (1,n)
Project
Name
Budget
Supervision
(t,e)
Secretary
(1,n)
(0,n)
Engineer
Manager
Speciality
NbSuperv
Method: propagate to each subentity the attributes (and identifiers) and relationship links of the superentity
(1,n)
Uses
Drawbacks
(0,n)
Word
Processor
Exercise:
Name
Budget
(0,n)
(0,n)
WorksOn1
WorksOn2
(0,1)
(0,1)
Secretary
(0,n)
Manager
SSN
Name
Speciality
(1,n)
SSN
Name
NbSuperv
(0,n)
(0,1)
(0,1)
3 this may lead to creating entities that were not naturally identified in the first
place
WorksOn3
(0,1)
Engineer
SSN
Name
Skills (1,n)
Uses
Supervision2
(0,n)
Supervision2
Supervisor
(0,n)
(0,1)
Subordinate
Supervision3
Word
Processor
(1,n)
WorksOn
(1,n)
Name
Budget
Employee
SSN
Name
(p,o)
New relationships are created (IsHwProj, ...): they are mandatory on subentities,
optional on superentity
Former subentities have become weak entities with the former superentity as
identifying entity
Old attributes and relationships are preserved
HwProject
#Boards
SwProject
ManMonth
Subcontract
Drawbacks:
Contractor
(1,n)
Uses
(0,n)
Component
11
(1,n)
WorksOn
Name
Budget
(0,1)
IsHwProj
(1,1)
HwProject
#Boards
(0,1)
IsSubcont
(1,1)
(1,1)
SwProject
Subcontract
ManMonth
Employee
SSN
Name
(0,1)
IsSwProj
(1,n)
Contractor
ER-to-Relational Mapping
Derivation of a relational schema equivalent to a given ER schema without generalizations
Versions of the translation are realized by CASE tools for database design, that
produce relational schemas in the DDL of specific DBMSs
The basic translation can be realized with a few rules
(1,n)
Uses
(0,n)
Component
10
12
Company: ER Schema
(0,n)
Supervision
Supervisor
(0,1)
Supervisee
Employee
Manages
(0,1)
SSN
Name
FName
MInit
LName
BDate
Sex
Salary
Address
Number
Name
Locations (1,n)
(4,n)
/NoEmployees
startDate
(1,1)
(1,n)
WorksFor
(1,n)
WorksOn
Controls
hours
(0,n)
relation WorksOn represents the many-to-many relationship WorksOn between Employee and Project (relationship relation)
Department
(1,1)
(1,1)
(1,n)
(1,1)
DependOf
Dependent
Project
Name
Sex
BDate
Relationship
Number
Name
Location
13
Employee
SSN FName
MInit
Department
DNumber DName
LName
BDate
Project
PNumber
Address
PName
Sex
Salary
PLocation
LName
BDate
Address
Department
DNumber DName
Sex
Salary
SuperSSN
DNo
15
DMgr
MgrStartDate
DeptLocations
DNumber DLocation
Project
PNumber
PName
PLocation
WorksOn
PNo ESSN
Dependent
ESSN DependentName
Sex
More attributes will be added to R by subsequent rules to represent some of the 1-1
and 1-N relationships of the entity type represented by R
DNumber
Hours
BDate
Relationship
14
as foreign key of R (i.e., with a referential integrity constraint), attribute(s) corresponding to the primary key of the relation (produced by Rule 1) representing
the entity identifying F
primary key of R = this foreign key + attributes of partial key of F
Dependent
ESSN DependentName
Sex
BDate
Relationship
16
Note that Rule 2 represents in relation R both the weak entity F and its relationship
to the entity that contributes to identifying F
3 the simple attributes and the simple components of the composite attributes
of R
If the minimal cardinality of E1 in R is 0, there will be null values in the extension
of R1
Department
. . . DMgr
MgrStartDate
17
Primary key of R = V K
3 the simple attributes and the simple components of the composite attributes
of R
Employee
. . . SuperSSN
DeptLocations
DNumber DLocation
DNo
18
20
DMgr
6
Department
DName
Research
Administration
Headquarters
DNumber
5
4
1
6
DMgr
333445555
987654321
888665555
{DLocations}
6
{DLocations}
{Bellaire,Sugarland,Houston}
{Stafford}
{Houston}
This representation can also apply to 1-1 and 1-N relationships, thereby avoiding
null values in relations
This would be a natural extension, but with more complex definitions for
WorksOn
ESSN PNo
3 functional dependencies
19
21
The relational model, when it was defined in the early 1970s, ruled out multivalued attributes to mark a clear simplification in comparison to the previously existing
models (COBOL, Codasyl)
DMgr
333445555
987654321
888665555
{DLocations}
{Bellaire,Sugarland,Houston}
{Stafford}
{Houston}
1NF Normalization
Department
DName
Research
Administration
Headquarters
Multivalued attributes are natural and useful, they were present as repeating groups
in the pre-relational era, and are available in all object models
DNumber
5
4
1
DeptLocations
DNumber DLocation
5
Bellaire
5
Sugarland
5
Houston
4
Stafford
1
Houston
DMgr
333445555
987654321
888665555
22
DNumber
5
4
1
DMgr
333445555
987654321
888665555
{DLocations}
{Bellaire,Sugarland,Houston}
{Stafford}
{Houston}
as foreign keys (i.e., with referential integrity), the primary keys of relations that
represent the entity types of R
a composite primary key made of those foreign keys
(except if an entity type E of R has maximum cardinality 1 in R, in which case
the primary key of Rel is the primary key of the relation that represents E)
1NF Normalization
Department
DName
Research
Research
Research
Administration
Headquarters
DNumber
5
5
5
4
1
DLocation
Bellaire
Sugarland
Houston
Stafford
Houston
DMgr
333445555
333445555
333445555
987654321
888665555
24
23
Supply
(0,n)
Quantity
SSN
Name
BirthDate
Project
ProjName
(t,e)
(0,n)
Part
Secretary
Technician
TypingSpeed
TechGrade
Engineer
EngType
PartNo
Supplier
SupName
...
Supply
SupName
Project
ProjName
...
Part
PartNo
PartNo
Quantity
ProjName
26
25
The composite key of relation Supply is made of SupName, ProjName, and PartNo
There is a referential integrity constraint from each of those attributes to the corresponding attribute in relations Supplier, Project, and Part
...
TypingSpeed
TechGrade
EngType
JobType
27
Add a (redundant) view for each subclass, by joining the subclass relation with
the superclass relation
Advantages
Secretary
SSN FName
Technician
SSN FName
Engineer
SSN FName
...
TypingSpeed
...
TechGrade
...
EngType
28
Employee
SSN FName
Full-Secr
SSN FName
MInit
BirthDate
Address
Address
TypingSpeed
30
29
31
32
33