Northwind › Tables
Order Details table
The order lines. Its primary key is two columns, (OrderID, ProductID). 2155 rows.
Columns
| # | Name | Type | Not null | Default | Key | References |
|---|---|---|---|---|---|---|
| 0 | OrderID |
INTEGER |
yes | — | PK 1 | Orders.OrderID |
| 1 | ProductID |
INTEGER |
yes | — | PK 2 | Products.ProductID |
| 2 | UnitPrice |
REAL |
yes | 0 |
||
| 3 | Quantity |
INTEGER |
yes | 1 |
||
| 4 | Discount |
REAL |
yes | 0 |
Indexes
| Name | Columns | Unique | Created by |
|---|---|---|---|
OrderDetails_ProductID |
ProductID |
no | CREATE INDEX |
sqlite_autoindex_Order Details_1 |
OrderID, ProductID |
yes | PRIMARY KEY |
Referenced by
No other table has a foreign key pointing at Order Details.
Definition
CREATE TABLE "Order Details" (
OrderID INTEGER NOT NULL REFERENCES Orders (OrderID),
ProductID INTEGER NOT NULL REFERENCES Products (ProductID),
UnitPrice REAL NOT NULL DEFAULT 0 CHECK (UnitPrice >= 0),
Quantity INTEGER NOT NULL DEFAULT 1 CHECK (Quantity > 0),
Discount REAL NOT NULL DEFAULT 0 CHECK (Discount >= 0 AND Discount <= 1),
PRIMARY KEY (OrderID, ProductID)
)