Why is given example not in 3NF? - database

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.

Related

database normalization, second normal form exercise

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?

BCNF project FD on the result relations

So i have a relation R(A, B, C, D, E), with FD
{A->C, CE->B, BC->AD, D-E}.
And i want to normalize it to BCNF.
Since A->C and D->E violate BCNF. i substract C and E from ABCDE
which will be ABD. But how do i project the FD of the original Relation to the new ABD relation? I was told that the resulted FD on ABD will be
{AB->D, AD->B}
I don't quite understand it.
Any help would be appreciated!
The algorithm to project a set of dependencies over a decomposed schema is exponential, since one should calculate the closure of each subset of the attributes of the decomposed schema, and see which attributes of the closure belong to the decomposed relation. In simple cases, however, like that of your example, it is easy to check all the possible subsets (six):
A+ = AC
B+ = B
D+ = DE
AB+ = ABCDE (D is present in ABD, so AB → D is in the projection)
AD+ = ABCDE (B is present in ABD, so AD → B is in the projection)
BD+ = BDE

BCNF Decomposition and Keys

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.

Finding out 2NF for Functional Dependency

I have a relation R consisting of {A,B,C,D,E,F} and the below are the dependencies that follow :
{A} -> {C,F}
{C} -> {D}
{B} -> {E}
This has to be converted to 2NF and 3NF accordingly.
I just converted them accordingly.
Could you please validate and let me know if the below forms are valid ?
2NF :
{A,C,F,D}
{B,E}
3NF :
{A,C,F}
{C,D}
{B,E}
The conversion in 3NF is not a correct one, since you have a decomposition that is not “data preserving” (that is, if you have an instance of the relation R, and project it over the attributes of the decomposed relations, when you do the natural join of them you obtain a relation which is different from R).
The reason is that the (only) candidate key of R is {A,B}, and this two attributes must be both present in a decomposed relation. So, in the synthesis algorithm to decompose a schema in 3NF, the last step says that if no candidate key of the original relation is present in any decomposed relation, one must add a schema with a key. So the correct decomposition is the following:
R1 < (A C F), { A → C F } >
R2 < (B E), { B → E } >
R3 < (C D), { C → D } >
R4 < (A B), { } >

Primary key of a relation with circular functional dependencies

I'm studying for my database exam and I'm not sure about one question which goes as follow:
Given the relation R={A, B, C, D, E, F, G, H, I} and the set of functional dependencies
F = { AB -> C,
A -> DE,
C -> AB,
B -> FGH,
D -> IJ,
D -> CBE
}
Under what (normal) form is this relation?
First, I know I have to find all candidate keys. Looking at the right, I see that every attribute of R appears on the right hand-side, so it is not trivial that any single attribute of R is a candidate key. So looking at the left hand-size, only A, B, C, D appear, so one or some of these attributes must appear in the candidate keys.
So using A, C and D works (details skipped), but using B alone doesn't. Considering using two-attribute ket is useless since any key that does not contain A, C or D won't "bring us back" to R. Exemple, BE allows us to find B, E, F, G, H, but then we can't proceed further, so not all attributes of R are found.
Also, using any combination with A, C, or D in it is useless since it contains a subset (a single attribute) which is part of a candidate key (a single attribute). Example, AB can be reduced to A, and then all attributes of R can be found.
What bugs me is AB -> C and C -> AB, which is a circular dependency. I thought of two possibilities:
C is the primary key and we can use it to find A and B (C -> AB);
AB can be reduced to A (as said above) and with it we can find C.
But it is very easy to see that AB must be unique and C must also be unique.
Let's only use AB -> C. We can have the following associations:
11 -> 1 (A = 1, B = 1, C = 1)
12 -> 1
But then, if we reinsert the rule C -> AB, we find:
1 -> 11
1 -> 12
which can't hold.
So C has to be unique.
Same thing if we only consider C -> AB, and then reinsert the rule AB -> C.
I'm starting to think that this is a trick and that the real primary key of this relation is ABC to ensure uniqueness of the combinations of AB and C. We would then have the following rules:
F'={
ABC -> DEFGH
D -> IJ
D -> CBE
}
Is this right? What about the other circular dependency, i.e. C -> D (first rule), D -> C (third rule), and C -> D (going back to first rule)? Do I simply not care about it?
If I don't care about it (and assuming the primary key is ABC), then it seems obvious that this table is not in 3NF since ABC determines D (which is a non prime attribute here), and D determines IJ, two non prime attributes. But it seems to be in 2NF because no non prime attribute (D, E, F, G, H, I, J) can be obtain using a subset of attributes of the candidate keys (ABC here).
Of course, I could consider the primary key to be A, C or D and split AB -> C and C -> AB in two separate relations, but I don't think joining those two tables will always respect the rules AB -> C and C -> AB. For example, if someone inserts a new row in one of the table, then the join could introduce an invalid row.
I am thinking too much? Am I going in the wrong direction?
Thanks for your help :)
AB -> C
A -> DE
C -> AB
B -> FGH
D -> IJ
D -> CBE
I will assume that the FDs in your relation are known to be exactly those in the the transitive closure of F. (What were you actually told about F vis a vis your relation?)
{} only determines trivially.
{A} determines DE, which determines IJCB, which determines FGH. CK.
{B} determines FGH. Not CK.
{C} determines AB. CK.
{D} determines IJCBE. CK.
Other singleton sets just determine trivially.
Proper supersets of A, C and D are not CKs.
Other proper supersets are of B,E,F,G,H,I,J, which cannot determine A, C or D. Not CKs.
That accounts for all subsets of attributes.
So the CKs are {A},{B} and {D}.
What bugs me is AB -> C and C -> AB, which is a circular dependency.
Why should this bug you? Just follow the rules you were given. Review the definition of CK and how to determine the CKs from FDs. Eschew non-technical terms.
the real primary key of this relation
"Primary key" is not a useful notion in normalization. (I can't make much sense of what follows.)
this table is not in 3NF since
I don't see any definition of 3NF being used in your reasoning. You seem to use a definition of BCNF, but not properly.
assuming the primary key is ABC
the candidate keys (ABC here)
Make up your mind. Is there one candidate key {A,B,C} or three candidate keys {A}, {B} and {C}? This is two different situations.
it seems to be in 2NF because no non prime attribute [...] can be obtain using a subset of attributes of the candidate keys
You mean no non-prime attribute is functionally dependent on a proper subset of attributes of any candidate key. You misquoted, then misused what you quoted as if it meant what you should have quoted.
Review the definitions of the normal forms and the definitions they depend on.

Resources