Normal Forms

Tables need to follow a set of numbered rules known as “normal form.” (It's “normal” in the sense of “normalized” or conforming to a standard). First normal form says that all attributes must be atomic. That means there can be no lists of items in an attribute. You can't have an attribute that is “contents of a shopping cart,” because that could contain several items. Atomic means “only one, and it cannot be subdivided any further.”

Second normal norm

Second normal form says that it is in first normal form (atomic) and every non-key attribute depends fully on the key. The Person table has non-key attributes of “age” and “lives in” and both of these are completely dependent on the person we are identifying by the “name” attribute. However, if we added a column to the table to hold, say, the land of origin of the band, we would be breaking second normal form. A band's land does not depend on the primary key (the person name).

Third normal norm

A table is in third normal form if it is in second normal form and all non-key columns are mutually independent. In the Person table, the non-key columns are “age” and “lives in.” These are mutually independent because they can change without affecting the other. If we were to add a column to store “is a minor” data in Person, the table would no longer be in third normal form. Whether or not someone is a minor depends on their age, which is another attribute in the Person relation.

Add tables to taste

If you find your table designs break a normal form rule, you can always fix it by adding an extra table as we did above to resolve a many-to-many relationship. You may need to move columns from one table to another or to add an identification number to a couple of tables to relate records between them. Raw data can always be put into third normal form. There are additional normal forms beyond this, but third normal form is enough for most purposes. If you make sure all your tables are in third normal form, you will be able to use relational database operations on them and get the right results. A database that has been designed to be in third normal form is said to be “normalized.” There's a great memory aid for the form in which you want your tables: the data in a table has to depend on the key, the whole key, and nothing but the key.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.37.191