Database Reference
In-Depth Information
Table 4.8
Column Descriptions for SHIPPING Table
Column Name
Data Type
PK or FK
Reference Table
ShippingID
INT
PK
OrderID
INT
FK
ORDERS
EmployeeID
INT
FK
EMPLOYEE
ShippingDate
DATETIME
Street
VARCHAR(50)
City
VARCHAR(50)
State
VARCHAR(50)
Zip
CHAR(5)
CREATE TABLE SHIPPING
(
ShippingID INT PRIMARY KEY,
OrderID INT NOT NULL,
EmployeeID INT NOT NULL,
ShippingDate DATETIME NOT NULL,
Street VARCHAR(50) NOT NULL,
City VARCHAR(50) NOT NULL,
State VARCHAR(50) NOT NULL,
Zip CHAR(5) NOT NULL,
CONSTRAINT Shipping_OrderId_fk
FOREIGN KEY (OrderID)
REFERENCES ORDERS (OrderID),
CONSTRAINT Shipping_EmployeeId_fk
FOREIGN KEY (EmployeeID)
REFERENCES EMPLOYEE (EmployeeID)
)
here are two intersection tables in the Computer_Store database, ORDER_INVENTORY
and CUSTOMER_PAYMENT. hese two tables contain multiple foreign key columns that are
also used in a combination primary key. In Table 4.9, we have the deinition of the intersection
table ORDER_INVENTORY.
In the SQL statement, you will have three constraints, two for the foreign keys and one for the
combination primary key. To create the table ORDER_INVENTORY with these constraints,
consider the SQL statement below:
Table 4.9
Column Descriptions for ORDER_INVENTORY Table
Column Name
Data Type
PK or FK
Reference Table
OrderID
INT
PK, FK
ORDERS
InventoryID
INT
PK, FK
INVENTORY
Quantity
INT
Search WWH ::




Custom Search