I've been looking to decompose the following relation from its present state, into BCNF with three functional dependencies.
Taking the maxim
the key, the whole key, and nothing but the key
I concluded that B-->C transitive functional dependency meant it was in 2NF, and should be decomposed to remove this into
This also, I think, should be in BCNF. However, my question is, does the A,B --> C FD break this - because it doesn't seem to match the 'nothing but the key', aspect of the maxim above? (And the 'B' part of the A,B --> FD is not a key attribute, rather 'B' is addition to the key)
You should note that the three dependencies:
A → B
A B → D
B → C
are not a canonical cover (A B → D can be simplified to A → D, given A → B). So, the canonical cover is:
A → B
A → D
B → C
and since the key is A, you are correct in decomponing the relation in:
R1<(B, C), {B → C}>
R2<(A, B, D), {A → B, A → D}>
Note that all the dependencies satisfy the BCNF definition, since the key of R1 is B, the key of R2 is A, and each depedency has its LHS which is a key.
Related
Suppose we have a relation R(A, B, C, D).
If R has the following functional dependencies:
A, C -> D
B, C -> D
A -> B
B -> A
We should have the following candidate keys:
{A, C}, {B, C}
Thus, A, B and C are prime attributes.
I chose {A, C} as the primary key.
At this point I have arrived at an impasse.
While, from my experience, when normalising to the 2nd Normal Form it would be advisable to split the relation into:
R1(A, C, D)
R2(A, B)
But technically, following the requisites of the 2nd Normal Form, this isn't necessary as R is already in 2nd Normal Form.
Should I follow my gut and separate the relation or should I leave it as it is?
I am trying to solve an exercise related with functional dependencies and database normalization. I have solved many exercises similar to this one but I can not solved this.
For a given a Schema with a single relation R(A, B, C, D, E, F), the set of all functional dependencies that holds is:
BC -> DC
B -> E
D -> EF
FC -> E
C -> A
F -> E
Normalize the relation R so it satisfies the 2NF AND all Functional dependencies are kept.
What I have done so far:
1) Find candidate keys: {BC} (I think there is a single candidate key)
2) Find a minimal equivalent set of dependencies
BC → D
B → E
D → EF
C → A
F → E
3) use C → A (A depends on C that is part of the candidate key, A is non prime)
R1(B, C, D, E, F), candidate keys BC
R2(C, A) candidate keys C
4) use B → E (E depends on B that is part of the candidate key, E is non prime)
R2(C, A) candidate keys C
R11(B, C, D, F) candidate keys BC
R12(B, E) candidate keys B
I do not like this normalization because the functional dependency F -> E can not be recovered. I am looking for a decomposition of R such that the second normal form is satisfied and no functional dependency is lost. Can anybody help me to find such decomposition?
I have following example which I am trying to understand, where:
R = {A, B, C}
FD = {A->B, B->C, AB->C}
Prime key is A.
I know that this example is in 2NF, because prime key has only one element, but I dont understand why this example is not in 3NF.
C is functionaly dependent on AB, but B is not a key or part of an key. Is that the reason why it is not in the 3NF.
Thanks
In Relation R, the canonical cover of the set of dependencies FD is:
1. A → B
2. B → C
The reason is that the dependency A B → C can be derived from the others:
1. A → B (given)
2. AB → B (by enrichment of A → B)
3. AB → C (by transitivity of AB → B and B → C)
A candidate key of the relation is A, since its closure determines all the other attributes:
A+ = A
A+ = AB (by using A → B)
A+ = ABC (by using B → C)
No other attribute can be a key (B cannot determine A, C appear only on the rigth part of a dependency).
Remember that a schema is in Boyce-Codd Normal Form (BCNF) if and only if all the determinants of the functional dependencies of the canonical cover are superkeys, or, for the Third Normal Form (3NF), if and only if all the determinants of the functional dependencies of the canonical cover are superkeys, or a determinate is a prime attribute.
So, the schema is not in BCNF, neither in 3NF, since there is the functional dependency B → C in which the determinant B is not a key, and C is not a prime attribute. Finally, decomposing the schema in two relations:
R1 < (A B), { A → B } >
R2 < (B C), { B → C } >
we have two relations that are both in 3NF and in BCNF, and this decomposition preserves the functional dependencies of the original schema.
Given
R(a, b, c, d, e, p, w)
two keys: (b, c, d) and (p).
F ={
{b,c,d} -> {a,e,p,w},
p -> {a, b, c, d, e, w},
w -> c
}.
Is R in the 3rd normal form?
R(a,b,c,d,e) and a set of FD
F={
Fdl: {a,b} -> {c,d,e}
Fd2: c -> {a,b,d,e}
Fd3: e-> a
}
Keys for R: {a,b} and {c}.
Is R in 2nd normal form?
I know that in 2NF there must not be any partial dependency of any column on primary key, as well as, in 3NF every non-prime attribute of table must be dependent on primary key.
But I don't get these example from the book.
Is R in the 3rd normal form?
No, R is not in 3NF as in 3NF we have two main properties: that if X->A then either X should be a super key or A should be a prime attribute. In FD3 w->c does not have these properties.
Is R in 2nd normal form?
Yes it is in 2NF, as in the RHS of the FDs the prime attributes are present.
I am trying to comprehend BCNF databasing and I can't quite wrap my head around it.
Consider the following relation:
R (A, B, C, D, E, F, G)
The following functional dependences hold:
A -> E, F
A -> G
A, B -> D
B -> C
E, F -> G
A -> D
How would I make it BCNF?
Speaking informally, in homework problems, you get to BCNF by
assuming you're in at least 1NF,
removing partial key dependencies to get to 2NF (at least),
removing transitive dependencies to get to 3NF (at least), and finally
removing remaining functional dependencies in which the left-hand side isn't a candidate key to get to BCNF (at least).
An example of a partial key dependency is the pair
AB->D
A->D
Since A alone determines D, the functional dependency AB->D has a partial key dependency.
An example of a transitive dependency is the pair
A->EF
EF->G
There's no guarantee that you can normalize a given relation to, say, BCNF and no higher. (This seems to cause a lot of confusion among university students on SO.) Removing partial-key dependencies to get to 2NF might leave all the relations in 5NF.
)We can use the Armstrong Axioms to get the F+
A -> D,E,F,G
B -> C (A,B -> D is ignored because A -> D)
E,F -> G
We can get the primary key(A,B).
According to the definition of BCNF, we have to separate A-> (E,F), B->C, A -> D and (E,F) -> G from the original schema.
(A,B) Primary key(A,B)
(B,C) Primary Key(B)
(A,D) Primary Key(A)
(A,E,F) Primary Key(A)
(E,F,G) Primary Key(E,F)
That's BCNF decomposition.
You can try this:
Table 1: A, B, D, E, F with composite primary keys (A, B) and foreign key( B) refer to table 2(B)
Table 2: B, C with B is primary key
Table 3: A, E, F, G with composite primary keys(A, E, F)