17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 8: Being Normal: Normalization and Other Basic Design Issues<br />

The First Normal Form<br />

The first normal form (1NF) is all about eliminating repeating groups of data and guaranteeing atomicity<br />

(the data is self-contained and independent). At a high level, it works by creating a primary key (which<br />

we already have), then moving any repeating data groups into new tables, creating new keys for those<br />

tables, and so on. In addition, we break out any columns that combine data into separate rows for each<br />

piece of data.<br />

In the more traditional flat file designs, repeating data was commonplace — as was having multiple<br />

pieces of information in a column. This was rather problematic in a number of ways:<br />

❑ At that time, disk storage was extremely expensive. Storing data multiple times means wasted<br />

space. Data storage has become substantially less expensive, so this isn’t as big an issue as it<br />

once was.<br />

❑ Repetitive data means more data to be moved, and larger I/O counts. This means that performance<br />

is hindered as large blocks of data must be moved through the data bus and or network.<br />

This, even with today’s much faster technology, can have a substantial negative impact on<br />

performance.<br />

❑ The data between rows of what should have been repeating data often did not agree, creating<br />

something of a data paradox and a general lack of data integrity.<br />

❑ If you wanted to query information out of a column that has combined data, then you had to<br />

first come up with a way to parse the data in that column (this was extremely slow).<br />

Now, there are a lot of columns in our table, and I probably could have easily tossed in a few more. Still,<br />

the nice thing about it is that I could query everything out of one place when I wanted to know about<br />

orders.<br />

Just to explore what this means, however, let’s take a look at what some data in this table might look<br />

like. Note that I’m going to cut out a few columns here just to help things fit on a page, but I think you’ll<br />

still be able to see the point:<br />

Order<br />

No<br />

Order<br />

Date<br />

Customer<br />

No<br />

Customer<br />

Name<br />

Customer<br />

Address<br />

100 1/1/99 54545 ACME Co 1234 1st<br />

St.<br />

101 1/1/99 12000 Sneed<br />

Corp.<br />

102 1/1/99 66651 ZZZ &<br />

Co.<br />

555 Main<br />

Ave.<br />

4242 SW<br />

2nd<br />

103 1/2/99 54545 ACME Co 1234 1st<br />

St.<br />

ItemsOrdered<br />

1A4536, Flange, 7lbs, $75;4-OR2400,<br />

Injector, .5lbs, $108;4-OR2403, Injector,<br />

.5lbs, $116;1-4I5436, Head, 63lbs, $750<br />

1-3X9567, Pump, 5lbs, $62.50<br />

7-8G9200; Fan, 3lbs, $84;1-8G5437, Fan,<br />

3lbs, $15;1-3H6250, Control, 5lbs, $32<br />

40-8G9200, Fan, 3lbs, $480;1-2P5523,<br />

Housing, 1lb, $165;1-3X9567, Pump,<br />

5lbs, $42<br />

219

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!