Why does this query fail?
I know that the 'correct' form is with the constraints defined separately,Code:CREATE TABLE Order_Items ( Order_ID CHAR(72) NOT NULL FOREIGN KEY REFERENCES Orders(ID), Product_ID INT(10) UNSIGNED NOT NULL FOREIGN KEY REFERENCES Items(ID), Quantity INT(10) UNSIGNED NOT NULL, Notes VARCHAR(255) );
but why then can you define primary keys in the column definition? I prefer the SQL / Oracle / Microsoft SQL syntax, and hope to be able to use it with little changes to MySQL.Code:CREATE TABLE Order_Items ( Order_ID CHAR(72) NOT NULL, Product_ID INT(10) UNSIGNED NOT NULL, Quantity INT(10) UNSIGNED NOT NULL, Notes VARCHAR(255), FOREIGN KEY (Order_ID) REFERENCES Orders(ID), FOREIGN KEY (Product_ID) REFERENCES Items(ID) );


LinkBack URL
About LinkBacks

Reply With Quote
icon below! (this is even better than "liking" a post)
