Listing 1: Code for Creating the Orders and OrderDetails Tables CREATE TABLE Orders ( OrderId int NOT NULL PRIMARY KEY, CustomerId int NOT NULL, OrderDate smalldatetime NOT NULL, OrderStatus tinyint NOT NULL CHECK (OrderStatus IN (1 /*Processing*/, 2 /*Shipped*/, 3 /*Cancelled*/) ) ) CREATE TABLE OrderDetails ( PRIMARY KEY (OrderId, ProductId), OrderId int NOT NULL FOREIGN KEY REFERENCES Orders(OrderId), ProductId int NOT NULL, Quantity int NOT NULL CHECK(Quantity > 0), OrderDetailStatus tinyint NOT NULL CHECK( OrderDetailStatus IN (1 /*Processing*/, 2 /*Processed*/, 3 /*Cancelled*/, 4 /*Returned*/)), )