Professional Documents
Culture Documents
3.0 Relational Model
3.0 Relational Model
3.0 Relational Model
2
Relational Model Terminology
3
Relational Model Terminology
4
Instances of Branch and Staff (part) Relations
5
Examples of Attribute Domains
6
Alternative Terminology for Relational Model
7
Mathematical definition of relation
D1 D2 = {(2, 1), (2, 3), (2, 5), (4, 1), (4, 3), (4, 5)}
9
Mathematical definition of relation
10
Mathematical definition of relation
11
Database Relations
Relation schema
– Named relation defined by a set of attribute
and domain name pairs.
12
Properties of Relations
13
Properties of Relations
14
Relational Keys
Superkey
– An attribute, or a set of attributes, that uniquely
identifies a tuple within a relation.
Candidate Key
– Superkey (K) such that no proper subset is a superkey
within the relation.
– In each tuple of R, values of K uniquely identify that
tuple (uniqueness).
– No proper subset of K has the uniqueness property
(irreducibility).
15
Relational Keys
Primary Key
– Candidate key selected to identify tuples uniquely
within relation.
Alternate Keys
– Candidate keys that are not selected to be primary
key.
Foreign Key
– Attribute, or set of attributes, within one relation
that matches candidate key of some (possibly same)
relation.
16
Relational Integrity
Null
– Represents value for an attribute that is
currently unknown or not applicable for tuple
– Deals with incomplete or exceptional data.
– Represents the absence of a value and is not the
same as zero or spaces, which are values.
17
Relational Integrity
Entity Integrity
– In a base relation, no attribute of a primary
key can be null.
Referential Integrity
– If foreign key exists in a relation, either
foreign key value must match a candidate
key value of some tuple in its home relation
or foreign key value must be wholly null.
18
Relational Integrity
Enterprise Constraints
– Additional rules specified by users or
database administrators.
19
Views
Base Relation
– Named relation corresponding to an entity
in conceptual schema, whose tuples are
physically stored in database.
View
– Dynamic result of one or more relational
operations operating on base relations to
produce another relation.
20
Views
21
Purpose of Views
22
Updating Views
23
Updating Views
24
Updating Views
25
ER Diagram and Relation Mapping
Company Department
Operates dNo {PK}
Company (cName, cAddress, cTelNo, cFaxNo)
cName {PK}
cAddress 1..1 1..* dName
dLoc
Primary Key cName
cTelNo
cFaxNo
1..1
Department (dNo, dName, dLoc, cName)
Primary Key dNo
Employs
Alternate Key dName
Foreign Key cName references Company (cName)
1..*
Employee (empNo, fName, lName, address, dNo)
Employment Employee Primary Key empNo
History
Has
empNo {PK} Foreign Key dNo references Department (dNo)
compOrganName 0..* 1..1
(PK) fName
address lName
position
address Dependent (dName, dAddress, relationship, empNo)
sDate
fDate 1..1
Primary Key dName
Foreign Key empNo references Employee (empNo)
RelatedTo
27