when a 1NF table has no composite candidate keys is it in 2NF?
Asked Answered
E

3

4

Is it safe to say, when a 1NF table has no composite candidate keys (primary keys consisting of more than one column), the table is automatically in 2NF?

Can a table voilate 2NF, when it has only one column in its primary key?

Eucken answered 7/6, 2012 at 16:58 Comment(2)
possible duplicate of Is it true that a database is 2NF by default if the table only has 1 primary key?Ulani
Having "only one column in its primary key" doesn't mean the same as "no composite candidate keys". All the candidate keys are equally important. See the difference?Zobkiw
Z
2

A relvar R, is in 2NF as long as there is no non-trivial FD, A->B, satisfied by R where B is nonprime and where A is a proper subset of some candidate key of R.

You first have to consider all the candidate keys. If it is the case that all the candidate keys happen to be single attribute keys then the only possible proper subset of any of those keys is {} (the empty set). Dependencies on the empty set are unlikely to arise unintentionally because they are usually obvious and unnecessary. Such dependencies are perfectly possible however, even where there is only a single, simple key.

Zobkiw answered 7/6, 2012 at 21:24 Comment(1)
You could add that {} -> X when/iff X has the same value in every row. And that {} is the (sole) CK when/iff a table has at most one row.Embower
H
-1

Yes, the table can violate 2NF when it has only one column in its primary key. The basic idea of 2NF is to have all the fields of your table directly dependent/related to the primary key. The example that @A B gives explains the same point.

Hierarch answered 7/6, 2012 at 18:1 Comment(1)
I strongly feel that someone has to update 2NF wiki page where it states "when a 1NF table has no composite candidate keys (candidate keys consisting of more than one attribute), the table is automatically in 2NF"Eucken
D
-2

The key to having a individual table in 2NF is to "Remove subsets of data that apply to multiple rows of a table and place them in separate tables."

If a table has multiple rows that repeat information, then that information should be moved to another table and a relationship established though the use of foreign keys.

http://databases.about.com/od/specificproducts/a/2nf.htm

Dioptric answered 7/6, 2012 at 17:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.