3

My informal representation of these are:

1NF: The table is divided so that no item will appear more than once.

2NF: ?

3NF: Values can only be determined by the primary key.

I cannot make sense of it from the excerpts I found online or in my book. How do I differentiate between 1NF and 2NF?

philipxy
  • 14,416
  • 5
  • 32
  • 77
Christopher Markieta
  • 5,258
  • 10
  • 42
  • 58

3 Answers3

3

A relation schema is in 2NF if every non-prime attribute is fully functionally dependent on every key.

Shaun
  • 43
  • 4
2

Wikipedia says:

A table is in 2NF if and only if, it is in 1NF and every non-prime attribute of the table is either dependent on the whole of a candidate key, or on another non prime attribute.

To explain the concept, let's use a table for a inventory of toys adapted from Head First SQL:

TOY_ID| STORE_ID| INVENTORY| STORE_ADDRESS

The primary key is composed by the attributes TOY_ID and STORE_ID. If we analize the non-prime attribute INVENTORY we see that in depends on TOY_ID and STORE_ID at the same time. That's cool.

But on the other side, the non-prime attribue STORE_ADDRESS only depends on the STORE_ID attribute (i.e it's not related to the primary key attribute TOY_ID). That's a clear violation of 2NF, so to complain to the 2NF our schema must be like this:

An Inventory table: TOY_ID| STORE_ID| INVENTORY

and an Store table: STORE_ID| STORE_ADDRESS

Carlos Gavidia-Calderon
  • 7,015
  • 9
  • 33
  • 59
0

Some columns are part of a key (primary or secondary). We'll call these prime attributes.

For second normal form we'll consider the non-prime attributes and see if they should be moved to another table. We might find that some attributes don't require the full key for us to be able to identify what value they hold for at least one candidate key. That is, there is a candidate key where we could still determine the value of that attribute given the candidate key even if the values in one column of that candidate key were erased.

Casebash
  • 107,788
  • 83
  • 240
  • 344