Database Reference
In-Depth Information
Table 4.10
Column Descriptions for CUSTOMER_PAYMENT Table
Column Name
Data Type
PK or FK
Reference Table
CustomerID
INT
PK, FK
CUSTOMER
PaymentID
INT
PK, FK
PAYMENT
PaymentDate
DATETIME
CREATE TABLE ORDER_INVENTORY
(
OrderID INT,
InventoryID INT,
Quantity INT DEFAULT 0 CHECK(Quantity >= 0) NOT NULL,
CONSTRAINT OInventory_OrderID_fk
FOREIGN KEY (OrderID)
REFERENCES ORDERS (OrderID),
CONSTRAINT OInventory_InventoryID_fk
FOREIGN KEY (InventoryID)
REFERENCES INVENTORY (InventoryID),
CONSTRAINT OrderID_InventoryID_pk
PRIMARY KEY (OrderID, InventoryID)
)
For the table CUSTOMER_PAYMENT, you have the deinition in Table 4.10.
Similar to the SQL statement used to create the table ORDER_INVENTORY, the key-
word CONSTRAINT is used to deine a combination primary key shown in the following
code:
CREATE TABLE CUSTOMER_PAYMENT
(
CustomerID INT,
PaymentID INT,
PaymentDate DATETIME NOT NULL,
CONSTRAINT CustPayment_CustomerID_fk
FOREIGN KEY (CustomerID)
REFERENCES CUSTOMER (CustomerID),
CONSTRAINT CustPaymant_PaymentID_fk
FOREIGN KEY (PaymentID)
REFERENCES PAYMENT (PaymentID),
CONSTRAINT CustomerID_PaymentID_pk
PRIMARY KEY (CustomerID, PaymentID)
)
Now, all the tables are deined. With the SQL statements given in this section, you should be
able to create the tables in Windows Azure SQL Database. Next, you will enter and execute the
SQL statements in Windows Azure SQL Database.
Search WWH ::




Custom Search