Welcome to dbForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

2nd Normal Form Question

 
   Database Forums (Home) -> Technology and Theory RSS
Next:  Tables Normalized?  
Author Message
gamehack

External


Since: Feb 08, 2008
Posts: 4



(Msg. 1) Posted: Fri Feb 08, 2008 8:21 am
Post subject: 2nd Normal Form Question
Archived from groups: comp>databases>theory (more info?)

Hi all,

I'm currently evaluating whether a relation is in 2NF. The relation is
defined as follows:
<Year | Winner Name | Winner Votes | Party | Home State> in the
context of an election. I've given a sample relation below.
1946 | MyName | 453 | MyParty | California
The primary key for this relation is 'Year'.

Now the question is whether this relation is in 2NF? What confuses me
is that some books say the following:
"Note that when a 1NF table has no composite candidate keys (candidate
keys consisting of more than one attribute), the table is
automatically in 2NF."

Now, let's evaluate the functional dependencies for this relation.
Year -> Winner Name
Year -> Winner Votes
Winner Name -> Party
Winner Name -> Home State

The definition for 2NF is as follows: "A 1NF table is in 2NF if and
only if, given any candidate key and any attribute that is not a
constituent of a candidate key, the non-key attribute depends upon the
whole of the candidate key rather than just a part of it." (Wikipedia)
which is consistent with the books I'm reading on databases.

Now as this relation doesn't have a composite primary key, it follows
that it is automatically in 2NF. But as we can see two non-prime
attributes (party & home state) are functionally dependent only a
subset of the primary key (the subset being the empty set). This must
imply that it is not in 2NF.

My question is, is this relation is 2NF or not?

Thanks,
g

 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Jan Hidders

External


Since: Nov 15, 2007
Posts: 145



(Msg. 2) Posted: Fri Feb 08, 2008 8:39 am
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 8 feb, 17:21, gamehack <gameh... DeleteThis @gmail.com> wrote:
> Hi all,
>
> I'm currently evaluating whether a relation is in 2NF. The relation is
> defined as follows:
> <Year | Winner Name | Winner Votes | Party | Home State> in the
> context of an election. I've given a sample relation below.
> 1946 | MyName | 453 | MyParty | California
> The primary key for this relation is 'Year'.
>
> Now the question is whether this relation is in 2NF? What confuses me
> is that some books say the following:
> "Note that when a 1NF table has no composite candidate keys (candidate
> keys consisting of more than one attribute), the table is
> automatically in 2NF."
>
> Now, let's evaluate the functional dependencies for this relation.
> Year -> Winner Name
> Year -> Winner Votes
> Winner Name -> Party
> Winner Name -> Home State
>
> The definition for 2NF is as follows: "A 1NF table is in 2NF if and
> only if, given any candidate key and any attribute that is not a
> constituent of a candidate key, the non-key attribute depends upon the
> whole of the candidate key rather than just a part of it." (Wikipedia)
> which is consistent with the books I'm reading on databases.
>
> Now as this relation doesn't have a composite primary key, it follows
> that it is automatically in 2NF.

A small note here: you should check if there is a composite
*candidate* key. It is in principle possible that the candidate key
you picked as primary keys is not composite while at the same time
there is another candidate that *is* composite, in which case the
relation could very well not be in 2NF.

> But as we can see two non-prime
> attributes (party & home state) are functionally dependent only a
> subset of the primary key (the subset being the empty set). This must
> imply that it is not in 2NF.

They are not dependent on the empty set, but on the set {"Winner
Name"}, which is clearly not a proper subset of a candidate key. So no
2NF violation there.

-- Jan Hidders

 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
gamehack

External


Since: Feb 08, 2008
Posts: 4



(Msg. 3) Posted: Fri Feb 08, 2008 8:55 am
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 8, 4:39 pm, Jan Hidders <hidd....DeleteThis@gmail.com> wrote:
> On 8 feb, 17:21, gamehack <gameh....DeleteThis@gmail.com> wrote:
>
> [snip]
>
> > But as we can see two non-prime
> > attributes (party & home state) are functionally dependent only a
> > subset of the primary key (the subset being the empty set). This must
> > imply that it is not in 2NF.
>
> They are not dependent on the empty set, but on the set {"Winner
> Name"}, which is clearly not a proper subset of a candidate key. So no
> 2NF violation there.
>

But isn't it a requirement for 2NF that all non-prime attribs (party &
home state) _have to be_ dependent on the whole of a candidate key (as
we only have 1 candidate key here which is the primary key) which is
not the case in this relation. Am I wrong?

> -- Jan Hidders

Thanks,
g
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Jan Hidders

External


Since: Nov 15, 2007
Posts: 145



(Msg. 4) Posted: Fri Feb 08, 2008 8:59 am
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 8 feb, 17:39, Bob Badour <bbad... RemoveThis @pei.sympatico.ca> wrote:
> gamehack wrote:
> > Hi all,
>
> > I'm currently evaluating whether a relation is in 2NF. The relation is
> > defined as follows:
> > <Year | Winner Name | Winner Votes | Party | Home State> in the
> > context of an election. I've given a sample relation below.
> > 1946 | MyName | 453 | MyParty | California
> > The primary key for this relation is 'Year'.
>
> > Now the question is whether this relation is in 2NF? What confuses me
> > is that some books say the following:
> > "Note that when a 1NF table has no composite candidate keys (candidate
> > keys consisting of more than one attribute), the table is
> > automatically in 2NF."
>
> I am not sure where you read that. It sounds like a typo or a mistake.
> Composite keys are important at the higher normal forms.

Of course, but all that it says is that if you have determined all the
candidate keys and they happen all to be not-composite then a 1NF is
always also in 2NF. I'm sure you agree that this is correct.

-- Jan Hidders
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Jan Hidders

External


Since: Nov 15, 2007
Posts: 145



(Msg. 5) Posted: Fri Feb 08, 2008 10:30 am
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 8 feb, 17:55, gamehack <gameh....TakeThisOut@gmail.com> wrote:
> On Feb 8, 4:39 pm, Jan Hidders <hidd....TakeThisOut@gmail.com> wrote:
>
> > On 8 feb, 17:21, gamehack <gameh....TakeThisOut@gmail.com> wrote:
>
> > [snip]
>
> > > But as we can see two non-prime
> > > attributes (party & home state) are functionally dependent only a
> > > subset of the primary key (the subset being the empty set). This must
> > > imply that it is not in 2NF.
>
> > They are not dependent on the empty set, but on the set {"Winner
> > Name"}, which is clearly not a proper subset of a candidate key. So no
> > 2NF violation there.
>
> But isn't it a requirement for 2NF that all non-prime attribs (party &
> home state) _have to be_ dependent on the whole of a candidate key (as
> we only have 1 candidate key here which is the primary key) which is
> not the case in this relation. Am I wrong?

Sorry, but yes, you are wrong. The attributes "Party" and "Home State"
are both dependent on "Year". Note that "dependent on" means here that
there is a functional dependency. It indeed holds that "Year"--
>"Party" and "Year"-->"Home State". This is not in contradiction with
the fact that it is also true that "Winner Name"-->"Party" and "Winner
Name"-->"Home State". An attribute can be dependent on several
different sets of attributes.

-- Jan Hidders
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Bob Badour

External


Since: Feb 14, 2006
Posts: 1559



(Msg. 6) Posted: Fri Feb 08, 2008 12:39 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

gamehack wrote:

> Hi all,
>
> I'm currently evaluating whether a relation is in 2NF. The relation is
> defined as follows:
> <Year | Winner Name | Winner Votes | Party | Home State> in the
> context of an election. I've given a sample relation below.
> 1946 | MyName | 453 | MyParty | California
> The primary key for this relation is 'Year'.
>
> Now the question is whether this relation is in 2NF? What confuses me
> is that some books say the following:
> "Note that when a 1NF table has no composite candidate keys (candidate
> keys consisting of more than one attribute), the table is
> automatically in 2NF."

I am not sure where you read that. It sounds like a typo or a mistake.
Composite keys are important at the higher normal forms.
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Bob Badour

External


Since: Feb 14, 2006
Posts: 1559



(Msg. 7) Posted: Fri Feb 08, 2008 1:41 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jan Hidders wrote:

> On 8 feb, 17:39, Bob Badour <bbad....TakeThisOut@pei.sympatico.ca> wrote:
>
>>gamehack wrote:
>>
>>>Hi all,
>>
>>>I'm currently evaluating whether a relation is in 2NF. The relation is
>>>defined as follows:
>>><Year | Winner Name | Winner Votes | Party | Home State> in the
>>>context of an election. I've given a sample relation below.
>>>1946 | MyName | 453 | MyParty | California
>>>The primary key for this relation is 'Year'.
>>
>>>Now the question is whether this relation is in 2NF? What confuses me
>>>is that some books say the following:
>>>"Note that when a 1NF table has no composite candidate keys (candidate
>>>keys consisting of more than one attribute), the table is
>>>automatically in 2NF."
>>
>>I am not sure where you read that. It sounds like a typo or a mistake.
>>Composite keys are important at the higher normal forms.
>
> Of course, but all that it says is that if you have determined all the
> candidate keys and they happen all to be not-composite then a 1NF is
> always also in 2NF. I'm sure you agree that this is correct.
>
> -- Jan Hidders

What can I say? I was tired. Your answer was so much better than mine I
cancelled mine almost immediately.

Sigh. Alas, you have immortalized it.
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Jan Hidders

External


Since: Nov 15, 2007
Posts: 145



(Msg. 8) Posted: Fri Feb 08, 2008 2:26 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 8 feb, 21:08, "David Portas"
<REMOVE_BEFORE_REPLYING_dpor... RemoveThis @acm.org> wrote:
> "Jan Hidders" <hidd... RemoveThis @gmail.com> wrote in message
>
> news:3c0c26bc-65d3-44b8-bf91-ea32c0b4a917@i7g2000prf.googlegroups.com...
>
>
>
> > On 8 feb, 17:39, Bob Badour <bbad... RemoveThis @pei.sympatico.ca> wrote:
> >> gamehack wrote:
> >> > Hi all,
>
> >> > I'm currently evaluating whether a relation is in 2NF. The relation is
> >> > defined as follows:
> >> > <Year | Winner Name | Winner Votes | Party | Home State> in the
> >> > context of an election. I've given a sample relation below.
> >> > 1946 | MyName | 453 | MyParty | California
> >> > The primary key for this relation is 'Year'.
>
> >> > Now the question is whether this relation is in 2NF? What confuses me
> >> > is that some books say the following:
> >> > "Note that when a 1NF table has no composite candidate keys (candidate
> >> > keys consisting of more than one attribute), the table is
> >> > automatically in 2NF."
>
> >> I am not sure where you read that. It sounds like a typo or a mistake.
> >> Composite keys are important at the higher normal forms.
>
> > Of course, but all that it says is that if you have determined all the
> > candidate keys and they happen all to be not-composite then a 1NF is
> > always also in 2NF. I'm sure you agree that this is correct.
>
> Here's a counter example. PatientId is the candidate key but the relation is
> not in 2NF. This is an unusual case but I don't think it should be ignored.

Yeah, yeah, yeah. I know, I know. I wanted to give Brian Selzer the
pleasure of correcting me on this twice, but you beat him to it. Smile

-- Jan Hidders
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
David Portas

External


Since: Nov 11, 2003
Posts: 678



(Msg. 9) Posted: Fri Feb 08, 2008 5:03 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Jan Hidders" <hidders RemoveThis @gmail.com> wrote in message
news:3c0c26bc-65d3-44b8-bf91-ea32c0b4a917@i7g2000prf.googlegroups.com...
> On 8 feb, 17:39, Bob Badour <bbad... RemoveThis @pei.sympatico.ca> wrote:
>> gamehack wrote:
>> > Hi all,
>>
>> > I'm currently evaluating whether a relation is in 2NF. The relation is
>> > defined as follows:
>> > <Year | Winner Name | Winner Votes | Party | Home State> in the
>> > context of an election. I've given a sample relation below.
>> > 1946 | MyName | 453 | MyParty | California
>> > The primary key for this relation is 'Year'.
>>
>> > Now the question is whether this relation is in 2NF? What confuses me
>> > is that some books say the following:
>> > "Note that when a 1NF table has no composite candidate keys (candidate
>> > keys consisting of more than one attribute), the table is
>> > automatically in 2NF."
>>
>> I am not sure where you read that. It sounds like a typo or a mistake.
>> Composite keys are important at the higher normal forms.
>
> Of course, but all that it says is that if you have determined all the
> candidate keys and they happen all to be not-composite then a 1NF is
> always also in 2NF. I'm sure you agree that this is correct.
>
> -- Jan Hidders

Here's a counter example. PatientId is the candidate key but the relation is
not in 2NF. This is an unusual case but I don't think it should be ignored.

Pregnancies {PatientId, Gender, DueDate}

FDs:
{PatientId} -> {DueDate}
{} -> {Gender}

--
David Portas
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
paul c

External


Since: Apr 22, 2005
Posts: 867



(Msg. 10) Posted: Fri Feb 08, 2008 5:03 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

David Portas wrote:
....
> Here's a counter example. PatientId is the candidate key but the relation is
> not in 2NF. This is an unusual case but I don't think it should be ignored.
>
> Pregnancies {PatientId, Gender, DueDate}
>
> FDs:
> {PatientId} -> {DueDate}
> {} -> {Gender}
>

If you have {} -> {Gender} don't you also have {PatiendId} -> {Gender,
DueDate} ?
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
David Portas

External


Since: Nov 11, 2003
Posts: 678



(Msg. 11) Posted: Fri Feb 08, 2008 8:04 pm
Post subject: Re: 2nd Normal Form Question [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"paul c" <toledobythesea.RemoveThis@oohay.ac> wrote in message
news:Kp3rj.6645$Ly.6410@pd7urf1no...
> David Portas wrote:
> ...
>> Here's a counter example. PatientId is the candidate key but the relation
>> is not in 2NF. This is an unusual case but I don't think it should be
>> ignored.
>>
>> Pregnancies {PatientId, Gender, DueDate}
>>
>> FDs:
>> {PatientId} -> {DueDate}
>> {} -> {Gender}
>>
>
> If you have {} -> {Gender} don't you also have {PatiendId} -> {Gender,
> DueDate} ?

Yes.

--
David Portas
 >> Stay informed about: 2nd Normal Form Question 
Back to top
Login to vote
Display posts from previous:   
   Database Forums (Home) -> Technology and Theory All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]