Date post: | 05-Apr-2018 |
Category: |
Documents |
Upload: | saniya-khalsa |
View: | 223 times |
Download: | 0 times |
of 17
7/31/2019 Thanh Truong Boyce Codd Normal Form
1/17
Boyce-Codd Normal Form
By: Thanh Truong
7/31/2019 Thanh Truong Boyce Codd Normal Form
2/17
Boyce-Codd Normal Form
Eliminates all redundancy that can bediscovered by functional dependencies
But, we can create a normal form morerestrictive called 4NF
7/31/2019 Thanh Truong Boyce Codd Normal Form
3/17
Definition
A relation schema Ris in BCNF with respectto a set Fif:
For all functional dependencies ofFof theform , where R and R is a trivial functional dependency()
is a superkey for schemaR
A database design is in BCNF if each memberof the set of relational schemas thatconstitute the design is in BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
4/17
Rule for schema not in BCNF
Let Rbe a schema not in BCNF, thenthere is at least one nontrivial functional
dependency such that is not asuperkey
7/31/2019 Thanh Truong Boyce Codd Normal Form
5/17
Example of not BCNF
bor_loan = (customer_id, loan_number,amount)
loan_numberamountbut loan_number is not a superkey
7/31/2019 Thanh Truong Boyce Codd Normal Form
6/17
BCNF Decomposition
The definition of BCNF can be used todirectly test if a relationship is in BCNF
If a relation is not in BCNF it can bedecomposed to create relations that arein BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
7/17
Example
borrower = (customer_id, load_number)
Is BCNF because no nontrivial functional
dependency hold onto itloan = (loan_number, amount)
Has one nontrivial functional dependency thatholds, loan_numberamount, but
loan_number is a superkey so loan is in BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
8/17
7/31/2019 Thanh Truong Boyce Codd Normal Form
9/17
Testing for BCNF
1) To check if a nontrivial dependency causes a violation of BCNF, compute
a
+
(attribute closure of), and verify that itincludes all attributes ofR; that is, is is thesuperkey ofR
2) If we can show that none of the
dependencies in Fcauses a violation ofBCNF, then none of the dependencies in F+will cause a violation of BCNF either
7/31/2019 Thanh Truong Boyce Codd Normal Form
10/17
Alternate test for 2)
For every subset of attributes in Richeck that a+(the attribute closer of
under F) either includes no attribute ofRi-, or includes all attributes ofRi
7/31/2019 Thanh Truong Boyce Codd Normal Form
11/17
BCNF DecompositionAlgorithm
IfRis not in BCNF, we can decompose Rintoa collection of BCNF schemas R1 , R2, , RnResult := {R};
done := false;computer F+
while(not done) do
if(there is a schema Ri in result that is not in BCNF)
then begin
be a nontrivial functional dependency that holds
on Ri such that -> Ri is not in F+, and = ;
result :=(resultRi) (Ri - ) (,);
endelse done := true;
Pg 289 figure 7.12
7/31/2019 Thanh Truong Boyce Codd Normal Form
12/17
Example
lending = (branch_name, branch_city, assets,customer_name, loan_number, amount)
branch_nameassets branch_cityloan_numberamount branch_name
candidate key is {loan_number,customer_name}
branch_name is not superkey so not in BCNFso lending is not BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
13/17
Example (cont)
So we replace lendingby:
branch = (branch_name, branch_city, assets)
loan_info = (branch_name, customer_name,loan_number, amount)
The only nontrivial functional dependenciesthat hold on branchinclude branch_nameon
the left side of the arrow. Sincebranch_nameis a key for branch, the relationbranchis in BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
14/17
Example (cont)
For loan_info
The functional dependency
loan_number
amount branch_nameholds on loan_infobut loan_numberis not akey for loan_info, so we replace loan_infoby
loanb = (loan_number, branch_name,
amount)borrower = (customer_name, loan_number)
loanband borrowerare in BCNF
7/31/2019 Thanh Truong Boyce Codd Normal Form
15/17
3NF pro/con
Advantage of 3NF: it is always possible toobtain a 3NF design without sacrificinglosslessness or dependency preservation
Disadvantage of 3NF: we may have to usenull values to represent some of the possiblemeaningful relationships among data items,
and there is the problem of repetition ofinformation
7/31/2019 Thanh Truong Boyce Codd Normal Form
16/17
Conclusion
Our goals of database design withfunctional dependencies are
1) BCNF2) Losslessness
3) Dependency preservation
Not possible to get all 3, we have tochoose between BCNF or dependencypreservation
7/31/2019 Thanh Truong Boyce Codd Normal Form
17/17
Source
Silberschatz, Korth, Sudarshan (2006).Database System Concepts. New York:
McGraw-Hill