A table is in first normal form if each attributes contain only one value. All attributes are dependant on the primary key. It is also known as removing repeating groups of data.

 

This is known as eliminating repeating groups of information. First of all we must flatten a database. Consider the following example.

 

CustomerId

OrderNumber

Name

Product

ProductID

Supplier

CU1

OR1, OR2,OR3

Bob

Frisbee, T-Shirt, Frisbee

P20,P43,P20

Argos

CU2

OR4

Sally

Frisbee

P20

Argos

CU3

OR5,OR6

Fred

A4 paper, Envelopes

P2, P4

Partners

This is not normalised and is said to be in UNF (un-normalised form). First of all we must identify a primary key. As we are dealing with customer orders we shall choose the order number to be the primary key. OrderNumber, Product and productID all have multiple values stored in them. As such they are breaking the test for 1-NF. It says that each attribute should contain only one value. As such we should perform a flattening operation. That is ensure that each attribute only contains one value. This would result in the following table.

 

CustomerId

OrderNumber

Name

Product

ProductID

Supplier

CU1

OR1

Bob

Frisbee

P20

Argos

CU1

OR2

Bob

T-Shirt

P43

Argos

CU2

OR3

Bob

Frisbee

P20

Argos

CU2

OR4

Sally

Frisbee

P20

Argos

CU3

OR5

Fred

A4 paper

P2

Partners

CU3

OR6

Fred

Envelopes

P4

Partners

There is still a lot of repeated data in this table. We now need to look at what the primary key is. Order number would be a good candidate as each order will have its own unique number. As such we need to look to see if all of the data depends on the primary key. Customers to not depend on the primary key and as such should not be stored in the same table. As we can clearly see that customers names are repeated multiple times. There is a clear one to many relationship between a customer and their order.

In order to put the table into 1-NF we need to pull the customer information out. This will then be placed into a separate table. Below is the two new tables.

Customer Table

CustomerId

Name

CU1

Bob

CU2

Bob

CU3

Fred

Order Table

CustomerId

OrderNumber

Product

ProductID

Supplier

CU1

OR1

Frisbee

P20

Argos

CU1

OR2

T-Shirt

P43

Argos

CU2

OR3

Frisbee

P20

Argos

CU2

OR4

Frisbee

P20

Argos

CU3

OR5

A4 paper

P2

Partners

CU3

OR6

Envelopes

P4

Partners

You may wonder why the customerID has been duplicated in both tables. Surely this goes against the idea of repeated data? The simple answer is that there must exist a link between customer and their order. We call this link the foreign key. To find out who owns a single order we use the customerID from the order table and match it to a single row in the customer table. We can then read the correct customer name off the customer table. OR5 in the order table has got a customerID of CU3. Looking CU3 up in the customer table we find out that CU3 is bob.

We can write the above in the form of short hand. Each table is listed with its attributes held in brackets, comma delimited. The primary key is always shown as being underlined.

Customer( CustomerID, Name)

Order( CustomerID, OrderNumber, Product, ProductID, Supplier, SupplierID)