Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

Second Normal Form Expand / Collapse
Author
Message
Posted Wednesday, July 13, 2011 9:20 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 7:29 PM
Points: 8,562, Visits: 9,063
Comments posted to this topic are about the item Second Normal Form

Tom
Post #1141462
Posted Thursday, July 14, 2011 1:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 30, 2012 1:56 AM
Points: 1, Visits: 14
Great explanation - however in this case I think you would agree it would be prudent to strre the Rate_Applying and Years_Applying in the Current Assignment table to prevent them being implicitly changed retrospectively when they were changed in the PayGradeDetails table. This appears to be a violation but is essential to retain correct data over time.
Post #1141509
Posted Thursday, July 14, 2011 1:48 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 6:58 AM
Points: 2,036, Visits: 1,377
I must admit that I got a bit lost by the description in your first paragraph, but the example that you gave made it clear and confirmed to me that 2NF was what I thought it was - phew!

Thanks very much, looking forward to 3NF and beyond...
Post #1141518
Posted Thursday, July 14, 2011 2:38 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 7:29 PM
Points: 8,562, Visits: 9,063
Lempster (7/14/2011)
I must admit that I got a bit lost by the description in your first paragraph, but the example that you gave made it clear and confirmed to me that 2NF was what I thought it was - phew!

Thanks very much, looking forward to 3NF and beyond...


Thanks for that.

I should have used a betterl description (the form of words I used was pretty poor). Something like "If X is a set of prime attributes and A is a non-prime attribute and the value of A is determined by the values of X then X contains the whole of at least one candidate key". Your comment made me read that first paragraph again and I found it confusing me this time and I'm not sure what I wrote is actually right (it looks a bit too much like a definition of 3NF).

EDIT: I provided Steve with new text for the definition and it is now incorporated in teh article. Thanks' Lemperer, for helping make this a better article.


Tom
Post #1141540
Posted Thursday, July 14, 2011 2:41 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Yesterday @ 10:21 AM
Points: 440, Visits: 3,278
The author's point about A being "fixed by" the values of X presumably means a functional dependency of the form X->A. Functional dependencies are the basis of 2NF. It 's important to remember that the concept of functional dependency was developed without regard for nulls and it is an assumption of 2NF (and 3NF, BCNF, etc) that relations consist only of values and not nulls.

The definition of a candidate key as a set of columns that "could reasonably be used as the primary key" is a bit strange. A candidate key is quite precisely a minimal superkey. There is no difference at all between a candidate key and a primary key (or even "the" primary key) so I'm not sure what is meant by a "reasonable choice" in that context. It's a pity the explanation of candidate keys isn't spelt out more clearly because it is very often a point of confusion for some people.





David
Post #1141542
Posted Thursday, July 14, 2011 2:49 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 7:29 PM
Points: 8,562, Visits: 9,063
martin-1049293 (7/14/2011)
Great explanation - however in this case I think you would agree it would be prudent to strre the Rate_Applying and Years_Applying in the Current Assignment table to prevent them being implicitly changed retrospectively when they were changed in the PayGradeDetails table. This appears to be a violation but is essential to retain correct data over time.

I think I would keep the rate history for each person in the PayGradeDetails table, and assignment history in a third table, if there was any question of trying to reconstruct historical charges. But the ability to do historical reconstructions is non-trivial, and doing it safely requires extra normalisation.

Of course concern for time-dependent data is what led Chris Date to invent his version of 6NF, and maybe one day there will be an SQL Server Central article on that (if there is it won't be written by me - I have no practical experience of using 6NF, so it's just theory to me, and I don't believe people should write articles on parts of normalisation that they have no practical knowledge of).


Tom
Post #1141549
Posted Thursday, July 14, 2011 4:52 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:03 AM
Points: 13,290, Visits: 10,159
Nice article, thanks Tom.
Looking forward to the rest of the series.




How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at LessThanDot.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1141611
Posted Thursday, July 14, 2011 5:05 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Yesterday @ 7:29 PM
Points: 8,562, Visits: 9,063
David Portas (7/14/2011)
The author's point about A being "fixed by" the values of X presumably means a functional dependency of the form X->A. Functional dependencies are the basis of 2NF.

That's sort of true. But Occam's razor is a useful tool when trying to present things in a simple manner, and what a functional dependency is all about is that some values are fixed by some other values; at least I hope that's what you mean by a functional dependency (it's what every academic paper I've read that contained the term used it for).

If I were intending to write about formal theory rather that something useful for practical database people, I would of course treat FDs as a special case of MVFDs (an FD is an MVFD where the range value set is a singleton) and then for 2NF (and 3NF too) discuss only a special case of FDs (where the range domain is a 1-tuple). I don't think that would be much use to most of the SQLServerCentral audience, who are practitioners not theorists.

It 's important to remember that the concept of functional dependency was developed without regard for nulls and it is an assumption of 2NF (and 3NF, BCNF, etc) that relations consist only of values and not nulls.

It's important to remember that Codd and Heath were discussing NULL (not two different NULLs, just one) way back when they were preparing their early papers on normalisation, so that it is extremely unlikely that NULLs weren't considered at all. They didn't work out the effect of nulls on normalisation at that point - which is why Codd later wrote that their introduction had meant that the normalisation had had to be revisited - but certainly there are no grounds now, three decades after NULLs were first proposed, for claiming that relational theory has no room for them or that 2NF, 3NF, BCNF and etc (presumably "etc" means EKNF, 4NF, various 5NFs, DKNF and Date's 6NF) exclude them (for example, if 5NF had been intended to exclude NULL, the paper introducing it would have said so - its author, Ron Fagin, was working with Codd and had just reviewed Codd's RM-T and "...Capture more Meaning" papers for him, so he certainly knew all about NULLs. For 6NF, I imagine Date did intend that NULL be forbidden - but that's the only one I believe does exclude NULL.

The definition of a candidate key as a set of columns that "could reasonably be used as the primary key" is a bit strange. A candidate key is quite precisely a minimal superkey. There is no difference at all between a candidate key and a primary key (or even "the" primary key) so I'm not sure what is meant by a "reasonable choice" in that context. It's a pity the explanation of candidate keys isn't spelt out more clearly because it is very often a point of confusion for some people.

Just a fortnight ago one of you anti-NULL purists was claiming that there was no such term as "primary key" in relational theory, only in SQL! (Complete nonsense, as you will agree.)

I think most people will understand that I used "the primary key" in the sense used in the paper which introduced the relational model to the world - it is a primary key that has been chosen to be "the" primary key as opposed to just "a" primary key and it is a perfectly sensible description of a candidate key to say that it is something that can be so chosen, both because that's why the word "candidate" is there - a candidate is something that can be chosen (whether by fate, by a schema designer, or otherwise) and since the term "candidate key" was in fact introduced as a replacement for "primary key" rather later. The concept of superkey is of course completely superfluous.


Tom
Post #1141621
Posted Thursday, July 14, 2011 5:20 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Saturday, May 4, 2013 5:21 AM
Points: 52, Visits: 117
Tom,

Great article...although I too was a little lost by the first paragraph but your example made it clear.

I would also add effectiveStartDate and effectiveEndDate fields to the PayGrade_Details table so that you could see that Charlie Fixit spent 3 years at paygrade 12 and then got bumped up to paygrade 13 and when it happened. Then I would just grab the paygrade record whose start date/end date falls within the proper date range that I need...I'm not sure if that is the correct way to do it or what NF that is but that's the way I've been doing it

That way I can pull historical reports...I guess I could also use a historical or archive paygrade table and move the old records into that table when they are changed...but I'm not sure which way is the recognized "proper" way to do it.

But I digress...Thanks, George
Post #1141628
Posted Thursday, July 14, 2011 7:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, April 7, 2014 1:00 AM
Points: 2, Visits: 35
Great Post....
Post #1141772
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse