Mysql Syntax Help (webmatrix)?

The below code keeps on getting a CONSTRAINT error. Any ideas?
Create Table Orders(
orderNumber bigint Not Null,
orderDate datetime Not Null,
completed bit Not Null,
discount numeric(2,1),
PRIMARY KEY(orderNumber)
CONSTRAINT FK_Orders_Store
FOREIGN KEY(StoreID) REFERENCES Store(StoreID)
CONSTRAINT FK_Orders_Pizza
FOREIGN KEY(itemCode) REFERENCES Pizza(itemCode)
)
(the below codes are seperate tables)
Create Table Store(
StoreID int IDENTITY,
town nvarchar(25) NOT NULL,
address nvarchar(50) NOT NULL,
PRIMARY KEY(StoreID)
)
Create Table Pizza(
itemCode int IDENTITY,
pizzaName nvarchar(25) NOT NULL,
baseType nvarchar(20) NOT NULL,
PRIMARY KEY(itemCode)
)

Both comments and pings are currently closed.

One Response to “Mysql Syntax Help (webmatrix)?”

  1. rbjolly says:

    It ought to give you more than a constraint error. Try the following:
    Create Table Store(
    StoreID INTEGER AUTO_INCREMENT PRIMARY KEY,
    town nvarchar(25) NOT NULL,
    address nvarchar(50) NOT NULL
    );
    Create Table Pizza(
    itemCode INTEGER AUTO_INCREMENT PRIMARY KEY,
    pizzaName nvarchar(25) NOT NULL,
    baseType nvarchar(20) NOT NULL
    );
    Create Table Orders(
    orderNumber BIGINT UNSIGNED NOT NULL PRIMARY KEY auto_increment,
    orderDate datetime Not Null,
    completed bit Not Null,
    discount numeric(2,1),
    StoreID INTEGER,
    itemCode INTEGER,
    CONSTRAINT FK_Orders_Store
    FOREIGN KEY(StoreID) REFERENCES Store(StoreID),
    CONSTRAINT FK_Orders_Pizza
    FOREIGN KEY(itemCode) REFERENCES Pizza(itemCode)
    );

Powered by WordPress | Designed by: free css template | Thanks to hostgator coupon and web hosting reviews