Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SOLUTION

question is as follows:
"consider the following relation:
car sale(car#, date_sold, salesman#, commission%,
discount_amount)

assume that the car may be sold by multiple salesman


and hence (car#, salesman#) is the primary key

additional dependencies are:-


date_sold->discount_amount
salesman->commission%

Let us call the relation car_sale R and its attributes as


car #  ---> A
date_sold----> B
salesman# ----> C
commission% -----> D
discount_amount-----> E

Thus we have relation R as R(A,B,C,D,E) and functional dependencies that exist over R are
B--->E and C--->D primary key being AC.

BCNF Decomposition Algorithm: (Ref: Korth....)

ReturnBCNFRelations(R,closure of F i.e. F+)


 Step-1: result:={R}
 Step-2: done=: false
 Step-3: compute F (superscript+) {F+ being closure of set of functional dependency}
 Step-4: while(not done) do
               if (there is a schema Ri  in result that is not in BCNF)
                  then begin
                           let alpha--->beta be a non trivial functional dependency that holds
                           on Ri such that alpha--->Ri is not in F+ and alpha intersection beta=phi(null)  ;
                            result:=(result-Ri) union (Ri-beta) U (alpha,beta);
                         end
               else done:=true;
               return(R1,R2,.......,Rn);
  End of ReturnBCNFRelation
F+  =  F = { B--->E, C--->D }
Applying aforementioned algorithm to the realtion schema R:

  Step-1: Checking for relation schema R, whether it is in BCNF: 


              Functional Dependency B--->E holds on R (since B is subset of R and E subset of R)  
              But B is not a superkey of R (by computing B+ (attribute closure of B) B+ = {BE} which does not
contain all the attributes in R thus B is not a superley of R)
              Thus R is not in BCNF hence replacing R by
               R1=(ABCD)
               R2=(BE)
              (Note: R1=( R - E) and R2= (B union E) )

 Step-2: The only non trivial functional dependency that hold on R2 is B--->E (since B is subset of R2 and
E is subset of R2)
             by computing attribute closure of B i.e. B+  we get
             B+  = BE which contains all attributes of R2, hence B is a superkey of  R2
             The BCNF test says a relation R' is in BCNF if all the dependencies in F+  that holds on this relation
R'  satisfies the condition........
              Condition being: the attrbiute on the left side of arrow must be a superkey for schema R'
             Sincel B is superkey for R2 hence R2 is in BCNF.

Step-3: The functional dependency c--->D holds on R1 but C is not a superkey of R1 ( Since C+={CD})
            Thus we replace R2 by R3 nd R4
            R3=(CD ) { R3=(C union D) and R4 = (R1-D)}
            R4=(ABC)

Step-4: R3 is in BCNF as the only functional dependency that holds on R3 is C--->D and C forms a
superkey for the relation (by computing C+=(CD))
           (sufficeint condition for R3 to be in BCNF)

Step-5: Since no dependency holds on R4 the test to check whether R4 is in BCNF is:
               For every subset alpha (A,B,C,AB,BC,CA,ABC) of attributes of R4 check that attribute closure
over alpha either includes no attribute of R4-alpha  or includes all            
               attributes of R4.
               Let us compute attribute closure over subsets of R4:
  
                Attribute Closure(alpha)                                  Value                    R4-alpha
                A+                                                                A                          ABC-A= BC
                B+                                                                BE                        ABC-BE=AC 
                C+                                                                CD                        ABC-CD=AB
                AB+                                                              ABE                      ABC-ABE=C 
                BC+                                                              BCED                    ABC-BCED=A
                CA+                                                              ACD                      ABC-BE=B
                ABC+                                                           ABCDE                  ABC-ABCDE=phi
           
                Note : The above test is conducted with functional dependencies in F and not in F+.
               
             As the table shows for each subset the value of aplha+ includes no attribute of R4-alpha hence R4
is in BCNF.
 Since R=R2 union R3 union R4 and R2, R3, R4 are in BCNF (as proven above), R is also in BCNF.

Notes:
Replace R by car_sale
Similarly replace ABCDE with corresponding attributes.
For alpha , beta, union, intersection use proper mathematical notations.
Imagine some proper names for R1,R2, R3,R4

You might also like