Mysql Foreign Keys

mysql

How can we add foreign key constraint?

ALTER TABLE orderitems ADD CONSTRAINT fk_orderitems_order FOREIGN KEY(orderID) REFERENCES order(id);
ALTER TABLE orderitems ADD CONSTRAINT fk_orderitems_product FOREIGN KEY(productID) REFERENCES product(id);
ALTER TABLE order ADD CONSTRAINT fk_order_customer FOREIGN KEY(customerID) REFERENCES customer(id);
ALTER TABLE product ADD CONSTRAINT fk_product_vendor FOREIGN KEY(vendorID) REFERENCES vendor(id);
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License