Assignment 8 - Sao Chép
Assignment 8 - Sao Chép
(Cont)
1. Consider the schema R = (A, B, C, D, E, G) and the set F of functional dependencies: A→ BC BD → E CD
→ AB a. Find a nontrivial functional dependency containing no extraneous attributes that is logically
implied by the above three dependencies and explain how you found it. One of the non-trivial functional
dependency containing no extraneous attribute is AD -> BCE Explanation: We need to check by taking a
combination of attributes, there can be below combinations (1) taking one attribute at a time (2) taking
two attributes at a time (3) taking 3 attributes at a time (4) taking 4 attributes at a time (5) taking 5
attributes at a time (6) taking all 6 attributes at a time. =>By following the above procedure we can't get
any non-trivial functional dependency taking one attribute at a time containing no extraneous attribute
from the given functional dependencies. => By following the above procedure we can get a non-trivial
functional dependency taking two attributes at a time containing no extraneous attribute from the given
functional dependencies. AD+ = ADBCE ( taking closure of AD ) => So non trivial functional dependency is
A -> BCE b. Use the BCNF decomposition algorithm to find a BCNF decomposition of R. Start with A →
BC. Explain your steps. The candidate keys are = { ADG, CDG } Explanation: As we can see that attributes
D and G are not present in any functional dependency on the right side part so D and G must be
included in the candidate key for sure as the candidate key has the property that it can derive all the
attributes of the table when we take the closure of candidate key. => D and G are there in candidate
keys now we will check DG+ first, DG+ = DG (it's not candidate key as it can't derive all the attributes of
the table) => Now taking one by one other attributes where D and G must be included. (ADG)+ =
ABCDEG (its candidate key as it can derive all the attributes of the table) (BDG)+ = BDEG (its not
candidate key as it can't derive all the attributes of the table) (CDG)+ = ABCDEG (its candidate key as it
can derive all the attributes of the table) (DEG)+ = DEG (its not candidate key as it can't derive all the
attributes of the table) => Now we can see that A and C are already included in candidate keys with
mandatory attributes D and G, So we will not include in other cases because it will form a super key
(BDEG+ = BDEG (its not candidate key as it can't derive all the attributes of the table) Hence the
candidate keys are = { ADG, CDG } c. For your decomposition, state whether it is lossless and explain
why. Functional dependencies F = { A -> BC, BD -> E, AD -> E, CD -> AB } The candidate keys are = { ADG,
CDG } => As relation does not contain any multivalued attribute or complex attribute so the relation is in
1 NF => The functional dependency A -> BC is partial functional dependency as attribute A is the proper
set of candidate keys. converting A -> BC into 2 NF or removing partial functional dependency, we need
to decompose the relation R. R1(A, B, C) with functional dependency A -> BC => BD -> E satisfies 2 NF as
on the left side we have a combination of prime attribute and nonprime attribute. => AD -> E, CD -> AB
are having partial functional dependency hence we need decomposition of relation R R2(A, D, E ) with
functional dependency AD -> E and R3( A, B ,C ,D) with functional dependency CD -> AB => We can see
that BD -> E does not satisfy 3 NF property as BD is not a candidate key and E is not a prime attribute so
we need to decompose the relation. R4(B, D, E) with BD -> E functional dependency, => There will be
another table which is R5(A, E, G) => Now we can see all the functional dependencies { A -> BC, BD -> E,
AD -> E, CD -> AB } satisfy the 3 NF as well as BCNF as we can see left part of every functional
dependency is a candidate key. Hence relation is in BCNF now. d. For your decomposition, state whether
it is dependency preserving and explain why. As we know that every BCNF decomposition is lossless
decomposition. We can check by applying the conditions of lossless decomposition- (1) When we
combine all the attributes of all the relation it should form the initial relation. (2) At least one common
attribute should be there between every two tables. (3) Common attributes should be a candidate key of
at least one table. All three conditions must be satisfied to follow lossless decomposition. => As we can
when we combine R1(A, B, C) U R2(A, D, E ) U R3( A, B, C, D) U R4(B, D, E) U R5(A, E, G) = R hence the
first condition is satisfied. => There is a common attribute A between relations R1(A, B, C) and R2(A, D,
E ) => A is the candidate key of R1(A, B, C) hence these two tables are satisfying lossless decomposition,
this way we need to check every pair of tables and can declare that BCNF decomposition is always
lossless decomposition. 2. Consider the schema R = (A, B, C, D, E, G) and the set F of functional
dependencies: AB → CD ADE → GDE A→ GC G → DE Use the 3NF decomposition algorithm to generate a
3NF decomposition of R, and show your work. This means: a. A list of all candidate keys Here, attributes
A and B both are not in present in any of the Functional Dependencies. So, AB will surely be a part of
candidate key. Lets find closure of AB. {AB}+ = {A, B, C, D, G, E} As, closure of AB contains all the
attributes AB itself is a candidate key. Hence there is only 1 candidate key i.e {A, B}. b. A canonical cover
for F, along with an explanation of the steps you took to generate it i) Simplify the functional
dependencies. F = { .AB → C .AB → D ADE → G .ADE → D .ADE → E B → G B → C G → D G → E } ii) Find
redundant Functional dependencies and remove them from the set. To do so find the closure of LHS of
the FD and don't consider that FD while finding the canonical cover. c. The remaining steps of the
algorithm, with explanation d. The final decomposition 3. Consider the schema R = (A, B, C, D, E, G,H)
and the set F of functional dependencies: AB → CD D → C DE → B DEH → AB AC → DC Use the 3NF
decomposition algorithm to generate a 3NF decomposition of R, and show your work. This means: a. A
list of all candidate keys Explanation: Finding candidate keys: =>There is no attributes "E", "G" and "H" at
the right hand side part of any of the given functional dependencies hence these attributes must be
present in every candidate key as candidate key has ability to derive all the attributes of the relation.
=>(DEGH)+ = ABCDEGH =>(ABEGH)+ = ABCDEGH =>(ACEGH)+ = ABCDEGH =>Hence candidate keys =
{DEGH, ABEGH, ACEGH} b. A canonical cover for F Explanation: Finding cannonical cover of F: Step 1:
=>Split the functional dependencies such that there should be exactly one attribute at the right hand
side part of any of the functional dependencies. =>Functional dependencies = {AB -> C, AB -> D, D -> C,
DE -> B, DEH -> A, DEH -> B, AC - > D, AC ->C} Step 2: =>Removing unused functional dependencies.
=>Functional dependencies AC -> C, AB -> C are unused functional dependencies. =>Functional
dependencies = {AB -> D, D -> C, DE -> B, DEH -> A, DEH -> B, AC -> D} Step 3: =>Removing extraneous
attributes. =>In functional dependencies DEH -> B, attribute H is extraneous hence removing it.
=>Functional dependencies = {AB -> D, D -> C, DE -> B, DEH -> A, AC -> D} =>Hence cannonical cover =
{AB -> D, D -> C, DE -> B, DEH -> A, AC -> D} c. The steps of the algorithm, with explanation Explanation:
=>Reduced functional dependency set = {AB -> D, D -> C, DE -> B, DEH -> A, AC -> D} =>Candidate keys =
{DEGH, ABEGH, ACEGH} Finding normal form of R: =>R is in 1 NF as there is no multivalued or complex
attributes in the relation R. =>Relation is also in 2 NF as there is no partial functional dependencies of
type X -> Y where X is proper subset of candidate key and Y is non prime attribute. =>Relation is also in 3
NF as all the functional dependencies are of type X -> Y where either X is super key or Y is prime
attribute. d. The final decomposition Explanation: =>As relation R is in 3 NF with reduced functional
dependencies set hence no need to decompose the relation. I have explained each and every part with
the help of statements attached to the answer above.