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.
Related
R = {A, B, C, D, E, F, G, H, I, J}
F =
{{A,B} -> {C},
{A}-> {D,E},
{B} -> {F},
{C}-> {B},
{F}->{G,H},
{D}->{I,J}
The question is: What is the key for R?
I assume based on how the question has been formulated that there is one single candidate key which they want me to find.
If i have AB+ i can determine all the attributes in the relation meaning AB is a superkey. The proper subsets of the superkey AB which are {A} and {B} are not superkeys, hence why AB then is a candidate key. But from what i can tell there is another candidate key aswell which we can find if we have AC+. Is this correct or am i making a mistake somewhere?
Yes, you are correct: assuming that F is a cover of the dependencies of R, the relation has two candidate keys: {A, B} and {A, C}.
This can be easily shown by computing both {A,B}+ and {A,C}+.
I have trouble finding the candidate keys of a relation when there aren't any keys with only 1 attribute, so I have to find composite candidate keys.
I have the relation R(A, B, C, D, E, F, G, H, I, J, K) and the FDs:
A, B → D
A → C, E
B→ G
G → H, I
C → J, K
and I have to find the key of R, but there aren't any keys with 1 attribute. In order to find all the candidate keys of R I calculate every combination of 2 fields or I just check if the combination {A, B} is a candidate key, because there is a FD with that combination?
Thanks in advance
Any attribute that does not appear on the right side of any FD must be part of all keys. In your example, those attributes are A, B and F. Compute the closure of { A, B, F }. If it covers R (and it does), that set is the sole (candidate) key of R.
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'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.
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)