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

What normal form would this be considered? 2NF or 3NF? Expand / Collapse
Author
Message
Posted Sunday, June 02, 2013 6:16 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, December 28, 2013 5:45 PM
Points: 94, Visits: 96
Lets say I have a table with four columns named PersonID1, PersonID2, JobTitle, and PreviousJobTitle. There is a composite primary key on PersonID1 and PersonID2. In all instances PreviousJobTitle can be derived on JobTitle. Let's say PreviousJobTitle is dependent on JobTitle but not the primary key. Please assume PreviousJobTitle is 0% dependent on the primary key and 100% dependent on a non-key attribute. JobTitle is 100% dependent on the composite primary key.

What normal form is such a table in?
Post #1459044
Posted Sunday, June 02, 2013 8:28 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:22 PM
Points: 36,016, Visits: 30,308
Golfer22 (6/2/2013)
Lets say I have a table with four columns named PersonID1, PersonID2, JobTitle, and PreviousJobTitle. There is a composite primary key on PersonID1 and PersonID2. In all instances PreviousJobTitle can be derived on JobTitle. Let's say PreviousJobTitle is dependent on JobTitle but not the primary key. Please assume PreviousJobTitle is 0% dependent on the primary key and 100% dependent on a non-key attribute. JobTitle is 100% dependent on the composite primary key.

What normal form is such a table in?


I'd say that it doesn't meet any of the requirements for any level of normal form.


--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

"Change is inevitable. Change for the better is not." -- 04 August 2013
(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1459052
Posted Sunday, June 02, 2013 9:02 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 7:47 AM
Points: 8,296, Visits: 8,750
Golfer22 (6/2/2013)
Lets say I have a table with four columns named PersonID1, PersonID2, JobTitle, and PreviousJobTitle. There is a composite primary key on PersonID1 and PersonID2. In all instances PreviousJobTitle can be derived on JobTitle. Let's say PreviousJobTitle is dependent on JobTitle but not the primary key. Please assume PreviousJobTitle is 0% dependent on the primary key and 100% dependent on a non-key attribute. JobTitle is 100% dependent on the composite primary key.

What normal form is such a table in?

The description you give is a bit self-contradictory, but if it means what I think it means the table is both in first normal form and in second normal form but not third normal form or in any higher normal form. Although PreviousJobTitle is determined by the primary key and hence is 100% (not 0%, as you suggest) dependent on it, it can also be derived from JobTitle without considering the primary key, so there is a functional dependency on something that doesn't include all of a candidate key. As JobTitle isn't a prime attribute (unless there are functional dependencies you haven't told us about) this doesn't mean it's not in second normal form (we don't have a dependency on a subset of a candidate key), but it certainly means it isn't in third normal form.

See Second Normal Form and Third Normal Form].

This is a nice example of how bizarre an idea 2NF is when approached described in terms of keys and dependencies instead of in terms of what it achieves in preventing errors and unfortunately the description in terms of what errors it prevents varies from case to case, so the apparently bizarre definition is the useful one.


Tom
Post #1459056
Posted Saturday, June 08, 2013 4:29 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, December 28, 2013 5:45 PM
Points: 94, Visits: 96
PreviousJobTitle is 0% dependent on the primary key in my example. Was that not clear?

If the table were changed and PreviousJobTitle were dependent on PersonID2 (instead of JobTitle) would it be in 1NF?

If PreviousJobTitle were dependent on PersonID1 and PersonID2 (and not on JobTitle), would the table be in 3NF?

JobTitle could be a candidate key in a different table. I guess the normal form only looks at the scope of one table.

Please confirm the following:
If a non-key attribute is dependent on one of 1,000 columns (when the primary key is composed of 1,000 columns), the table is in 1NF or lower. But if the non-key attributes are all dependent on either the primary key (all 1,000 columns) except that one non-key attribute is dependent another non-key attribute, the table is in 2NF. If the non-key attribute that is dependent on a different non-key attribute is removed from the table, then the table is in 3NF.
Post #1461313
Posted Saturday, June 08, 2013 5:58 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 7:47 AM
Points: 8,296, Visits: 8,750
Golfer22 (6/8/2013)
PreviousJobTitle is 0% dependent on the primary key in my example. Was that not clear?

No, it was clear that you were misusing the term "dependent" to exclude "transitively dependent", and that is not the usage of "dependent" in normalisation. You explicitly said that PreviousJobTitle was dependent on JobTitle and that JobTitle is dependent on the primary key, so in the ordinary terminology of normalisation PreviousJobTitle is dependent on the primary key; because that is a transitive dependency and JobTitle (the thing in the middle) is not a prime attribute the table is not in 3NF. But everything is dependent (directly or indirectly) on the primary key so the table is in 1NF and nothing is dependent on just a (proper) subset of any candidate key so the table is in 2NF.

If the table were changed and PreviousJobTitle were dependent on PersonID2 (instead of JobTitle) would it be in 1NF?

Yes, because once you have the primary key you can derive everything from the dependency relationships. But it now would not be in 2NF, because something would be dependent on a proper subset of the primary key (and hence not in any normal form higher than 2NF).

If PreviousJobTitle were dependent on PersonID1 and PersonID2 (and not on JobTitle), would the table be in 3NF?

Yes, because everything (except the components of the primary key) is now dependent on the whole primary key and nothing is dependent on anything other than the primary key. is now directly dependent

JobTitle could be a candidate key in a different table. I guess the normal form only looks at the scope of one table.

Yes, that's right. But having each table in normal form isn't actually the whole of normal form: having the domain constraints (check constraints, not null constraints), primary key constraints, uniqueness constraints, and foreign key constraints explicitly stated in the schema definition is part of normalisation too.

Please confirm the following:
If a non-key attribute is dependent on one of 1,000 columns (when the primary key is composed of 1,000 columns), the table is in 1NF or lower. But if the non-key attributes are all dependent on either the primary key (all 1,000 columns) except that one non-key attribute is dependent another non-key attribute, the table is in 2NF. If the non-key attribute that is dependent on a different non-key attribute is removed from the table, then the table is in 3NF.

Yes, that's correct (given that in the 2NF case your "another key attribute" is dependent on all 1000 primary key columns).


Tom
Post #1461319
Posted Sunday, June 09, 2013 2:14 PM
SSC-Addicted

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

Group: General Forum Members
Last Login: Today @ 2:00 PM
Points: 429, Visits: 3,097
Golfer22 (6/8/2013)
Please confirm the following:
If a non-key attribute is dependent on one of 1,000 columns (when the primary key is composed of 1,000 columns), the table is in 1NF or lower. But if the non-key attributes are all dependent on either the primary key (all 1,000 columns) except that one non-key attribute is dependent another non-key attribute, the table is in 2NF. If the non-key attribute that is dependent on a different non-key attribute is removed from the table, then the table is in 3NF.

That's correct as far as it goes but it's important to remember that 2NF is violated if a proper subset of any candidate key happens to be a determinant. Being fully dependent on just one key (a primary key) is not necessarily sufficient if other keys are present. 3NF and later normal forms are concerned equally with all candidate keys of relations and not just any one key per relation.

It is sometimes assumed that a relation automatically satisfies 2NF if it has no composite keys. That isn't invariably so. Violations of 2NF in relations with only simple keys (single attribute keys) occur when the empty set of attributes is a determinant. That's a fairly unusual case and the apparent rarity of such situations perhaps explains why dependencies on the empty set don't often get mentioned in textbooks and get ignored in informal explanations of normal forms.


David
Post #1461352
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse