20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

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.

Appendix A<br />

376<br />

Figure A-1<br />

ISBN is a unique reference that identifies books and makes up part of the primary key. BookSellerId<br />

uniquely identifies a bookseller and provides the second part of the primary key. Finally, PublisherCode<br />

is the third part of the primary key for Table1. For the WrittenBy table, the primary key is the ISBN and<br />

AuthorId. In Authors, the AuthorId is the primary key, a newly created column that Table1 references.<br />

So far, the database is roughly in first normal form. Second normal form specifies that no partial dependencies<br />

can exist between any of the columns on the primary key. In Table1, BookTitle and<br />

YearPublished are dependent on ISBN but not dependent on BookSellerId or PublisherCode.<br />

BookSellerName and BookSellerTelNo are dependent only on the BookSellerId and not on any of the<br />

other parts of the primary key. Finally, PublisherCode determines PublisherName and<br />

PublisherAddress, but no dependency exists between any of the other parts of the primary key.<br />

Therefore, in order to make the table comply with second normal form, the three independent parts<br />

need to be split up into three tables, which you can call something like Books, BookSellers, and<br />

Publishers. Figure A-2 illustrates how this might look:

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

Saved successfully!

Ooh no, something went wrong!