Is this in BCNF? - database

Assume that the relation is obtained through decomposition from a relation with attributes ABCDEFGHI and that dependencies over ABCDEFGHI are listed below.
R(A,B,F)
B->E
A->F
We need to convert this relation into BCNF
What i have done till now is
R1(AB)
R2(AF)
R3(BE)
Is there anything more I should do? Is this proper BCNF or am I missing something?

This answer follows from the edited question, under the following hypotheses:
the original relation is R(ABCDEFGHI)
a cover of the functional dependencies holding on it is {B->E, A->F}
Of course if my hypotheses are wrong the answer is wrong!
In this case:
the only candidate key of the original relation is ABCDGHI;
in the decomposed relation R1(ABF) the only non-trivial dependency that holds is A -> F, so the relation has the only candidate key AB;
the relation is not in BCNF, and a decomposition in BCNF is {R2(AF), R3(AB)}
Note that you cannot decompose a relation adding an extraneous attribute, like E in your decomposition.

Related

Lossy decompositions

If a relation is decomposed into 2 sub relations such that the decomposition is lossy then can these sub-relations be in any normal form (3nf or bcnf) if the parent relation is in bcnf ?
Consider a relation R(S,T,U,V) with following functional dependencies:-
S->T , T->U, U->V, V->S.
Now if I decompose the above relation into 2 relations R1 and R2 such that R1 intersection R2 is null like R1(S,T) and R2(U,V) , then is the decomposition in bcnf?
I know that R1 can have functional dependencies S->T, T->S and R2 can have functional dependencies U->V and V->U which makes it look like BCNF.
My question was do we consider the decomposition as BCNF even though it's not a valid decomposition ? By not valid I mean lossy decomposition.
From your (unclear) question:
If a relation is decomposed into 2 sub relations such that the decomposition is lossy
From a comment:
I just asked if there is a possibility that the decomposed relations be in bcnf if the parent relation is in bcnf
If that's your question then the answer is yes, there is.
Consider a variable with CK (candidate key) {a} in BCNF that can hold this:
a b
1 2
3 4
Binary decomposition {{a},{b}} is lossy with components in BCNF.
(When trying to prove something wrong always check out some simple cases in case you can find a counterexample as proof.)
do we consider the decomposition as BCNF even though it's not a valid decomposition ? By not valid I mean lossy decomposition.
When we say that a decomposition is in a certain NF, that's short for saying that all its components are in that NF. But we only ever use this shorthand when the decomposition is lossless, ie when "decomposition" is understood to be short for "lossless decomposition", because lossy decompositions are not useful.

Is this in BCNF, 3NF or neither?

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.

Specific scenario regarding BCNF decomposition

Say I have a relation ABCD with FD's (A->D and AB -> ABCD)
Will a decomposed relation ABC be in BCNF? According to the second FD, AB form a key and is therefore in BCNF, but if you only look at the FD A -> D, is the relation no longer in BCNF then?
If you decompose a given relation schema (to which given dependencies apply), the next task is to determine, for each individual dependency in the original set :
(a) which (if any) of the new, decomposed, schemas does it apply to ?
(b) how has the decomposition affected the very definition of the FD ?
Question (a) applies to your original A->D dependency.
Question (b) applies, sort of, to your original AB->ABCD dependency. I say "sort of" because that version is quite "overstated". Given that A->D was already a given, it could just as well just say AB->C.

BCNF -- Impossible to achieve?

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.

NormalizAtion concept in DB

Is this statment correct?
"A Prime attribute can be transitively dependon a key in a BCNF relation" ?
according to me it is wrong
if it is wrong then what is the Normal Form of given Relation
R(A,B,C,D) and its functional dependency set is { AB->C ,AB->D , CD->A ,CD->B ,AB->CD }
A BCNF relation can satisfy a transitive FD like A->B->C only if A and B are both superkeys or if either A->B or B->C is trivial.
Gramatical errors aside the statement is strictly correct - it's just not very interesting or useful. Normally we are interested in whether a relation satisfies any non-superkey, non-trivial FDs, which are the ones that BCNF prohibits. I suggest you recheck the quotation to make sure you have it right.

Resources