Re: 2NF There are two Definitions which is right
Date: Fri, 22 Jul 2005 07:59:44 GMT
Message-ID: <42E0A76A.9080204_at_earthlink.net>
Jens Haase wrote:
> Jonathan Leffler wrote:
>> Jens Haase wrote: >>> I found two definitions for 2NF: >>> >>> 1: A relation R(A,F) is in 2NF, when every attribute not >>> belonging to the primary key of R is fully functionally dependent >>> on the primary key of R >> >> Can you give a hint as to the significance of the parenthesized >> "(A,F)"; neither A nor F is referenced in the definition quoted. I >> don't think it alters the answer, but I'm curious. (The comma after >> 2NF should be omitted too.)
> R(A,F) means a Relation R with attributes A and functional
> dependencies F
Fine - as expected, this makes no difference to the answer.
>>> 2: A relation schema R is in 2NF if every nonprime attribute A in >>> R is fully functionally dependent on the primary key of R >> >> Assuming 'nonprime attributes' are the attributes that do not >> belong to the primary key, it seems to me that the two definitions >> are the same.
>
> This definition (the second) is from Elmasri/Navate Fundamentals of
> Database Systems Second Edition Page 411.
> On Page 408 in the same book the authors state:
>
> An attribute of relation schema R is called a prime attribute of R if
> it is a member of some candidate key of R. An attribute is called
> nonprime if it is not a prime attribute—that is, if it is not a
> member of any candidate key.
Superkeys are not relevant to most of this discussion, I think.
> If a relation schema has more than one key, each is called a
> candidate key. One of the candidate keys is arbitrarily designated to
> be the primary key, and the others are called secondary keys
> According to this definition there is a difference between the two
> definitions.
Just about - and the second is the better definition, but not perfect.
>>> According to the first definition the following schema would not >>> be in 2NF, according to the second it would be: >>> >>> R = (A,B,C,D) >>> >>> with: >>> A->D >>> AB->C >>> C->D >>> D->A >>> >>> According to the first definition when the primary key is AB, then >>> A->D violates 2NF, because D is not part of the primary key. >> >> I agree that AB is the primary key - or at least a valid primary key.
>> A->D itself cannot violate 2NF; it is a functional dependency, and >> relation schemas are what satisfy or violate 2NF. And the reasoning >> the that D is not part of the primary key is bogus too.
> A->D tells us that D is only dependant on A and so only on a part of the
> primary key.
Yes. (And this is a change in stance from yesterday's post.)
>> As I see it, AB->C and C->D implies that AB->D so the primary key >> determines both C and D, as required. Granted, it is neither in 3NF >> nor BCNF - the mnemonic is "the key, the whole key, and nothing but >> the key", and the functional dependency A->D means that 'the whole >> key' part of the rule is violated. (The C->D part is also problematic, >> but doesn't cause the relation schema to violate 2NF.)
By implication, yesterday I said "but R is in 2NF"; today, I think that was wrong.
> According to Ullmans definition of 3NF:
> A relation R is in third normal form in whenever X -> A holds in R
> and A is not in X, then either X is a candidate key for R, or A is
> [a] prime attribute
>
> it is in 3NF since:
>
> A->D holds 3NF since D is prime attribute
> AB->C holds 3NF because AB is candidate key
> C->D holds 3NF because D is prime attribute
> D->A holds 3NF because A is prime attribute
is implied by the candidate keys of R. ]
>>> According to the second definition R is in 2NF because the >>> candidate keys are AB, BC, BD and since that, every attribute is >>> prime attribute, so there is no violation of 2NF. >> >> Now you introduce a term - candidate key - not mentioned in the >> definitions of 2NF that we're dissecting. I would dispute that BC >> is a candidate key anyway; likewise BD. Given a relation schema R { >> A, B, C, D, E } with candidate key AB, by definition, AB->CDE (and, >> by the rules of trivial functional dependencies (or FDs), >> AB->ABCDE). That is, a candidate key functionally determines every >> attribute in the relation schema. How do you apply Armstrong's >> Axioms to the relation schema and list of FDs to deduce that >> BC->AD?
>
> Well since C->D and D->A with Armstrongs 3. Axiom we get C->A that
> gives us C->DA and with Armstrongs 2. Axiom we get BC->BDA, so BC is
> a candidate key.
>
> since D->A with Armstrongs 2. Axiom we get BD->AB and with AB->C with
> Armstrongs 3. Axiom we get BD->C so we get BD->ABC, so BD also is a
> candidate key.
> The [w]hole problem i am facing, is that the first definition is from
> a german script and the second is from an english book
> (Elmasri/Navathe) and my thoug[h]t is, that there is a confusion
> between "Primary key" and "prime".
-- Jonathan Leffler #include <disclaimer.h> Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/Received on Fri Jul 22 2005 - 09:59:44 CEST