0% found this document useful (0 votes)
2 views

Ch15 (FD)-rules

The document outlines informal guidelines for database design, emphasizing the avoidance of redundancy, NULL values, and invalid tuples. It discusses functional dependencies (FDs) as a measure of relational design quality and introduces inference rules for deriving FDs. Additionally, it explains how to determine candidate keys and the closure of attributes based on given FDs.

Uploaded by

dearest.tinu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Ch15 (FD)-rules

The document outlines informal guidelines for database design, emphasizing the avoidance of redundancy, NULL values, and invalid tuples. It discusses functional dependencies (FDs) as a measure of relational design quality and introduces inference rules for deriving FDs. Additionally, it explains how to determine candidate keys and the closure of attributes based on given FDs.

Uploaded by

dearest.tinu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

DATABASE DESIGN THEORY-II

Informal guidelines for DBD


⚫ Aviod redundant values in data as it leads to update anomalies
⚫ Put together semanitcally related attributes in a table
⚫ Avoid NULL values as they lead to
− wastage of storage space
− difficulty in using aggregate functions/comparison operations
− Inconsistent records when joining tables on attributes having NULL
values
⚫ Design relations such that no invalid/spurious tuples are generated by doing a
natural-join on any relations.
Is StaffBranch a good Relation
Scheme?

PK: BranchNo
PK: StaffNo

PK: StaffNo

Pearson Education © 2009


3
FUNCTIONAL DEPENDENCY (FD)
⚫ formal measures of the "goodness" of relational designs
⚫ FDs and keys are used to define normal forms for relations
⚫ FDs are constraints that are derived from the meaning and
interrelationships of the data attributes as per their real world
semantics
⚫ A set of attributes X functionally determines a set of attributes Y
(X → Y) of a table R if the value of X determines a unique value
for Y
Characteristics of Functional
Dependencies
• Diagrammatic representation

• Determinant
• Attribute or group of attributes on left-
hand side of arrow

Pearson Education © 2009


5
FD contd..
⚫ What does FD X→ Y reveal?
− Constraint between values that can be assigned to two
sets of attributes X and Y where X and Y are subset of
R
− if two tuples t1, t2 in relation state r(R) have the same value for X, then
they must have the same value for Y (Note- reverse may not be true) I.e.
t1[X]=t2[X] => t1[Y]=t2[Y]
− The constraint must hold on every relation instance r(R)
Examples on FDs using COMPANY SCHEMA
⚫ Social security number determines employee name in EMPLOYEE
table
⚫ SSN -> ENAME

⚫ Project number determines project name and location in PROJECT


table
− PNUMBER -> {PNAME, PLOCATION}
− may be written as
− PNUMBER -> PNAME, PNUMBER-> PLOCATION
⚫ Employee ssn and project number both determines the hours per
week that the employee works on the project
⚫ {SSN, PNUMBER} -> HOURS .....(A)
⚫ Hence {SSN -> HOURS, PNUMBER->HOURS} is incorrect
and is not equivalent to FD (A)
Given FD X→ Y on R, when X can be the
candidate for key of R?
⚫ Set of attributes X do not have duplicate values
in r(R)
⚫ Y represents all other attributes of R
⚫ Simply stated , when X functionally determines all attributes
in R and no two distinct tuples are have same values on X
i.e. t1[X]=t2[X]) , then X is candidate for KEY of R
To have knowledge about all candidate keys of R, one must know about all possible
FDs which could hold in R
INFERENCE RULES
⚫ To find out all possible FDs (F+ called as F closure) in R
given a few FDs (F) on R
⚫ Total six inference rules out of which first three (IR1-IR3)
are called Armstrong's inference rules/Axioms:
− IR1. (Reflexive) If 𝑋 ⊇ 𝑌 then 𝑋 → 𝑌 i.e. F ⊨ {X → Y | Y ⊆ X} for
any X. Such Fds are called as Trivial FDs
− IR2. (Augmentation) {X → Y} ⊨ {XZ → YZ}, Z ⊆ R
− (Notation: XZ stands for X U Z)
− IR3. (Transitive) {X → Y, Y → Z} ⊨ {X → Z}
Inference rules contd..
⚫ IR1, IR2, IR3 form a sound and complete set of inference rules
⚫ Given FA : Additional FD computed using Armstrong Rules (AR)
on given F i.e. FA = { X → Y | X → Y can be derived from F using
AR }
⚫ F + : Closure of F

F ⊨ {X → Y} means Fd {X → Y} is logically implied by F

− Soundness: ( FA ⊆ F + )
I.e. Every new FD X → Y derived from a given set of FDs F using Armstrong's Axioms is such
that F ⊨ {X → Y}

− Completeness: ( F + ⊆ FA )
I.e Any FD X → Y logically implied by F (i.e. F’ ⊨ {X → Y}) can be derived from F using
Armstrong’s Axioms
Other Inference Rules
⚫ IR4: Decomposition or Projective rule
{X → YZ} ⊨ {X → Y}
⚫ IR5: Union or Additive rule
{X → Y, X → Z} ⊨ {X → YZ}
⚫ IR6: Pseudo transitive rule
{X → Y, WY → Z} ⊨ {WX → Z}
Proofs of Axioms/ Rules
IR1(Reflexive) If 𝑋 ⊇ 𝑌 then 𝑋 → 𝑌 i.e. F ⊨ {X → Y | Y ⊆ X} for any X.
Such FDs are called as Trivial FDs
Proof of IR1.

Suppose thatIf 𝑋 ⊇ 𝑌 and that two tuples t1 and t2 exist in some relation r(R)
instance such that
t1 [X] = t2 [X]. Then t1[Y] = t2[Y] because 𝑋 ⊇ 𝑌;
Hence, 𝑋 → 𝑌 must hold in r (relation state).
IR2: (Augmentation) {X → Y} ⊨ {XZ → YZ}, Z ⊆ R

Proof of IR2 (by contradiction). Assume that X → Y holds in a relation


instance r(R) but that XZ → YZ does not hold.
⟹ ∃ two tuples t1 and t2 in r such that
1. t1 [X] = t2 [X]
2. t1 [Y] = t2 [Y]
3. t1 [XZ] = t2 [XZ]
4. t1 [YZ] ≠ t2 [YZ].
This is not possible because from (1) and (3) we deduce t1 [Z] = t2 [Z] (5)
From (2) and (5) we deduce t1 [YZ] = t2 [YZ] (6)
whereas (6) contradicts (4). Hence given {X → Y} ⊨ {XZ → YZ},
IR3. (Transitive) {X → Y, Y → Z} ⊨ {X → Z}

Given X → Y, Y → Z. Consider two tuples t1 and t2 in r(R) such that


1. t1 [X] = t2 [X] , t1 [Y] = t2 [Y] (from X → Y)
2. t1 [Y] = t2 [Y] , t1 [Z] = t2 [Z] (from Y → Z)
Hence from (1) and (2), t1 [X] = t2 [X] and t1 [Z] = t2 [Z]
⟹X→Z
Hence, the proof
Proofs of IR4-IR6

⚫ Proof : (IR4) IR4: Decomposition or Projective rule {X → YZ} ⊨ {X → Y}


X → YZ(given) YZ → Y (IR1),
use IR3 (transitivity), we get X → Y; similarly we get X → Z
⚫ Proof of IR5: Union or Additive rule {X → Y, X → Z} ⊨ {X → YZ}
Given X → Y, and X → X, ⟹ X → XY (1)
Given X → Z, Y → Y ⟹ XY → YZ (2)
using transitivity on (1) and (2) gives X → YZ

⚫ Proof of IR6: Pseudo transitive rule {X → Y, WY → Z} ⊨ {WX → Z}


Given X → Y , we get WX → WY (using IR2)
Given is WY → Z, hence using transitive rule (IR3), we get WX → Z
Closure of X under F : X+

Definition. For each such set of attributes X, we determine the set X+


of attributes that are functionally determined by X based on F;
X+ is called the closure of X under F.
Find the Key of the table whose Fd
set F is given

You might also like