Docsity

Boyce-Codd NF - Data Base Management System - Lecture Slides, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Boyce-Codd NF - Data Base Management System - Lecture Slides and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Boyce-Codd NF & Lossless

Decomposition

Armstrong’s Axioms

For computing the set of FDs that follow a given FD, the following rules called Armstrong’s axioms are useful:

  1. Reflexivity: If B ⊆ A, then A  B
  2. Augmentation: If A  B, then A ∪ C  B ∪ C Note also that if A  B, then A ∪ C  B for any set of attributes C.
  3. Transitivity: If A  B and B  C then A  C
  • FD graph of R is
  • A B C D
  • B  A
  • AC  B
  • *BD  A, C
  • *CD  A, B
  • Prime Attribute = key attributes are {B,C,D}
  • B  A and B is not a key, So R is not 3NF
  • R is not BCNF

Projecting FDs

Given a relation R (A,B,C,D) and F(R) = {AB, BC,

CD}.

Suppose S is projected from R as S(A,C,D). What is F(S).

To compute F(S), start by computing the closures of all

attributes

in S.

In R, A +^ = {AB, AC, AD}

In S, A +^ = {AC, AD}

C+^ = {CD} and

D +^ = {D}

Since A +^ contains all attributes of S, it is not required to

compute

(AC)+, (AD)+^ or (ACD)+.

Inference Rules for FD’s

(continued)

Trivial Rule

Why?

A 1 …^ A (^) m

where i = 1, 2, ..., n

A 1 , A 2 , …, An  Ai

Inference Rules for FD’s

(continued)

Transitive Closure Rule

If

and

then

Why?

A 1 , A 2 , …, An  B 1 , B 2 , …, Bm

B 1 , B 2 , …, Bm  C 1 , C 2 , …, Cp

A 1 , A 2 , …, An  C 1 , C 2 , …, Cp

Example (continued)

Start from the following FDs:

Infer the following FDs:

  1. name  color
  2. category  department
  3. color, category  price

Inferred FD

Which Rule did we apply ?

  1. name, category  name
  2. name, category  color
  3. name, category  category
  4. name, category  color, category

Another Rule

If

then

Augmentation follows from trivial rules and transitivity How?

A 1 , A 2 , …, An  B

A 1 , A 2 , …, An , C 1 , C 2 , …, Cp  B

Augmentation

Closure of a set of Attributes

Given a set of attributes A 1 , …, An

The closure , {A 1 , …, An } +^ , is the set of attributes B s.t. A 1 , …, An  B

name  color category  department color, category  price

Example:

Closures: name +^ = {name, color} {name, category}+^ = {name, category, color, department, price} color +^ = {color}

Closure Algorithm

Start with X={A1, …, An}.

Repeat until X doesn’t change do :

if B 1 , …, Bn  C is a FD and B 1 , …, Bn are all in X then add C to X. {name, category}^

{name, category, color, department, price}

name  color category  department color, category  price

Example:

Using Closure to Infer ALL FDs

A, B  C
A, D  B
B  D

Example:

Step 1: Compute X+, for every X: A+ = A, B+ = BD, C+ = C, D+ = D AB+ = ABCD, AC+ = AC, AD+ = ABCD ABC+ = ABD+ = ACD+^ = ABCD (no need to compute– why ?) BCD+^ = BCD, ABCD+ = ABCD

Step 2: Enumerate all FD’s X  Y, s.t. Y ⊆ X+^ and X∩Y = ∅:

AB  CD, ADBC, ABC  D, ABD  C, ACD  B Docsity.com

Problem: Finding FDs

  • Approach 1: During Database Design
    • Designer derives them from real-world knowledge of users
    • Problem: knowledge might not be available
  • Approach 2: From a Database Instance
    • Analyze given database instance and find all FD’s satisfied by that instance
    • Useful if designers don’t get enough information from users
    • Problem: FDs might be artifical for the given instance

Answer

Course  Dept, Room Dept, Room  Course Student, Dept  Course, Room Student, Course  Dept, Room Student, Room  Dept, Course

Do all FDs make sense in practice?

Keys

  • A key is a set of attributes A 1 , ..., An s.t. for any other

attribute B, we have A 1 , ..., An  B

  • A minimal key is a set of attributes which is a key and for

which no subset is a key

  • Note: book calls them superkey and key