 |
|
Oracle Tips by Burleson |
Basic SQL structure
Now that we see the basics of SQL, let’s
take a look at the normalization steps, so that we can understand
table structure.
Un-normalized Form (0NF)
Essentially, an un-normalized relation is a
relation that contains repeating values. An un-normalized relation
can also contain relations nested within other relations, as well as
all kinds of transitive dependencies. Sometimes un-normalized
relations are signified by 0NF, but an un-normalized relation is not
to be confused with a denormalized relation.
The un-normalized relation is any relation
in its raw state, and they commonly contain repeating vales and
other characteristics that are not found in denormalized relations.
The process of denormalization is a very deliberate attempt to
introduce controlled redundant items into an already normalized
form.
First Normal Form (1NF)
In essence, any relation is in first normal
form if it does not contain any repeating values. Here, we have
taken our relations with repeating values and moved them to separate
relations. When the new relations are created, we carry the primary
key of the original relation into the new relation.
We start by creating a primary key to
uniquely identify each row in the table. Any repeating data is
moved to a new table. Finally, create a key for each of the rows of
the new table and a reference to that key in the original table.
This is like what we did with the FRIENDS and ADDRESS tables above.
First normal form removes repeating data to separate tables. Each
of the new tables may have repeating data that should be moved to
another new table. This process continues until there is no longer
redundant data.
Second Normal Form (2NF)
For second normal form, you must start in
first normal form. Then, each column in a table must be dependent
on the key for that table, or it should be move to a new table.
The purpose of the second normal form (2NF)
test is to check for partial key dependencies. Partial key
dependencies are created when we break off an un-normalized relation
into first normal form by carrying the key thereby creating a
concatenated key with several data items. The formal definition of
second normal form is as follows:
A relation is in second normal form if and
only if the relation is in first normal form and each non-key
attribute is fully functionally dependent on the entire concatenated
key.
The above book excerpt is from:
Easy Oracle
SQL
Get Started
Fast writing SQL Reports with SQL*Plus
ISBN 0-9727513-7-8
Col. John Garmany
http://www.rampant-books.com/book_2005_1_easy_sql.htm |