0

Hi,

I can create all tables but order table. What is wrong, is it foreign key?

CREATE TABLE customer(
customerId INT(10) NOT NULL AUTO_INCREMENT, 
customerName VARCHAR(10),
customerSurname VARCHAR(10),
customerAddress VARCHAR(10),
PRIMARY KEY (customerId));

CREATE TABLE order(
orderId INT(10) NOT NULL AUTO_INCREMENT, 
customerId INT(10),
PRIMARY KEY (orderId),
FOREIGN KEY (customerId) REFERENCES customer(customerId));

CREATE TABLE orderDetail(
orderDate DATE,
orderId INT(10), 
productId INT(10),
FOREIGN KEY (orderId) REFERENCES order(orderId),
FOREIGN KEY (productId) REFERENCES product(productId));

CREATE TABLE product(
productId INT(10) NOT NULL AUTO_INCREMENT, 
productName VARCHAR(10),
PRIMARY KEY (productId));

CREATE TABLE stock(
stock INT(10), 
productId INT(10),
FOREIGN KEY (productId) REFERENCES product(productId));

Thanks

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Fenerbahce
0

"order" is a reserved word so you need to quote it if you're going to use it for a table name. See here for details.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.