-- FOREIGN KEYS FOR BOOKSTORE 1.0

-- BOOK

ALTER TABLE BOOK ADD CONSTRAINT FK_BOOK001 FOREIGN KEY (AUTHOR_ID) REFERENCES AUTHOR ;

ALTER TABLE BOOK ADD CONSTRAINT FK_BOOK002 FOREIGN KEY (PUBLISHER_ID) REFERENCES PUBLISHER ;

-- BOOK_ORDER

ALTER TABLE BOOK_ORDER ADD CONSTRAINT FK_BOOK_ORDER001 FOREIGN KEY (SHOP_CODE) REFERENCES SHOP ;

ALTER TABLE BOOK_ORDER ADD CONSTRAINT FK_BOOK_ORDER002 FOREIGN KEY (CUSTOMER_CODE) REFERENCES CUSTOMER ;

-- ALTER TABLE BOOK_ORDER DROP FOREIGN KEY FK_BOOK_ORDER003 ;
ALTER TABLE BOOK_ORDER ADD CONSTRAINT FK_BOOK_ORDER003 FOREIGN KEY (EMPLOYEE_CODE) REFERENCES EMPLOYEE ;

-- BOOK_ORDER_ITEM

ALTER TABLE BOOK_ORDER_ITEM ADD CONSTRAINT FK_BOOK_ORDER_ITEM001 FOREIGN KEY (BOOK_ORDER_ID) REFERENCES BOOK_ORDER ;

ALTER TABLE BOOK_ORDER_ITEM ADD CONSTRAINT FK_BOOK_ORDER_ITEM002 FOREIGN KEY (BOOK_ID) REFERENCES BOOK ;

-- CUSTOMER

ALTER TABLE CUSTOMER ADD CONSTRAINT FK_CUSTOMER001 FOREIGN KEY (COUNTRY_CODE) REFERENCES COUNTRY ;

-- EMPLOYEE

ALTER TABLE EMPLOYEE ADD CONSTRAINT FK_EMPLOYEE001 FOREIGN KEY (SHOP_CODE) REFERENCES SHOP ;

-- PUBLISHER

ALTER TABLE PUBLISHER ADD CONSTRAINT FK_PUBLISHER001 FOREIGN KEY (COUNTRY_CODE) REFERENCES COUNTRY ;

-- REVIEW

ALTER TABLE REVIEW ADD CONSTRAINT FK_REVIEW001 FOREIGN KEY (CUSTOMER_CODE) REFERENCES CUSTOMER ;

ALTER TABLE REVIEW ADD CONSTRAINT FK_REVIEW002 FOREIGN KEY (BOOK_ID) REFERENCES BOOK ;

-- SHOP

ALTER TABLE SHOP ADD CONSTRAINT FK_SHOP001 FOREIGN KEY (COUNTRY_CODE) REFERENCES COUNTRY ;

ALTER TABLE SHOP ADD CONSTRAINT FK_SHOP002 FOREIGN KEY (EXECUTIVE) REFERENCES EMPLOYEE ;

-- SYNOPSIS

ALTER TABLE SYNOPSIS ADD CONSTRAINT FK_SYNOPSIS001 FOREIGN KEY (BOOK_ID) REFERENCES BOOK ;
