Professional Documents
Culture Documents
Database design
Database design
2
Design methodology
3
Properties of the methodology
Generality
possibility of use regardless of the problem and the
tools available
Quality of result
in terms of correctness, completeness and
efficiency with respect to the resources used
Ease of use
of both strategies and reference models
4
Data-driven design
5
Stages of database design
Application
requirements
6
Application requirements
7
Stages of database design
Application
requirements Conceptual
design
Conceptual schema
8
Conceptual design
9
Stages of database design
Application
requirements Conceptual
design
Conceptual schema
Logical design
Logical schema
10
Logical design
11
Stages of database design
Application
requirements Conceptual
design
Conceptual schema
Logical design
Physical
schema
12
Physical design
13
Stages of database design
Application
requirements Conceptual
design
Conceptual schema
Logical design
Physical
schema
14
Entity-Relationship model
16
Main constructs of the E-R model
Entities
Relationships
Attributes
Identifiers
Generalizations and subsets
17
Entities
Entity name
Relationship name
19
Relationships examples
Passed Exam
Students Course
Residence
Person Municipality
Born in
20
Occurrences of a relationship
e1
Student
s1 e2 c1
s4 s2
e3 c2 cc5 Course
3
s3 e4
c4
e5
21
Cardinality of binary relationships
22
Cardinality of binary relationships
1 to 1 correspondence
Rector
(0,1) (1,1)
Professor University
p1 r1
u1
Professor p2
p3 University
p4 u2
r2
23
Cardinality of binary relationships
1 to N correspondence
Residence
(1,1) (1,N)
Person Municipality
r1
p1 r2 c1
Person p2 r3 Municipality
p3
p4 r4 c2
24
Cardinality of binary relationships
N to N correspondence
Passed Exam
(0,N) (0,N)
Student Course
e1
s1 c1
Student
s3 e2
c2 Course
s2
s4 e3
c3
e4 25
Limitations of a binary relationship
e1
Student
s1 e2 c1
e3 c2 c Course
s2 3
s3 e4
c4
e5
26
Ternary relationship
A student can take the same exam more than
once at different times
Example of an exam instance
s1 c1 t1
s1 c1 t2
...
Exam
Student Course
Time
27
Occurences of a ternary relationship
s1 c1
Student c3
s3 c2 Course
s2
t3
t1 Time
t2
28
Occurences of a ternary relationship
e1
s1 c1
Student c3
s3 c2 Course
s2
t3
t1 Time
t2
29
Occurences of a ternary relationship
e1
s1 e2 c1
Student e3
s3 c3 Course
c2
s2
t3
t1 Time
t2
30
Occurences of a ternary relationship
e1
s1 e2 c1
Student e3
s3 c3 Course
c2
s2
e4
t3
t1 Time
t2
31
Cardinality of ternary relationships
Exam
(0,N) (0,N)
Student Course
(1,N)
Time
32
Observations
33
The Entity-Relationship Model
Attributes
The attribute
Fiscal code
Residency
Name (1,1) (1,N) Name
Surname Person Municipality
Province
Transfer date
(1,1) (0,N)
36
Examples of attributes
Student Id
Name
Exam Code
(0,N) (0,N)
Surname Student Course Name
Grade
(1,N)
Date Professor’s
Time name
37
Composite attribute
Name of attr. 1
Name of attr. 2
Name of the ...
composite attr. Name of attr. i
Fiscal code
Name Educational
Surname Person qualification
(0,N)
Profession
(0,1)
40
The Entity-Relationship Model
Identifiers
Identifier
42
Internal Identifier
Name
Surname Person
Name
Surname Person
Profession
43
Remarks
Exam
Surname
Name Student Course
(0,N) (0,N)
Date
44
The Entity-Relationship Model
External Identifiers
Identifier
46
External Identifier
Surname
Name Student University
47
External Identifier
Enrollment
Surname
Name Student University
48
External Identifier
Enrollment
Surname
Name Student University
(1,1) (0,N)
Room code
Room
Bookshelf number Shelf number
(0,N)
In
In Bookshelf Shelf
(1,1) (0,N) (1,1)
50
The Entity-Relationship Model
Generalizations
Generalization
E1 E2 En
Person
53
Generalization: example
Military
situation Man Woman
Man
Person
Woman
54
Generalization: example
Athletic
55
Generalization: example
Card number
Name
Athletic
Surname
Skier
Athletic
56
Generalization: example
Card number
Name
Athletic
Surname
Skier
Athletic Both skier
and sailor
Neither skier,
nor sailor
Sailor
57
Generalization: property
58
Generalizzation: incorrect example
Fiscal Code
Name
Military
Person
Situation(0,1)
59
Generalizzation: incorrect example
60
Generalizzation: incorrect example
Fiscal code
Name
Militar
Person
Surname
Situation(0,1)
Man Woman
61
Generalizzation: correct example
Fiscal code
Name
Person
Surname
Militar Woman
Man
situation
62
Generalization: property
Orthogonal characteristics
total generalization if each instance of the parent
entity is an instance of at least one of the child
entities, partial otherwise.
exclusive if each instance of the parent entity is at
most one instance of one of the child entities,
overlapping otherwise.
63
Generalization: example
Military
situation Man Woman
Man
Person
Woman
64
Generalization: example
Skier
Athletic Both skier
and sailor
Neither skier,
nor sailor
Sailor
65
Subset
Employee
66
The Entity-Relationship Model
Date Time
Department Professor ID
Holder
Surname (1,N)
Name Professor
68
Documentation of E-R schemes
Data Dictionary
allows to enrich the E-R scheme with natural
language description of entities, relationships and
attributes
69
Data dictionary: example
71
Documentation of E-R schemes
Data Dictionary
It allows to enrich the E-R scheme with natural
language description of entities, relationships and
attributes
Constraints of integrity on data
may not always be explicitly indicated in an E-R
scheme
can be described in natural language
72
Constraints of integrity on data: example
Constraints of integrity
RV1 The grade of an exam can only take values between 0
and 30
RV2 Each student cannot pass the same exam twice
RV3 A student may not take more than three exams for the
same course during the same academic year
73
Documentation of E-R schemes
Data Dictionary
It allows to enrich the E-R scheme with natural
language description of entities, relationships and
attributes
Constraints of data integrity
may not always be explicitly indicated in an E-R
scheme
can be described in natural language
Rules for deriving data
allow to explain that a scheme concept can be
obtained (by inference or arithmetic calculation)
from other scheme concepts
74
Rules for deriving data: example
Derivation rules
RD1 The number of credits acquired by a student is obtained
by adding the number of credits of the courses for which
the student has passed the exam
RD2 The average marks of a student is obtained by
calculating the average marks of the exams passed by
the student
75
The Entity-Relationship Model
78
UML and E-R
Different formalisms
The class diagram of an application is different
from the E-R scheme of the database
The class diagram, even if designed for different
use, may be adapted for the description of the
conceptual design of a database
79