Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Figure A-2 Notice that Table1 is renamed BooksForSale and that all the columns except ISBN, PublisherCode, and BookSellerId are deleted. The database is now in second normal form. Exercise 2 Solution The FavCategory table links to two other tables: Category and MemberDetails. They are both the primary tables, the columns in FavCategory being foreign keys. Therefore, you must create two FOREIGN KEY constraints: ALTER TABLE FavCategory ADD CONSTRAINT favcat_cat_fk FOREIGN KEY (CategoryId) REFERENCES Category(CategoryId); ALTER TABLE FavCategory ADD CONSTRAINT favcat_member_fk FOREIGN KEY (MemberId) REFERENCES MemberDetails(MemberId); Exercise Answers 377

Figure A-2<br />

Notice that Table1 is renamed BooksForSale and that all the columns except ISBN, PublisherCode, and<br />

BookSellerId are deleted. The database is now in second normal form.<br />

Exercise 2 Solution<br />

The FavCategory table links to two other tables: Category and MemberDetails. They are both the primary<br />

tables, the columns in FavCategory being foreign keys. Therefore, you must create two FOREIGN<br />

KEY constraints:<br />

ALTER TABLE FavCategory<br />

ADD CONSTRAINT favcat_cat_fk<br />

FOREIGN KEY (CategoryId)<br />

REFERENCES Category(CategoryId);<br />

ALTER TABLE FavCategory<br />

ADD CONSTRAINT favcat_member_fk<br />

FOREIGN KEY (MemberId)<br />

REFERENCES MemberDetails(MemberId);<br />

Exercise Answers<br />

377

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

Saved successfully!

Ooh no, something went wrong!