views:

62

answers:

4

If I add an id column to a table, and set id as the primary key, will the table be in 2NF?

A: 

Please read:

Stefan Gehrig
One of the points of SO is that when people google for an answer they find it here.
Will
You're right... But sometimes the answer to a question can just be a pointer to a place where the question is answered more throughoutly than it is possible or feasible here in SO.
Stefan Gehrig
True, so 1-4 are valid answers.
Will
Guilty ;-) I admit that I added the last one simply because I wanted to express how easy it would have been to find the relevant pages on the web.
Stefan Gehrig
A: 

No. Just because you have a primary key doesn't mean your schema is 2NF.

Jason Punyon
actually if there is only ONE primary key in table, it is automatically in 2NF, by definition non-key atribute must be dependent on one specific PART of key (which means, key must be consisted of at least to columns) for schema not to be in 2NF
ante.sabo
`@as`: an attribute should be dependent on a part of a **candidate key** to violate `2NF`. Even if the actual `PRIMARY KEY` contains only one column, the candidate key can contain more.
Quassnoi
+1  A: 

Using the formal logic, this statement is FALSE.

There are tables having id as a PRIMARY KEY not being in 2NF.

Quassnoi
A: 

You've already got the answer, but I'm going to call attention to the following, from the article on second normal form:

" A table for which there are no partial functional dependencies on the primary key is typically, but not always, in 2NF. In addition to the primary key, the table may contain other candidate keys; it is necessary to establish that no non-prime attributes have part-key dependencies on any of these candidate keys.

Multiple candidate keys occur in the following table: "

Adding an id field doesn't make any other cnadidate keys go away, even if you make id the primary key.

Walter Mitty