Normalization 3NF and BCNF - database

If I have the following relation R = (A, B, C, D)
And the functional dependencies:
A -> B, B -> A, CDB -> A, CDA -> B
The candidate keys are CDA and CDB.
The third normal form says that there can not be a functional dependency between non-prime attributes. A non-prime attribute is an attribute that doesn't occur in one of the candidate keys. Then that means that this relation already is 3NF since both A and B, that depend on each other, are part of one of the candidate keys, am I right?
If so, I have another question about BCNF. BCNF says that every determinant must be a candidate key. In this case, A and B are not candidate keys, so that violates BCNF, or am I missing something here?
Thanks.

If the three FDs you have given are supposed to be a canonical cover of the FDs satisfied by R then you are right to conclude that CDA and CDB must be candidate keys. (You didn't state the FDs are canonical and if not then there are other ways to satisfy the same dependencies but I guess the intent of the question is that the candidate keys must be inferred only from what you are given.)
If CDA and CDB are in fact the candidate keys of R then you are right that R satisfies 3NF but not BCNF.

Related

Is it in 2NF or not?

R1(A, B, C, D) is a relation. It is specified that every attribute has only atomic values, and there is a set of dependencies (BD->C, C->A). It's clear to me that the relation is in the 1NF, but is it in the 2NF? I mean, BD is obviously a primary key, and we can conclude that BD->A, so all the attributes depend on the key. It isn't in the 3NF, for sure, because the 3NF doesn't accept transitive dependencies, but this shouldn't be a problem for the 2NF. I'm having doubts because some people told me that this couldn't be in 2NF. Is my reasoning correct? Is it in 2NF or not?
A relation schema is in 2NF if any non-prime (i.e. not belonging to a candidate key) attribute is fully functionally dependent on a candidate key.
This definition implies that, if a dependency X → A can be derived in which A is not a prime attribute and X is a proper subset of a candidate key, then such dependency violates the 2NF.
Since the (only) candidate key of this relation is BD, the attributes A and C are non-primes.
Since BD → C, is given, and BD → A can be derived, while neither B → A or D → A can be derived, then the relation is in 2NF.
Note that the 2NF has only historical interest, and the normalization process is discussed in many books (and formal algorithms are presented) only for BCNF, 3NF and higher normal forms.

Is this in 2NF?

I was working on some questions and found this relation R(A, B, C, D, E) with FDs {A -> B, B -> A, B -> E, AC -> D}.
I worked it out to find that it was in 3NF.
But the solution key for the question paper where I came across this said it was in 1NF. According to it, B -> E was a partial dependency, so R couldn't be in 2NF. Can anyone please explain to me the logic behind this?
A relation is in 2NF if any non-prime (i.e. not belonging to a candidate key) attribute is fully functionally dependent on a candidate key.
This definition implies that, if a dependency X → A can be derived in which A is not a prime attribute and X is a proper subset of a candidate key, then such dependency violates the 2NF.
This is the case of your example: the candidate keys are AC and BC, so D and E are non-prime attributes; the dependency B → E has a determinant which is not a candidate key, but only a subset of a key, so the relation is not in 2NF.
Finally note that the 2NF has only historical interest, and the normalization process is discussed in many books (and formal algorithms are presented) only for BCNF, 3NF and higher normal forms.

BCNF and 3NF property

I read a statement that " If a relation is in 3NF and does not contain any overlapping candidate key then it is definitely in BCNF"
Suppose we consider a relation R(A,B,C,D) with following functional dependencies:-
AB --> CD
C --> A
Here only candidate key is AB and the resulting relation is in 3NF and not in BCNF because C is not a super key.
So the above statement doesn't hold true.
Where am I going wrong ?
Your relation has overlapping candidate keys. While it doesn't appear on the left-hand side of the given functional dependencies, we can derive the fact that BC is a candidate key.
Starting with C -> A, we can use Armstrong's Axiom of Augmentation to determine that CB -> AB, and since it's known that AB is a candidate key, that means all other attributes are determined.

2nd Normal Form

I have a question:
Considering a relation R{A,B,C,D,E,F} with the next set of functional dependencies {ABC->DEF,D->E,ABC->A}. A, B and C are Prymary Keys.
Can you explain me why this is on 2nd NF? Thanks.
Can you explain me why this is on 2nd NF?
I'm not quite sure what "why this is on 2nd NF" means. (Typo?) But the relation R is not in 3NF, because there's a transitive dependency: ABC->D, and D->E. So relation R must be in either 1NF or 2NF.
Relation R is in 2NF if and only if
it's in 1NF, and
there are no partial key dependencies.
ABC->A might look like a partial key dependency, but it's not, because "A" is a prime attribute. (ABC->A is a trivial dependency, because A->A.) The non-prime attributes are {DEF}. None of those attributes are functionally dependent on only part of any candidate key (a more general way of saying they're not functionally dependent on part of this relation's primary key).
So relation R is in 2NF.

Boyce-Codd Normal Form explain

Accoring to Boyce-Codd Normal Form Definition,
Reln R with FDs F is in BCNF if, for all X -> A in F+
-A is subset of X (called a trivial FD), or
-X is a superkey for R.
“R is in BCNF if the only non-trivial FDs over R are key constraints.”
If R in BCNF, then every field of every tuple records information that
cannot be inferred using FDs alone.
What I dont understand is the above two statements about normal form,
Can someone give me an example?
Thanks!
Some Pre-requisite terms before I try to Explain:
• Non-key attribute: An attribute that is not part of any candidate key is known as non-key /non-prime attribute.
• Superkey: A set of attributes within a table whose values can be used to uniquely identify a tuple. A candidate key is a minimal set of attributes necessary to identify a tuple; this is also called a minimal superkey.
Now, BCNF is the advance version of 3NF, stricter than 3NF.
A table is in BCNF if every functional dependency X → Y, X is the super key of the table.
Consider a relation : R(A,B,C,D)
The dependencies are:
A->BCD
BC->AD
D->B
So, Candidate keys(or minimal super keys) are A and BC.
But in dependency: D->B, D is not a superkey.
Hence it violates BCNF form.
We can break this relation into R1 and R2 as:
R1(A,D,C) and R2(D,B) to get BCNF.

Resources