Let R{A,B,C,D,E} be a relation with functional dependencies:
B->EA
EBC->D
BED->A
Question: What's the higher normal form that R satisfies?
Attempt:
1NF: satisfied, since all the attributes are defined as single-valued.
2NF: I'm not exactly sure. 2NF states that there must not be partial dependecies. The candidate key is BC, so is B->EA considered a partial dependency or does it have to be one attribute on the rhs?
3NF: Assuming 2NF is satisfied, then for the dependency: B->EA, B is not a superkey and E,A are not prime attributes. Thus, 3NF is not satisfied.
Why (or why not) the 2NF is satisfied?
B -> EA
is equivalent to the two dependencies:
B -> E
B -> A
for the decomposition rule. Since neither E nor A are prime attribute and B is a proper subset of a candidate key, the relation is not in 2NF.
Related
I was doing homework for DB class.
One of the questions bugs me out even though I got the answer(I think)..
Question was simple.
FOR GIVEN RELATION R(A,B,C,D,E) and Functional dependencies F(AB -> C, D->E, DE ->B)
1. IS R IN 2NF?
2. IS R IN 3NF?
3. IS R IN BCNF?
I thought since there's no A and D on right-hand side of all FDs in F, A and D must be part of Candidate keys.
So I checked the Closure of AD, and I got AD+ : {A,B,C,D,E}.
That means that AD is super key.
Also, since both A and D must be part of Candidate key and AD cannot be reduced(no closure of subset of AD is {A,B,C,D,E}), AD is a candidate key and only possible candidate key. (Am I doing this right?)
With candidate key AD, D->E is partial dependence on candidate key AD.
So it violates the condition of 2NF.
On DE -> B, is this FD is violating 2NF?
If that's true then..
Is it violating because we can get D->DE from D->E . so DE -> B is equivalent to D -> B. Is this D->B is violating 2NF ??
OR
DE->B itself violates the 2NF without any conversion because of D on left-hand side?
It really confuses me when XY -> Z X is part of Candidate key and Y,Z is non-prime key.
Because I can't say it is violating 2NF or not. I think it is violating 2NF but I can't say why clearly.
I've been looking for examples and explanations and clips for hours but I haven't got any satisfying answer.
It's okay if I don't care specific reason and just want credit . But I can't bare myself with that kind of attitude.
Also, since both A and D must be part of Candidate key and AD cannot be reduced(no closure of subset of AD is {A,B,C,D,E}), AD is a candidate key and only possible candidate key. (Am I doing this right?)
Yes
Is this D->B is violating 2NF ?
Yes, since B is a non prime attribute and D is part of a candidate key and the dependency holds, since it is implied by D -> E and DE -> B (in a relation in 2NF dependencies where the determinant is a proper subset of a candidate key and the determinant is a non-prime attribute cannot hold).
I have a relation R(a,b,c,d) where (a,b) is a primary key so I have the determinant a,b -> c,d.
In addition to that I have the following determinants: a,c -> b,d and a,d -> b.
Let's be ok that this relation is in 3NF.
I'm wondering if it's in BCNF or not. I was using a definition for the BCNF that recognize:
a relation is in BCNF if it's in 3NF and there's no determinant X -> Y such as X is non-key attributes and Y is a part (or the totality) of the key
which is not applicable in my case for the determinant a,d -> b for example. Another definition is that
A relation, R, is in BCNF iff for every nontrivial FD (X->A) satisfied
by R the following condition is true:
(a) X is a superkey for R
which left me undecided insofar as in a,d->b it's clear that (a,d) is not a superkey (nor a key), but we have (a,d) clearly a key to the relation R!
So, my question is:
Is the relation R in BCNF or not, and why?
And what's the right process to determine whether a relation is or isn't in BCNF?
About terminology
You say:
I have the determinant a,b -> c,d
This is wrong therminology. a,b -> c,d is a functional dependency (sometimes abbreviated with FD), which has a determinant a,b (sometimes called left hand side (LHS) of the FD) and a determinate c,d (sometimes called right hand side, RHS, of the FD). This terminology is used since the values of the attributes a,b uniquely determinate the values of the attributes c,d.
About the key
The information that:
(a,b) is a primary key
can be irrelevant when normalizing a relation when you have enough information about the functional dependencies. From those dependencies you can calcolate which are the candidate keys: set of attributes that uniquely determines all the attributes of the relation and such that you cannot remove any attribute from them maintaining this property (in other words, minimal sets of attributes that uniquely determines all the attributes of the relation). The information about the primary key can be relevant when you have only partial information about the functional dependencies that hold in a relation, but in your case the information about all the (candidate) keys can be derived from the functional dependencies.
In your example, for instance, there are three candidate keys:
1. a, b
2. a, c
3. a, d
You can verify this fact by computing the closure of the attributes of a candidate key to see if it contains all the attributes. For instance, let's try to calculate the closure of a,d (called a,d *):
1. a,d * = a,d
2. a,d * = a,d,b (since a, d -> b)
3. a,d * = a,d,b,c (since a, b -> c, d)
So a,d is a candidate key (which is also a superkey, i.e. a set of attributes that determines all the attributes of the relation).
About the BCNF
There are different definitions of BCNF. Using for instance the second one that you cited, all the three dependencies have a determinant which is a candidate key (and so a superkey), and so the relation is in BCNF.
My doubt is for a given set of funtional dependencies F = { AE -> BCD, B -> E
}. Is this in BCNF or 3NF? It's a question from a test I have recently done and I would say that it is 3NF, but my teacher said it's neither 3NF nor BCNF. (I believe it is an error).
I have obtained as candidate keys AE and AB, and as in the first functional dependency the left side is a candidate key and in B -> E, E is contained in a candidate key, so it is in 3NF.
Is this in BCNF, 3NF or neither?
Assuming that all the attributes of the relations are A B C D and E, and that the only dependencies given are the two described (F), you are correct. Since the (only) candidate keys are correctly A E and A B, and since the functional dependency B → E has a determinant which is not a superkey, the relation is not in BCNF. Given one of the definitions of BNCF: “for all the non-trivial dependencies X → Y of F+, X is a superkey”, there is a theorem that shows that a necessary and sufficient condition for this is that the property of being a superkey holds for all the dependencies in F.
On the other hand, since E is a prime attribute, i.e. an attribute of a candidate key, the dependency B → E does not violate the 3NF, so that the relation is in 3NF. This, again, given one of the definitions of 3NF: “for all the non-trivial dependencies X → A in F+, then X is a superkey or A is a prime attribute”, is due to a theorem that says that this condition is equivalent to check, “for each functional dependency X → A1,...,An in F, and for each i in {1..n}, either Ai belongs to X, or X is a superkey or Ai is prime”. And this is satified by the two dependencies of F.
You need to use a definition of a NF when you claim/show that a relation is in it.
You don't actually say what all the attributes are. I'll assume the attributes are A through E. Otherwise, the CKs (candidate keys) are not what you say.
You are right in your argument against BCNF. You are using the definition that all determinants of FDs (functional dependencies) are out of superkeys. You found a counterexample FD B → E.
If it were an either-or question re BCNF vs 3NF you could stop there.
in the first functional dependency the left side is a candidate key and in B -> E, E is contained in a candidate key
You don't show that the table meets the conditions of either of the following definitions (from Wikipedia that happen to be correct) that a table is in 3NF if and only if:
both of the following conditions hold:
The relation is in 2NF
Every non-prime attribute is non-transitively dependent on every [candidate] key
for each of its functional dependencies X → A, at least one of the following conditions holds:
X contains A
X is a superkey
each attribute in A-X is prime
You seem to using definition 2 (but not saying so). You show bullet 2 holds for AE → BCD. Pointing out that E is prime in B → E seems to be part of showing that E-B is all prime. But you need to show every FD satisfies a bullet. Note that more FDs hold than the given ones. Armstrong's axioms tell you what all the FDs are.
In practice it can be easier to show a schema is in 3NF by applying a 3NF algorithm.
Relation schema R (ABCD)
Functional Dependencies are :
AB -> D
CB -> D
A-> C
C -> A
Highest Normal Form ???
My understanding :
Candidate key = AB and BC
While creating table both AB and BC can not consider as Primary key. So let's take one by one.
For Key AB :
AB -> D ( Fully Functional Dependency , so no problem )
CB -> D ( ??? )
A -> C (partial Functional Dependency , as left side contains only part of key)
C -> A ( Functional Dependency , So no problem )
For Key BC
AB -> D ( ???? )
CB -> D ( Fully Functional Dependency , so no problem )
A -> C (Functional Dependency )
C -> A ( Partial Functional Dependency , as it's LHS is part of Key )
Now through both key's , relation contains Partial Functional Dependency.
Then it should not be in 2NF.
But answer is 3NF.
Please correct me.
While creating table both AB and BC can not consider as Primary key.
So let's take one by one.
No. You can take them one by one, but you have to consider every candidate key. The relational model offers no theoretical basis for labeling one candidate key "primary". There might be good practical reasons for that in a SQL database, but there's no theoretical justification for it solely within the relational model.
The notion of "partial functional dependency" applies to non-prime attributes. The only non-prime attribute is D. There's no partial dependency here.
When some FDs hold, others must hold, per Armstrong's axioms. But you are only looking at given FDs.
"Partial FD" is not defined in terms of CKs (candidate keys). 2NF is defined in terms of partial FDs and CKs. 2NF holds when there are no partial FDs of non-prime attributes on any CK. Not when there are no partial FDs.
PKs (primary keys) are irrelevant. A PK is just some CK you decided to call "the PK".
Y is partially functionally dependent on X when Y is functionally dependent on a smaller/proper subset S of X. But the partial dependency so identified is X -> Y, not S -> Y.
(See this answer.)
Let R be a relation with Schema R(X,Y,Z)
and it's FDs are
{XY -> Z, Z -> Y}
I am not able to decompose it into BCNF .
Because r1(Z,Y), r2(Z,X) will lose FD XY -> Z and
R(X,Y,Z) itself is not the solution as Z->Y shows that Z should be a key ..
How to do this ???
Every conversion into BCNF may not be dependency preserving
We only need to give a counter example: Consider the following schema;
a b c and c->b
Clearly the above schema is in 3NF, because ab->c is a superkey dependency and ,from c->b we
can see that b-c=b, which is a subset of the primary key (such dependency is also allowed in 3NF).
But, the above schema is not in BCNF because c->b is neither super-key nor trivial dependency.
So we decompose above schema , keeping it lossless.
Only possible lossless decomposition is: ac and cb. (because,their intersection c is primary key for the 2nd table).
But clearly the dependency ab->c is lost.
Hence, proved.