Entity order
A placed order.
Terms: Order
Subject areas: Sales
Attributes
| # | Name | Type | Null | Default | Key | Terms | Description |
|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | PK | |||
| 2 | customer_id | bigint | no | FK | |||
| 3 | coupon_id | bigint | yes | FK | |||
| 4 | status | enum order_status | no | "pending" | |||
| 5 | total | domain money (decimal(12, 2)) | no | 0 | |||
| 6 | placed_at | timestamptz | no | expr "now()" |
Keys
| Kind | Name | Attributes |
|---|---|---|
| primary | pk_order | id |
Relationships
| Name | Role | Other entity | Cardinality | Attributes | Identifying | On delete | On update |
|---|---|---|---|---|---|---|---|
| order_coupon | child | coupon | zero_or_one to many | order.coupon_id -> coupon.id | no | set_null | no_action |
| order_customer | child | customer | one to many | order.customer_id -> customer.id | no | restrict | no_action |
| order_line_order | parent | order_line | one to one_or_many | order_line.order_id -> order.id | yes | cascade | no_action |
| payment_order | parent | payment | one to many | payment.order_id -> order.id | no | no_action | no_action |
Physical
lite (sqlite): main.order
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | integer | no | by_default | id | |||
| 2 | customer_id | integer | no | customer_id | ||||
| 3 | coupon_id | integer | yes | coupon_id | ||||
| 4 | status | order_status | no | "pending" | status | |||
| 5 | total | numeric | no | 0 | total | |||
| 6 | placed_at | text | no | expr "CURRENT_TIMESTAMP" | placed_at |
- primary key pk_order (id)
- foreign key fk_order_coupon (coupon_id) references coupon (id) on delete set_null
- foreign key fk_order_customer (customer_id) references customer (id) on delete restrict
- index ix_order_coupon (coupon_id)
- index ix_order_customer (customer_id)
pg (postgresql): public.order
A placed order.
| # | Name | Type | Null | Default | Identity | Collation | Attribute | Comment |
|---|---|---|---|---|---|---|---|---|
| 1 | id | bigint | no | always | id | |||
| 2 | customer_id | bigint | no | customer_id | ||||
| 3 | coupon_id | bigint | yes | coupon_id | ||||
| 4 | status | order_status | no | "pending" | status | |||
| 5 | total | numeric(12, 2) | no | 0 | total | |||
| 6 | placed_at | timestamp with time zone | no | expr "now()" | placed_at |
- primary key pk_order (id)
- foreign key fk_order_coupon (coupon_id) references coupon (id) on delete set_null
- foreign key fk_order_customer (customer_id) references customer (id) on delete restrict
- index ix_order_coupon (coupon_id)
- index ix_order_customer (customer_id)
Triggers
| Name | Timing | Events | Level | Action |
|---|---|---|---|---|
| trg_order_touch | before | update | row | function set_updated_at |