






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







2
Follow instructions on course Web site
Due next Wednesday night
Expect an email regarding your DB2 account today Due February 8 (in 2 ½ weeks)
3
Design models are especially convenient for schema design, but are not necessarily implemented by DBMS Popular ones include
Relational, XML, object-oriented, etc.
Primarily a design model; not implemented by any major DBMS nowadays
5
Entity: a “thing,” like a record or an object
Entity set (rectangle): a collection of things of the same type, like a relation of tuples or a class of objects
Relationship: an association among two or more entities
Relationship set (diamond): a set of relationships of the same type; an association among two or more entity sets
Attributes (ovals): properties of entities or relationships, like attributes of tuples or objects
Students Courses
CID title
Enroll
SID name
6
Comes with a declarative query language OQL (Object Query Language) Implemented by OODBMS (Object-Oriented DataBase Management Systems)
In no instance of R will two different tuples agree on all attributes of K
SID is a key of Student { SID , name } is not a key (not minimal)
11
Student SID name age GPA 142 Bart 10 2. 123 Milhouse 10 3. 857 Lisa 8 4. 456 Ralph 8 2. ... ... ... ...
12
Enroll ( SID , CID )
Address ( street_address , city , state , zip )
Course ( CID , title , room , day_of_week , begin_time , end_time )
Many selection conditions are “key = value”
Example: Enroll ( SID , CID )
14
Why is this design is bad? This design has redundancy, because the name of a student is recorded multiple times, once for each course the student is taking
Why is redundancy bad?
How about a systematic approach to detecting and removing redundancy in designs? Dependencies, decompositions, and normal forms
SID name CID 142 Bart CPS 142 Bart CPS 857 Lisa CPS 857 Lisa CPS ... ... ...
15
X Y Z a b c a?? ... ... ...
X Y Z a b c a b? Must be b (^) ... ... ... Could be anything
Start with closure = Z If X → Y is in F and X is already in the closure, then also add Y to the closure Repeat until no more attributes can be added
20
21
F includes: SID → name , email email → SID SID , CID → grade
{ CID , email } +^ =?
email → SID Add SID ; closure is now { CID , email , SID }
SID → name , email Add name , email ; closure is now { CID , email , SID , name }
SID , CID → grade Add grade ; closure is now all the attributes in StudentGrade
Compute X +^ with respect to F If Y ⊆ X +^ , then X → Y follow from F
23
Reflexivity: If Y ⊆ X , then X → Y Augmentation: If X → Y , then XZ → YZ for any Z Transitivity: If X → Y and Y → Z , then X → Z
Splitting: If X → YZ , then X → Y and X → Z Combining: If X → Y and X → Z , then X → YZ
24
Since X is not a super key, there are some attributes (say Z ) that are not functionally determined by X
X Y Z a b c 1 a b c 2 ... ... ... The fact that a is always associated with b is recorded in multiple rows: redundancy!
SID CID grade 142 CPS216 B- 142 CPS214 B 123 CPS216 B+ 857 CPS216 A+ 857 CPS230 A+ 456 CPS214 C ... ... ...
SID CID 142 CPS 142 CPS 123 CPS 857 CPS 857 CPS 456 CPS ... ...
SID grade 142 B- 142 B 123 B+ 857 A+ 857 A+ 456 C ... ...
29
30
For every non-trivial FD X → Y in R , X is a super key That is, all FDs follow from “key → other attributes”
As long as some relation is not in BCNF
Always decompose on a BCNF violation )Then it is guaranteed to be a correct decomposition!
That is, a non-trivial FD X → Y in R where X is not a super key of R
R 1 has attributes X ∪ Y R 2 has attributes X ∪ Z , where Z contains all attributes of R that are in neither X nor Y
32
StudentGrade ( SID , name , email , CID , grade ) BCNF violation: SID → name , email
Student ( SID , name , email ) Grade ( SID , CID , grade )
BCNF BCNF
33
StudentGrade ( SID , name , email , CID , grade )