orders table

The orders table in the E-commerce Database Schema schema has 12 columns, keyed by id, with 1 foreign key to customers. 7 columns in order_lines, order_addresses, shipments, returns and 3 more reference it.

Every money column is a snapshot taken at placed_at. Totals are stored, not recomputed on read.

Columns (12)

Columns of the orders table
ColumnTypeConstraintsDescription
iduuidprimary key
customer_iduuidnot null, references customers.id
numbervarchar(32)unique, not null
statusorder_statusnot null
currencychar(3)not null
subtotal_centsintegernot null
discount_centsintegernot null
shipping_centsintegernot null
tax_centsintegernot null
total_centsintegernot null
placed_attimestamptznot null
cancelled_attimestamptz

Indexes (2)

  • (customer_id, placed_at)
  • (status, placed_at)

Relationships