Distributed Database Management Systems: Lecture 5. The main topics covered in this chapter include: data model; legacy data models; a set of tools/constructs used to model a database; record/semantic; relational data model; primary key;...
Trang 1Distributed Database Management System
Lecture 05
Trang 2Virtual University of Pakistan 2
Data Model
• A set of tools/ constructs
used to model a database
• Record/Semantic
Trang 3Virtual University of Pakistan 3
Legacy Data Models
• Hierarchical
• Network
• Relational
Trang 4Virtual University of Pakistan 4
Relational Data Model
• Two major Strengths
• Three Components
• Relational databases based
on relational Data Model
Trang 5Virtual University of Pakistan 5
• A relation R defined over
domains D1, D2, …., Dn is a set of n-tuples, <d1, d2, …,
dn> such that <d1 D1……,
dn Dn
Trang 6Virtual University of Pakistan 6
Schemes in RDB
• EMP(eNo, eName, eTitle,
eSal, pNo, eResp, pDur)
• PROJ(pNo, pName, bud)
Trang 7Virtual University of Pakistan 7
• Each of the attribute in these
two relations has a domain, like…
• Domains need not to be
distinct
Trang 8Keys
Trang 9Virtual University of Pakistan 9
• Minimum nonempty subset
of a relation whose values uniquely identify each tuple
in relation
Primary Key
Trang 10Virtual University of Pakistan 10
• The superset of the key is
super key, like…
• We also have candidate,
alternate, secondary, foreign
Trang 11Table
Trang 12Virtual University of Pakistan 12
• Relation represented in a two
dimensional form
pBud pName
pNo
PROJ
eDur eResp
pNo eSal
eTitle eName
eNo
EMP
Trang 13Virtual University of Pakistan 13
eDur eResp
pNo eSal
eTitle eName
eNo
12 7 12 15 10 10
Work Mangr Cons Cons Cons Mangr
P1 P2 P1 P1 P2 P3
500 700 700 850 700 900
Supr Desin Prog Eng Prog Anlyst
Naeem Rahila Narjis Aslam Hafeez Liaqat
Trang 14Virtual University of Pakistan 14
• After defining a relation’s
scheme, it is populated
• Tuples are rows and
attributes are cols
Trang 15Virtual University of Pakistan 15
• Attributes get values from
same domain
• Can have NULL value,
but…
Trang 16Virtual University of Pakistan 16
Normalization
Step-by-step reversible process to produce
anomalies free smarter tables
Trang 17Virtual University of Pakistan 17
• Anomalies Types….
• Major step is decomposition
• Universal Relation approach
Trang 18Virtual University of Pakistan 18
• Three Normal Forms
• Lossless decomposition
• Dependency preservation
Trang 19Virtual University of Pakistan 19
Trang 20Virtual University of Pakistan 20
Dependencies
A relation R defined on
attributes A(A1, A2, …., An), if
X A, Y A, if for each value of X
Trang 21Virtual University of Pakistan 21
there is a unique value in Y,
then X functionally determines
Y, X Y
Trang 22Virtual University of Pakistan 22
• If X Y and there is a Z X
and ZY, then X partially
determines Y or Y is partially dependent on X
Trang 23Virtual University of Pakistan 23
A relation R defined on
attributes A(A1, A2, …., An),
if X A, Y A, Z A, if for each value of X, there is
Trang 24Virtual University of Pakistan 24
there is unique value of (Y,Z)
pair and Z depends only on X then X multidetermines Z,
X Z
Trang 25Virtual University of Pakistan 25
Trang 26Virtual University of Pakistan 26
• 1NF, attributes have only
atomic values
• 2NF, there are no partial
dependencies
• 3NF, for each XY where Y is
not in X, either X is a superkey
of R or Y is prime attribute