Professional Documents
Culture Documents
Comp 3311
3311 Database
Database Management
Management Systems
Systems
1
Main Topics at Logical Data Level
3
Summary of ER Symbols II
4
Symbols of ER Diagram (Cont.)
(a) one-to-one 1 1
All employees Department Managed- Employee
by
have a dept;
a dept has only one employee
(b) one-to-many 1 N
All employees Department Works-in Employee
have a dept;
a dept has many employees
(c) many-to-many N M
Employee Member- Project
N:M of
(e)relationship N M
Employee Member- Project
attribute of
time
Symbols of ER Diagram (Cont.)
(f) recursive 1 boss
(with role names) Employee Manager-
of
N worker
(g) ternary N M
relationship Employee Uses Project
Language
ISA
7
RELATIONAL MODEL
The relational model represents the data for an applicat
ion as a collection of tables.
Relational Representation Notation
Model
Relation table R(A1, A2, …, An)
Attribute column Ai
Domain type and range of attribute dom(Ai)
values
Tuple / Record row
Attribute value value in table cell
A set of relation schemas define a relational database.
– Entities Branch
– Relationships 1
Payment
9
number date amount
BANK RELATIONAL SCHEMA
• Basic operations:
– Selection ( )
– Projection ( )
– Cross-product ( x )
– Set-difference ( - )
– Union ( )
– renaming ( )
• Additional operations:
– Intersection (), join ( ), division (/)
11
SQL: BASIC STRUCTURE
• SQL is based on set and relational algebra operations
with certain modifications and enhancements.
13
Functional Dependencies (FDs)
• A FD X Y holds on R, if and only if, for any legal relations r(R), whenever any
two tuples t1 and t2 of r agree on the attributes X, they also agree on the attribut
es Y
• Goal
– remove redundancy & preserve constraints
• Major normal forms
– BCNF: for every non-trivial FD without useless attributes X
Y, X is a candidate key.
– 3NF: a table in BCNF also satisfies 3NF. In addition, 3NF allo
ws FDs where every attribute in Y is prime.
– 2NF: a table in 3NF also satisfies 2NF. In addition, 2NF allow
s FDs where X is not a proper subset of a candidate key.
– 1NF: every relational table is 1NF because all attribute value
s are atomic.
15
3NF Decomposition Algorithm
16
BCNF Decomposition Algorithm
Compute F+;
Result = {R};
While (any XY in F+ on a schema Ri in Result violates
BCNF) {
Create a new table (X,Y);
Result = (Result-{Ri}) U {(Ri - Y)} U {(X,Y)};
}
18