orders table

The orders table in the Reddit Clone Database Schema schema has 11 columns, keyed by id, with 2 foreign keys to users and payment_methods. 1 column in order_items references it.

Money in minor units as an integer beside an explicit currency. Never floats. A refund is a new row referencing the original, never a mutation of it.

Columns (11)

Columns of the orders table
ColumnTypeConstraintsDescription
iduuidprimary key
user_iduuidnot null, references users.id
kindorder_kindnot null
amount_minorintegernot null
currencychar(3)not null
statusorder_statusnot null
payment_method_iduuidreferences payment_methods.id
processorvarchar(40)not null
processor_referencevarchar(120)
created_attimestamptznot null
completed_attimestamptz

Indexes (3)

  • (user_id, created_at)
  • (status, created_at)
  • (processor_reference)

Relationships