Is it in 2NF or not? - database

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.

Related

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.

Condition when BCNF and 3NF are equivalent

Statement - "If a table contains only one candidate key, the 3NF and the BCNF are equivalent."In the below image, relation is 3nf but not bcnf. But it has only one candidate key ie AB, so according to above statement it should be either both (3nf, bcnf) or nothing. Can somebody explain what i am missing here ?
"If a table contains only one candidate key, the 3NF and the BCNF are equivalent."
The second half, "the 3NF and the BCNF are equivalent", doesn't mean anything. What do you think it means? The normal forms are different things. BCNF requires a more restrictive condition than 3NF. So when a relation is in BCNF it has to also be in 3NF. So a relation can be in both normal forms at the same time.
Presumably the quote is trying to say that, "if a table contains only one candidate key", then if it is in 3NF then it is also in BCNF. And this is correct, because a table that is in 3NF but not in BCNF has to have overlapping CKs (candidate keys). Here the CKs, ie sets of attributes that determine all attrbutes that don't contain a smaller such set, are AB & AC. Which overlap. This table is in 3NF, but it's not in BCNF.
(Note that the FDs that hold are not just ones you are explicitly told hold but all the ones that must hold when they do per Armstrong's axioms.)
In,simple words the given words can be written as
AB->C
AB->D
C->B
In above relations,A,B,C are prime attributes and D is non-prime attributes
Here,AB and AC are minimal Super keys
Condition for 3NF and BCNF
X->Y
For BCNF,X should be Super key whether Y is prime or non-prime attribute
For 3NF,X should be Super key only when Y is non-prime,otherwise it is a optional one
BCNF and 3NF are equivalent when there are no **non-prime** attributes
Hope,it helps.

Normalization 3NF and BCNF

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.

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