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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

Sometimes what is, in practice, one entity still needs to be broken out into two tables and, thus, two entities.<br />

The header is something of the parent table of the two tables in the relationship. It contains information<br />

that needs to be stored only once while the detail table stores the information that may exist in<br />

multiple instances. The header usually keeps the name of the original table, and the detail table usually<br />

has a name that starts with the header table name and adds on something to indicate that it is a detail<br />

table (for example, OrderDetails). For every one header record, you usually have at least one detail<br />

record and may have many, many more. This is one example of a kind of relationship (a one-to-many<br />

relationship) that you look at in the next major section.<br />

So let’s take care of this by splitting our table again. We’ll actually start with the detail table since it’s<br />

keeping the bulk of the columns. From this point forward, we’ll call this table OrderDetails:<br />

OrderNo<br />

(PK)<br />

LineItem<br />

(PK)<br />

PartNo Description Qty Unit<br />

Price<br />

Then we move on to what, although you could consider it to be the new table of the two, will serve as<br />

the header table and thus keep the Orders name:<br />

OrderNo (PK) OrderDate CustomerNo<br />

100 1/1/1999 54545<br />

101 1/1/1999 12000<br />

102 1/1/1999 66651<br />

103 1/2/1999 54545<br />

Total<br />

Price<br />

100 1 1A4536 Flange 5 15 75 6<br />

100 2 OR2400 Injector 4 27 108 .5<br />

100 3 OR2403 Injector 4 29 116 .5<br />

100 4 4I5436 Head 1 750 750 3<br />

101 1 3X9567 Pump 1 62.50 62.50 5<br />

102 1 8G9200 Fan 7 12 84 3<br />

102 2 8G5437 Fan 1 15 15 3<br />

102 3 3H6250 Control 1 32 32 5<br />

103 1 8G9200 Fan 40 12 480 3<br />

103 2 2P5523 Housing 1 165 165 1<br />

103 3 3X9567 Pump 1 42 42 5<br />

Wt<br />

223

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

Saved successfully!

Ooh no, something went wrong!