discount_redemptions table
The discount_redemptions table in the E-commerce Database Schema schema has 6 columns, keyed by id, with 3 foreign keys to discounts, orders and customers.
The per-customer index is what enforces one-use-per-shopper promotions.
Columns (6)
| Column | Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key | |
| discount_id | uuid | not null, references discounts.id | |
| order_id | uuid | not null, references orders.id | |
| customer_id | uuid | not null, references customers.id | |
| amount_cents | integer | not null | |
| redeemed_at | timestamptz | not null |
Indexes (2)
(discount_id, order_id)unique(discount_id, customer_id)
Relationships
discount_redemptions.discount_idreferencesdiscounts.iddiscount_redemptions.order_idreferencesorders.iddiscount_redemptions.customer_idreferencescustomers.id