Restaurant Ordering and POS ER diagram and database schema
The Restaurant Ordering and POS database schema is a DB Planner template with 29 tables, 220 columns and 60 relationships, free to use. Core tables include adjustment_reasons, business_days, cash_drawers, check_adjustments. It can be opened as an interactive ER diagram or exported as PostgreSQL, MySQL, or SQL Server DDL.
- Tables
- 29
- Columns
- 220
- Relationships
- 60
- Category
- E-commerce
- Exports
- DBML, SQL, Prisma, C#
- Price
- Free
What this schema models
A complete restaurant point-of-sale database design, built the way a real front of house and kitchen run a shift: 29 tables, 14 enums and 60 relationships covering locations and the floor plan, a menu with dayparts, daypart pricing and modifier groups, recipes and plate cost, staff, role permissions and the time clock, checks by order type with seats and courses, voids, comps and discounts, kitchen tickets routed to prep stations, split payments and tips, cash drawers and the end-of-day close. THE FOUR DESIGN RULES 1. Nothing is deleted. Voids, comps and discounts are append-only adjustment rows with a reason picked from a fixed list, the employee who asked and the manager who approved. A check line that reached the kitchen is never deleted: a void marks it voided, and a void after firing is flagged as food waste. 2. Check lines are snapshots with a seat and a course. The name and the price actually charged (including a happy-hour daypart price and the modifier deltas) are copied at ring-in. The seat number drives serving and split-by-seat; the course decides firing order, and a line stays held until its course is fired. 3. The kitchen sees tickets, not checks. Firing a course creates one ticket per prep station, each with its own fired, started, bumped and recalled times, so ticket time is measured per station. A void after firing reaches the station as a void notice instead of silently vanishing from the screen. 4. Business date, not calendar date. Checks, payments, time punches and drawer sessions all belong to a business day that rolls over at an hour set per location, so the 1:30 am bar tab lands on the right night. The end-of-day close freezes the totals and locks the day. DETAILS WORTH STEALING - Cash drawers use blind counts: the closer counts without seeing the expected amount, over/short is stored per session, and a partial unique index allows one open session per drawer. - Every safe drop, paid-out, paid-in and no-sale opening is a drawer movement, which is exactly what managers audit. - Splitting a check evenly, by seat or by amount is just several payment rows, and card tips are added at tip adjust after the swipe. - Permissions hang off roles through a join table, PINs are stored only as hashes, and every check, void, comp and payment records the employee. - Time clock punches snapshot the wage, record declared cash tips and any manager correction, and only one open punch per employee is allowed. - Recipe lines link ingredients to items and to modifiers such as "Add bacon", which gives plate cost and theoretical usage per day. WHAT YOU GET Clean DBML that imports directly into DB Planner, and a laid-out board with zones color-coded and framed: recipes and food cost, menu, locations and floor plan, checks and adjustments, kitchen display, payments, cash and day close, and staff and permissions. Every table carries a note. Postgres-flavoured types that port cleanly to MySQL or SQL Server. Useful for developers building a restaurant POS, ordering or kitchen display system, and for students who need a realistic restaurant POS ER diagram for a DBMS project. This is a schema design reference; tax, tip and labor rules vary by jurisdiction and belong in your own business logic.
Tables (29)
| Table | Columns |
|---|---|
| adjustment_reasons | 8 |
| business_days | 11 |
| cash_drawers | 4 |
| check_adjustments | 11 |
| check_item_modifiers | 5 |
| check_items | 13 |
| checks | 18 |
| dayparts | 6 |
| dining_areas | 4 |
| dining_tables | 8 |
| drawer_movements | 8 |
| drawer_sessions | 11 |
| employees | 9 |
| ingredients | 6 |
| item_daypart_prices | 3 |
| kitchen_ticket_items | 4 |
| kitchen_tickets | 11 |
| locations | 9 |
| menu_categories | 6 |
| menu_item_modifier_groups | 3 |
| menu_items | 10 |
| modifier_groups | 5 |
| modifier_options | 5 |
| payments | 14 |
| prep_stations | 6 |
| recipe_lines | 5 |
| role_permissions | 2 |
| roles | 4 |
| time_clock_entries | 11 |
Every table and its columns
locations
One restaurant. Menu, floor plan, staff, kitchen stations and the cash office are all per location.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| name | varchar(200) | not null | ||
| address | varchar(300) | not null | ||
| timezone | varchar(64) | not null | IANA zone | |
| currency | char(3) | not null | ||
| business_day_rollover | time | not null, default '04:00' | When the business date changes. A check opened at 1:30 am belongs to the previous business day. | |
| tax_rate_bps | integer | not null | Sales tax on food in basis points; alcohol may use its own rate | |
| alcohol_tax_rate_bps | integer | |||
| is_active | boolean | not null, default true |
dining_areas
Sections of the floor plan. Servers are usually assigned a section per shift.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(100) | not null | e.g. Main room, Patio, Bar | |
| sort_order | smallint | not null, default 0 |
dining_tables
Tables as drawn on the host and server screens. A table shows as occupied because it has an open check, not because of a flag here.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| dining_area_id | uuid | FK, not null | dining_areas.id | |
| label | varchar(20) | not null | What staff call it, e.g. "12", "B4" | |
| seats | smallint | not null | ||
| shape | table_shape | not null | ||
| pos_x | integer | not null | Position on the floor plan screen | |
| pos_y | integer | not null | ||
| is_active | boolean | not null, default true |
Indexes: (dining_area_id, label) unique
dayparts
Named windows of the trading day. A category can be limited to one, and an item can carry a different price during one.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(60) | not null | e.g. Breakfast, Lunch, Happy hour, Late night | |
| starts_at | time | not null | ||
| ends_at | time | not null | Earlier than starts_at for a window that runs past midnight | |
| days_mask | smallint | not null, default 127 | Bitmask of weekdays, Monday = 1 ... Sunday = 64; 127 is every day |
item_daypart_prices
Price overrides by daypart, e.g. half-price wings during happy hour. The price actually charged is copied onto the check item at ring-in.
| Column | Type | Constraints | References |
|---|---|---|---|
| menu_item_id | uuid | FK, not null | menu_items.id |
| daypart_id | uuid | FK, not null | dayparts.id |
| price_cents | integer | not null |
modifier_groups
A reusable set of choices with its selection rules, so the POS prompts for exactly what the kitchen needs.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(100) | not null | e.g. Temperature, Side, Add-ons | |
| min_selections | smallint | not null, default 0 | 1 or more forces a choice, e.g. a steak temperature | |
| max_selections | smallint | not null, default 1 |
modifier_options
One choice within a modifier group.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| modifier_group_id | uuid | FK, not null | modifier_groups.id | |
| name | varchar(100) | not null | e.g. Medium rare, Fries, No onion, Add bacon | |
| price_delta_cents | integer | not null, default 0 | ||
| sort_order | smallint | not null, default 0 |
ingredients
Raw stock in its counting unit.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(120) | not null | ||
| unit | unit_of_measure | not null | The unit it is counted and costed in | |
| cost_per_unit_cents | numeric(12,4) | not null | Fractional cents: a gram of cheese costs less than one cent | |
| par_level | numeric(12,3) | Target quantity on hand, for ordering |
recipe_lines
How much of each ingredient an item or a modifier uses (a check constraint keeps exactly one of the two set). Plate cost is the sum of these lines; theoretical usage for a day is sales times these quantities.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| ingredient_id | uuid | FK, not null | ingredients.id | |
| menu_item_id | uuid | FK | menu_items.id | |
| modifier_option_id | uuid | FK | modifier_options.id | Set instead of menu_item_id for a modifier that uses stock, e.g. Add bacon |
| quantity | numeric(12,3) | not null | In the ingredient unit |
roles
Jobs. Permissions hang off the role, not the person, so promoting a server to shift lead is one update.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| name | varchar(60) | unique, not null | e.g. Server, Bartender, Host, Line cook, Shift lead, Manager | |
| default_hourly_rate_cents | integer | |||
| is_tipped | boolean | not null, default false |
role_permissions
What each role may do at the terminal: void, comp, discount, reopen a check, open the drawer with no sale, close the day.
| Column | Type | Constraints | References |
|---|---|---|---|
| role_id | uuid | FK, not null | roles.id |
| permission | permission | not null |
employees
Staff who sign in to the POS. Every check, void, comp, payment and drawer count records which employee did it.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | Home location |
| role_id | uuid | FK, not null | roles.id | |
| first_name | varchar(100) | not null | ||
| last_name | varchar(100) | not null | ||
| pin_hash | varchar(100) | not null | Hash of the PIN typed at the terminal, never the PIN itself | |
| hourly_rate_cents | integer | not null | ||
| hired_on | date | not null | ||
| terminated_on | date | Set instead of deleting: old checks and punches still point here |
time_clock_entries
Time clock punches, the source for payroll and labor cost per business day. A manager correction records who made it.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| employee_id | uuid | FK, not null | employees.id | |
| role_id | uuid | FK, not null | roles.id | The job worked on this shift, which sets the wage |
| business_day_id | uuid | FK, not null | business_days.id | |
| clock_in_at | timestamptz | not null | ||
| clock_out_at | timestamptz | |||
| break_minutes | smallint | not null, default 0 | ||
| hourly_rate_cents | integer | not null | Snapshot of the wage at clock-in | |
| declared_cash_tips_cents | integer | Cash tips declared at clock-out | ||
| edited_by | uuid | FK | employees.id | Manager who corrected a missed punch, if anyone |
| edited_at | timestamptz |
Indexes: (employee_id)
checks
A guest bill, the record everything else hangs off. Dine-in, takeout, delivery and bar tabs share one table, told apart by order_type.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| business_day_id | uuid | FK, not null | business_days.id | |
| check_number | integer | not null | Sequential per location per business day, printed on the receipt | |
| order_type | order_type | not null | ||
| dining_table_id | uuid | FK | dining_tables.id | Dine-in only |
| guest_count | smallint | Covers, for per-guest averages | ||
| server_id | uuid | FK, not null | employees.id | Who owns the check and its tips |
| customer_name | varchar(100) | For takeout, delivery or a bar tab | ||
| customer_phone | varchar(20) | |||
| split_from_check_id | uuid | FK | checks.id | Set when a check was split off another, e.g. separate checks per seat |
| status | check_status | not null, default 'open' | ||
| subtotal_cents | integer | not null, default 0 | Cached sum of the live check items | |
| adjustments_cents | integer | not null, default 0 | Cached sum of comps and discounts | |
| tax_cents | integer | not null, default 0 | ||
| total_cents | integer | not null, default 0 | ||
| opened_at | timestamptz | not null, default `now()` | ||
| closed_at | timestamptz |
Indexes: (location_id, business_day_id, check_number) unique, (dining_table_id, status)
check_items
One line on a check. Once a line has been sent to the kitchen it is never deleted: a void sets status voided and writes a check_adjustments row.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| check_id | uuid | FK, not null | checks.id | |
| menu_item_id | uuid | FK, not null | menu_items.id | |
| item_name | varchar(200) | not null | Snapshot at ring-in | |
| unit_price_cents | integer | not null | Snapshot, including any daypart price and the modifier deltas | |
| quantity | smallint | not null, default 1 | ||
| seat_number | smallint | Seat at the table, for serving and for splitting by seat; null for shared plates | ||
| course | smallint | not null | Fired in course order, starters before mains | |
| status | check_item_status | not null, default 'held' | ||
| special_request | varchar(200) | e.g. Allergy: no nuts | ||
| rung_in_by | uuid | FK, not null | employees.id | |
| rung_in_at | timestamptz | not null, default `now()` | ||
| fired_at | timestamptz | Sent to the kitchen. Null while held for a later course. |
Indexes: (check_id, course)
check_item_modifiers
The choices on a line, snapshotted, e.g. Medium rare, Sub salad.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| check_item_id | uuid | FK, not null | check_items.id | |
| modifier_option_id | uuid | FK | modifier_options.id | For reporting and recipe depletion |
| option_name | varchar(100) | not null | Snapshot, printed on the kitchen ticket | |
| price_delta_cents | integer | not null |
adjustment_reasons
The fixed list of reasons staff must pick from. Free-text reasons make void and comp reports useless.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| kind | adjustment_kind | not null | ||
| code | varchar(30) | not null | e.g. WRONG_ITEM, LONG_WAIT, EMPLOYEE_MEAL, SENIOR_10 | |
| label | varchar(100) | not null | ||
| percent_bps | integer | For a percentage discount; null for an amount entered at the time | ||
| requires_manager | boolean | not null, default true | ||
| is_active | boolean | not null, default true |
Indexes: (location_id, code) unique
check_adjustments
Every void, comp and discount, with the reason, who asked and which manager approved. Append-only: never updated, never deleted. A void says the item should not count as a sale; a comp says it was sold and given away.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| check_id | uuid | FK, not null | checks.id | |
| check_item_id | uuid | FK | check_items.id | Null for a discount on the whole check |
| kind | adjustment_kind | not null | ||
| adjustment_reason_id | uuid | FK, not null | adjustment_reasons.id | |
| amount_cents | integer | not null | Value taken off the check, always positive | |
| after_fire | boolean | not null, default false | A void after the kitchen fired the item is food waste, not just a correction | |
| requested_by | uuid | FK, not null | employees.id | |
| approved_by | uuid | FK | employees.id | Manager who entered their PIN; required when the reason says so |
| comment | varchar(300) | |||
| created_at | timestamptz | not null, default `now()` |
Indexes: (requested_by, created_at)
prep_stations
Kitchen display screens (and their backup printers). Every item routes to one station.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(60) | not null | e.g. Grill, Fry, Salad, Bar, Expo | |
| kind | station_kind | not null | ||
| printer_address | varchar(100) | Fallback ticket printer for when the screen is down | ||
| target_ticket_seconds | integer | Ticket time goal; the screen turns a ticket red past it |
kitchen_tickets
One firing of one course to one station. Mains for the grill and fries for the fryer are two tickets, and ticket time per station is bumped_at minus fired_at.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| check_id | uuid | FK, not null | checks.id | |
| prep_station_id | uuid | FK, not null | prep_stations.id | |
| course | smallint | not null | ||
| status | ticket_status | not null, default 'new' | ||
| is_rush | boolean | not null, default false | ||
| fired_by | uuid | FK, not null | employees.id | |
| fired_at | timestamptz | not null | ||
| started_at | timestamptz | |||
| bumped_at | timestamptz | Marked done on the station screen | ||
| recalled_at | timestamptz | Brought back after a bump, e.g. a dish sent back |
Indexes: (prep_station_id, status, fired_at)
kitchen_ticket_items
The check lines on a ticket, with their modifiers read through the check item. A void after firing goes to the same station as a new ticket flagged as a void notice, instead of silently vanishing from the screen.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| kitchen_ticket_id | uuid | FK, not null | kitchen_tickets.id | |
| check_item_id | uuid | FK, not null | check_items.id | |
| quantity | smallint | not null | ||
| is_void_notice | boolean | not null, default false | Shown as VOID so the line stops cooking it |
business_days
The trading day. Checks, payments, punches and drawer sessions all belong to one, so a 1:30 am bar tab is reported with the night it belongs to.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| business_date | date | not null | The trading day, which can end after midnight | |
| status | business_day_status | not null, default 'open' | ||
| opened_at | timestamptz | not null | ||
| closed_at | timestamptz | End-of-day close. The day is locked after it; later corrections land in the next day. | ||
| closed_by | uuid | FK | employees.id | |
| net_sales_cents | bigint | Frozen at close for the end-of-day report | ||
| tax_cents | bigint | |||
| tips_cents | bigint | |||
| cash_over_short_cents | integer | Sum of drawer variances for the day |
Indexes: (location_id, business_date) unique
payments
Each tender on a check. Splitting evenly, by seat or by amount is just several rows; the check closes when they cover the total.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| check_id | uuid | FK, not null | checks.id | |
| business_day_id | uuid | FK, not null | business_days.id | |
| tender | tender_type | not null | ||
| amount_cents | integer | not null | Applied to the check, tip excluded | |
| tip_cents | integer | not null, default 0 | Card tips are usually added after the swipe, at tip adjust | |
| cash_tendered_cents | integer | Cash handed over; change due is the difference | ||
| card_brand | varchar(20) | |||
| card_last4 | char(4) | |||
| processor_reference | varchar(100) | unique | ||
| status | payment_status | not null, default 'authorized' | ||
| employee_id | uuid | FK, not null | employees.id | Who took the payment; tips and cash owed are counted from this |
| drawer_session_id | uuid | FK | drawer_sessions.id | The drawer a cash payment went into |
| created_at | timestamptz | not null, default `now()` |
cash_drawers
Physical cash drawers.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| location_id | uuid | FK, not null | locations.id | |
| name | varchar(60) | not null | e.g. Bar 1, Front counter | |
| terminal_id | varchar(60) | The terminal the drawer is attached to |
drawer_sessions
One employee accountable for one drawer for a stretch of time: the float, the blind count at close, and the variance.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| cash_drawer_id | uuid | FK, not null | cash_drawers.id | |
| business_day_id | uuid | FK, not null | business_days.id | |
| employee_id | uuid | FK, not null | employees.id | The one person accountable for the drawer |
| opened_at | timestamptz | not null | ||
| starting_cash_cents | integer | not null | The counted float | |
| closed_at | timestamptz | |||
| counted_cash_cents | integer | Blind count: entered without seeing the expected amount | ||
| expected_cash_cents | integer | Float plus cash payments and paid-ins, minus paid-outs and drops | ||
| over_short_cents | integer | Counted minus expected | ||
| verified_by | uuid | FK | employees.id | Manager who verified the count |
Indexes: (cash_drawer_id)
drawer_movements
Cash in or out of a drawer that is not a sale: safe drops, paid-outs to vendors, paid-ins, and every no-sale opening, which is exactly what managers audit.
| Column | Type | Constraints | References | Description |
|---|---|---|---|---|
| id | uuid | PK | ||
| drawer_session_id | uuid | FK, not null | drawer_sessions.id | |
| kind | drawer_movement_kind | not null | ||
| amount_cents | integer | not null | Zero for a no-sale opening | |
| reason | varchar(200) | not null | e.g. "Paid out: ice delivery", "Safe drop" | |
| employee_id | uuid | FK, not null | employees.id | |
| approved_by | uuid | FK | employees.id | |
| created_at | timestamptz | not null, default `now()` |
Enums (14)
- table_shape
- round, square, rectangle, booth, bar_seat
- tax_class
- food, alcohol, non_taxable
- unit_of_measure
- gram, milliliter, each
- permission
- ring_items, transfer_check, reopen_check, void_item, comp_item, apply_discount, open_drawer_no_sale, paid_in_out, edit_time_punch, close_business_day, view_reports
- order_type
- dine_in, takeout, delivery, bar_tab
- check_status
- open, closed, voided
- check_item_status
- held, fired, served, voided
- adjustment_kind
- void, comp, discount
- station_kind
- kitchen, bar, expo
- ticket_status
- new, in_progress, bumped, recalled
- business_day_status
- open, closing, closed
- tender_type
- cash, card, gift_card, house_account
- payment_status
- authorized, captured, voided, refunded
- drawer_movement_kind
- safe_drop, paid_in, paid_out, no_sale
Relationships (60)
adjustment_reasons.location_id references locations.idmany to onebusiness_days.closed_by references employees.idmany to onebusiness_days.location_id references locations.idmany to onecash_drawers.location_id references locations.idmany to onecheck_adjustments.adjustment_reason_id references adjustment_reasons.idmany to onecheck_adjustments.approved_by references employees.idmany to onecheck_adjustments.check_id references checks.idmany to onecheck_adjustments.check_item_id references check_items.idmany to onecheck_adjustments.requested_by references employees.idmany to onecheck_item_modifiers.check_item_id references check_items.idmany to onecheck_item_modifiers.modifier_option_id references modifier_options.idmany to onecheck_items.check_id references checks.idmany to onecheck_items.menu_item_id references menu_items.idmany to onecheck_items.rung_in_by references employees.idmany to onechecks.business_day_id references business_days.idmany to onechecks.dining_table_id references dining_tables.idmany to onechecks.location_id references locations.idmany to onechecks.server_id references employees.idmany to onechecks.split_from_check_id references checks.idmany to onedayparts.location_id references locations.idmany to onedining_areas.location_id references locations.idmany to onedining_tables.dining_area_id references dining_areas.idmany to onedrawer_movements.approved_by references employees.idmany to onedrawer_movements.drawer_session_id references drawer_sessions.idmany to onedrawer_movements.employee_id references employees.idmany to onedrawer_sessions.business_day_id references business_days.idmany to onedrawer_sessions.cash_drawer_id references cash_drawers.idmany to onedrawer_sessions.employee_id references employees.idmany to onedrawer_sessions.verified_by references employees.idmany to oneemployees.location_id references locations.idmany to oneemployees.role_id references roles.idmany to oneingredients.location_id references locations.idmany to oneitem_daypart_prices.daypart_id references dayparts.idmany to oneitem_daypart_prices.menu_item_id references menu_items.idmany to onekitchen_ticket_items.check_item_id references check_items.idmany to onekitchen_ticket_items.kitchen_ticket_id references kitchen_tickets.idmany to onekitchen_tickets.check_id references checks.idmany to onekitchen_tickets.fired_by references employees.idmany to onekitchen_tickets.prep_station_id references prep_stations.idmany to onemenu_categories.daypart_id references dayparts.idmany to onemenu_categories.location_id references locations.idmany to onemenu_item_modifier_groups.menu_item_id references menu_items.idmany to onemenu_item_modifier_groups.modifier_group_id references modifier_groups.idmany to onemenu_items.menu_category_id references menu_categories.idmany to onemenu_items.prep_station_id references prep_stations.idmany to onemodifier_groups.location_id references locations.idmany to onemodifier_options.modifier_group_id references modifier_groups.idmany to onepayments.business_day_id references business_days.idmany to onepayments.check_id references checks.idmany to onepayments.drawer_session_id references drawer_sessions.idmany to onepayments.employee_id references employees.idmany to oneprep_stations.location_id references locations.idmany to onerecipe_lines.ingredient_id references ingredients.idmany to onerecipe_lines.menu_item_id references menu_items.idmany to onerecipe_lines.modifier_option_id references modifier_options.idmany to onerole_permissions.role_id references roles.idmany to onetime_clock_entries.business_day_id references business_days.idmany to onetime_clock_entries.edited_by references employees.idmany to onetime_clock_entries.employee_id references employees.idmany to onetime_clock_entries.role_id references roles.idmany to one
Restaurant Ordering and POS database schema in DBML
The schema as it is written: DBML, the text format DB Planner draws its diagrams from. Copy it into any DBML tool, or open it in the diagram above.
// Restaurant Ordering and POS
// Zones (header colors): staff and permissions (gray), locations and floor plan (blue),
// menu (teal), recipes and food cost (green), checks and adjustments (amber),
// kitchen display (coral), payments, cash and day close (purple).
// ---------------------------------------------------------------------------
// LOCATIONS AND FLOOR PLAN
// ---------------------------------------------------------------------------
Table locations [headercolor: #4c8bf5] {
id uuid [pk]
name varchar(200) [not null]
address varchar(300) [not null]
timezone varchar(64) [not null, note: 'IANA zone']
currency char(3) [not null]
business_day_rollover time [not null, default: '04:00', note: 'When the business date changes. A check opened at 1:30 am belongs to the previous business day.']
tax_rate_bps integer [not null, note: 'Sales tax on food in basis points; alcohol may use its own rate']
alcohol_tax_rate_bps integer
is_active boolean [not null, default: true]
Note: 'One restaurant. Menu, floor plan, staff, kitchen stations and the cash office are all per location.'
}
Table dining_areas [headercolor: #4c8bf5] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(100) [not null, note: 'e.g. Main room, Patio, Bar']
sort_order smallint [not null, default: 0]
Note: 'Sections of the floor plan. Servers are usually assigned a section per shift.'
}
Table dining_tables [headercolor: #4c8bf5] {
id uuid [pk]
dining_area_id uuid [not null, ref: > dining_areas.id]
label varchar(20) [not null, note: 'What staff call it, e.g. "12", "B4"']
seats smallint [not null]
shape table_shape [not null]
pos_x integer [not null, note: 'Position on the floor plan screen']
pos_y integer [not null]
is_active boolean [not null, default: true]
indexes {
(dining_area_id, label) [unique]
}
Note: 'Tables as drawn on the host and server screens. A table shows as occupied because it has an open check, not because of a flag here.'
}
// ---------------------------------------------------------------------------
// MENU: buttons on the order screen, priced by daypart
// ---------------------------------------------------------------------------
Table dayparts [headercolor: #4cd0b0] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(60) [not null, note: 'e.g. Breakfast, Lunch, Happy hour, Late night']
starts_at time [not null]
ends_at time [not null, note: 'Earlier than starts_at for a window that runs past midnight']
days_mask smallint [not null, default: 127, note: 'Bitmask of weekdays, Monday = 1 ... Sunday = 64; 127 is every day']
Note: 'Named windows of the trading day. A category can be limited to one, and an item can carry a different price during one.'
}
Table menu_categories [headercolor: #4cd0b0] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
daypart_id uuid [ref: > dayparts.id, note: 'Null for a category sold all day']
name varchar(100) [not null, note: 'e.g. Starters, Mains, Draft beer']
button_color char(7) [note: 'Hex color of the button on the order screen']
sort_order smallint [not null, default: 0]
Note: 'Buttons on the order screen, grouped the way servers expect to find them.'
}
Table menu_items [headercolor: #4cd0b0] {
id uuid [pk]
menu_category_id uuid [not null, ref: > menu_categories.id]
prep_station_id uuid [ref: > prep_stations.id, note: 'Where it is made. Null for items that need no kitchen, e.g. bottled water.']
name varchar(200) [not null]
kitchen_name varchar(40) [not null, note: 'Short form printed on tickets, e.g. "CHZ BGR"']
price_cents integer [not null]
tax_class tax_class [not null]
default_course smallint [not null, default: 2, note: '1 = starters, 2 = mains, 3 = dessert; the server can change it per line']
is_available boolean [not null, default: true, note: 'Switched off when the kitchen runs out (86ed)']
sort_order smallint [not null, default: 0]
Note: 'Anything that can be rung in.'
}
Table item_daypart_prices [headercolor: #4cd0b0] {
menu_item_id uuid [not null, ref: > menu_items.id]
daypart_id uuid [not null, ref: > dayparts.id]
price_cents integer [not null]
indexes {
(menu_item_id, daypart_id) [pk]
}
Note: 'Price overrides by daypart, e.g. half-price wings during happy hour. The price actually charged is copied onto the check item at ring-in.'
}
Table modifier_groups [headercolor: #4cd0b0] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(100) [not null, note: 'e.g. Temperature, Side, Add-ons']
min_selections smallint [not null, default: 0, note: '1 or more forces a choice, e.g. a steak temperature']
max_selections smallint [not null, default: 1]
Note: 'A reusable set of choices with its selection rules, so the POS prompts for exactly what the kitchen needs.'
}
Table modifier_options [headercolor: #4cd0b0] {
id uuid [pk]
modifier_group_id uuid [not null, ref: > modifier_groups.id]
name varchar(100) [not null, note: 'e.g. Medium rare, Fries, No onion, Add bacon']
price_delta_cents integer [not null, default: 0]
sort_order smallint [not null, default: 0]
Note: 'One choice within a modifier group.'
}
Table menu_item_modifier_groups [headercolor: #4cd0b0] {
menu_item_id uuid [not null, ref: > menu_items.id]
modifier_group_id uuid [not null, ref: > modifier_groups.id]
sort_order smallint [not null, default: 0]
indexes {
(menu_item_id, modifier_group_id) [pk]
}
Note: 'Which modifier groups an item prompts for, in order.'
}
// ---------------------------------------------------------------------------
// RECIPES AND FOOD COST
// ---------------------------------------------------------------------------
Table ingredients [headercolor: #8bc34a] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(120) [not null]
unit unit_of_measure [not null, note: 'The unit it is counted and costed in']
cost_per_unit_cents numeric(12,4) [not null, note: 'Fractional cents: a gram of cheese costs less than one cent']
par_level numeric(12,3) [note: 'Target quantity on hand, for ordering']
Note: 'Raw stock in its counting unit.'
}
Table recipe_lines [headercolor: #8bc34a] {
id uuid [pk]
ingredient_id uuid [not null, ref: > ingredients.id]
menu_item_id uuid [ref: > menu_items.id]
modifier_option_id uuid [ref: > modifier_options.id, note: 'Set instead of menu_item_id for a modifier that uses stock, e.g. Add bacon']
quantity numeric(12,3) [not null, note: 'In the ingredient unit']
Note: 'How much of each ingredient an item or a modifier uses (a check constraint keeps exactly one of the two set). Plate cost is the sum of these lines; theoretical usage for a day is sales times these quantities.'
}
// ---------------------------------------------------------------------------
// STAFF AND PERMISSIONS
// ---------------------------------------------------------------------------
Table roles [headercolor: #90a4ae] {
id uuid [pk]
name varchar(60) [not null, unique, note: 'e.g. Server, Bartender, Host, Line cook, Shift lead, Manager']
default_hourly_rate_cents integer
is_tipped boolean [not null, default: false]
Note: 'Jobs. Permissions hang off the role, not the person, so promoting a server to shift lead is one update.'
}
Table role_permissions [headercolor: #90a4ae] {
role_id uuid [not null, ref: > roles.id]
permission permission [not null]
indexes {
(role_id, permission) [pk]
}
Note: 'What each role may do at the terminal: void, comp, discount, reopen a check, open the drawer with no sale, close the day.'
}
Table employees [headercolor: #90a4ae] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id, note: 'Home location']
role_id uuid [not null, ref: > roles.id]
first_name varchar(100) [not null]
last_name varchar(100) [not null]
pin_hash varchar(100) [not null, note: 'Hash of the PIN typed at the terminal, never the PIN itself']
hourly_rate_cents integer [not null]
hired_on date [not null]
terminated_on date [note: 'Set instead of deleting: old checks and punches still point here']
Note: 'Staff who sign in to the POS. Every check, void, comp, payment and drawer count records which employee did it.'
}
Table time_clock_entries [headercolor: #90a4ae] {
id uuid [pk]
employee_id uuid [not null, ref: > employees.id]
role_id uuid [not null, ref: > roles.id, note: 'The job worked on this shift, which sets the wage']
business_day_id uuid [not null, ref: > business_days.id]
clock_in_at timestamptz [not null]
clock_out_at timestamptz
break_minutes smallint [not null, default: 0]
hourly_rate_cents integer [not null, note: 'Snapshot of the wage at clock-in']
declared_cash_tips_cents integer [note: 'Cash tips declared at clock-out']
edited_by uuid [ref: > employees.id, note: 'Manager who corrected a missed punch, if anyone']
edited_at timestamptz
indexes {
employee_id [name: 'one_open_punch', note: 'Partial unique index WHERE clock_out_at IS NULL']
}
Note: 'Time clock punches, the source for payroll and labor cost per business day. A manager correction records who made it.'
}
// ---------------------------------------------------------------------------
// CHECKS AND ADJUSTMENTS: what was rung in, and every change to it
// ---------------------------------------------------------------------------
Table checks [headercolor: #f5b74c] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
business_day_id uuid [not null, ref: > business_days.id]
check_number integer [not null, note: 'Sequential per location per business day, printed on the receipt']
order_type order_type [not null]
dining_table_id uuid [ref: > dining_tables.id, note: 'Dine-in only']
guest_count smallint [note: 'Covers, for per-guest averages']
server_id uuid [not null, ref: > employees.id, note: 'Who owns the check and its tips']
customer_name varchar(100) [note: 'For takeout, delivery or a bar tab']
customer_phone varchar(20)
split_from_check_id uuid [ref: > checks.id, note: 'Set when a check was split off another, e.g. separate checks per seat']
status check_status [not null, default: 'open']
subtotal_cents integer [not null, default: 0, note: 'Cached sum of the live check items']
adjustments_cents integer [not null, default: 0, note: 'Cached sum of comps and discounts']
tax_cents integer [not null, default: 0]
total_cents integer [not null, default: 0]
opened_at timestamptz [not null, default: `now()`]
closed_at timestamptz
indexes {
(location_id, business_day_id, check_number) [unique]
(dining_table_id, status) [note: 'Which tables have open checks right now']
}
Note: 'A guest bill, the record everything else hangs off. Dine-in, takeout, delivery and bar tabs share one table, told apart by order_type.'
}
Table check_items [headercolor: #f5b74c] {
id uuid [pk]
check_id uuid [not null, ref: > checks.id]
menu_item_id uuid [not null, ref: > menu_items.id]
item_name varchar(200) [not null, note: 'Snapshot at ring-in']
unit_price_cents integer [not null, note: 'Snapshot, including any daypart price and the modifier deltas']
quantity smallint [not null, default: 1]
seat_number smallint [note: 'Seat at the table, for serving and for splitting by seat; null for shared plates']
course smallint [not null, note: 'Fired in course order, starters before mains']
status check_item_status [not null, default: 'held']
special_request varchar(200) [note: 'e.g. Allergy: no nuts']
rung_in_by uuid [not null, ref: > employees.id]
rung_in_at timestamptz [not null, default: `now()`]
fired_at timestamptz [note: 'Sent to the kitchen. Null while held for a later course.']
indexes {
(check_id, course)
}
Note: 'One line on a check. Once a line has been sent to the kitchen it is never deleted: a void sets status voided and writes a check_adjustments row.'
}
Table check_item_modifiers [headercolor: #f5b74c] {
id uuid [pk]
check_item_id uuid [not null, ref: > check_items.id]
modifier_option_id uuid [ref: > modifier_options.id, note: 'For reporting and recipe depletion']
option_name varchar(100) [not null, note: 'Snapshot, printed on the kitchen ticket']
price_delta_cents integer [not null]
Note: 'The choices on a line, snapshotted, e.g. Medium rare, Sub salad.'
}
Table adjustment_reasons [headercolor: #f5b74c] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
kind adjustment_kind [not null]
code varchar(30) [not null, note: 'e.g. WRONG_ITEM, LONG_WAIT, EMPLOYEE_MEAL, SENIOR_10']
label varchar(100) [not null]
percent_bps integer [note: 'For a percentage discount; null for an amount entered at the time']
requires_manager boolean [not null, default: true]
is_active boolean [not null, default: true]
indexes {
(location_id, code) [unique]
}
Note: 'The fixed list of reasons staff must pick from. Free-text reasons make void and comp reports useless.'
}
Table check_adjustments [headercolor: #f5b74c] {
id uuid [pk]
check_id uuid [not null, ref: > checks.id]
check_item_id uuid [ref: > check_items.id, note: 'Null for a discount on the whole check']
kind adjustment_kind [not null]
adjustment_reason_id uuid [not null, ref: > adjustment_reasons.id]
amount_cents integer [not null, note: 'Value taken off the check, always positive']
after_fire boolean [not null, default: false, note: 'A void after the kitchen fired the item is food waste, not just a correction']
requested_by uuid [not null, ref: > employees.id]
approved_by uuid [ref: > employees.id, note: 'Manager who entered their PIN; required when the reason says so']
comment varchar(300)
created_at timestamptz [not null, default: `now()`]
indexes {
(requested_by, created_at) [note: 'Voids and comps per employee, the first report loss prevention runs']
}
Note: 'Every void, comp and discount, with the reason, who asked and which manager approved. Append-only: never updated, never deleted. A void says the item should not count as a sale; a comp says it was sold and given away.'
}
// ---------------------------------------------------------------------------
// KITCHEN DISPLAY: tickets routed to prep stations
// ---------------------------------------------------------------------------
Table prep_stations [headercolor: #f07178] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(60) [not null, note: 'e.g. Grill, Fry, Salad, Bar, Expo']
kind station_kind [not null]
printer_address varchar(100) [note: 'Fallback ticket printer for when the screen is down']
target_ticket_seconds integer [note: 'Ticket time goal; the screen turns a ticket red past it']
Note: 'Kitchen display screens (and their backup printers). Every item routes to one station.'
}
Table kitchen_tickets [headercolor: #f07178] {
id uuid [pk]
check_id uuid [not null, ref: > checks.id]
prep_station_id uuid [not null, ref: > prep_stations.id]
course smallint [not null]
status ticket_status [not null, default: 'new']
is_rush boolean [not null, default: false]
fired_by uuid [not null, ref: > employees.id]
fired_at timestamptz [not null]
started_at timestamptz
bumped_at timestamptz [note: 'Marked done on the station screen']
recalled_at timestamptz [note: 'Brought back after a bump, e.g. a dish sent back']
indexes {
(prep_station_id, status, fired_at) [note: 'What a station screen shows: open tickets, oldest first']
}
Note: 'One firing of one course to one station. Mains for the grill and fries for the fryer are two tickets, and ticket time per station is bumped_at minus fired_at.'
}
Table kitchen_ticket_items [headercolor: #f07178] {
kitchen_ticket_id uuid [not null, ref: > kitchen_tickets.id]
check_item_id uuid [not null, ref: > check_items.id]
quantity smallint [not null]
is_void_notice boolean [not null, default: false, note: 'Shown as VOID so the line stops cooking it']
indexes {
(kitchen_ticket_id, check_item_id) [pk]
}
Note: 'The check lines on a ticket, with their modifiers read through the check item. A void after firing goes to the same station as a new ticket flagged as a void notice, instead of silently vanishing from the screen.'
}
// ---------------------------------------------------------------------------
// PAYMENTS, CASH AND DAY CLOSE
// ---------------------------------------------------------------------------
Table business_days [headercolor: #b98cf0] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
business_date date [not null, note: 'The trading day, which can end after midnight']
status business_day_status [not null, default: 'open']
opened_at timestamptz [not null]
closed_at timestamptz [note: 'End-of-day close. The day is locked after it; later corrections land in the next day.']
closed_by uuid [ref: > employees.id]
net_sales_cents bigint [note: 'Frozen at close for the end-of-day report']
tax_cents bigint
tips_cents bigint
cash_over_short_cents integer [note: 'Sum of drawer variances for the day']
indexes {
(location_id, business_date) [unique]
}
Note: 'The trading day. Checks, payments, punches and drawer sessions all belong to one, so a 1:30 am bar tab is reported with the night it belongs to.'
}
Table payments [headercolor: #b98cf0] {
id uuid [pk]
check_id uuid [not null, ref: > checks.id]
business_day_id uuid [not null, ref: > business_days.id]
tender tender_type [not null]
amount_cents integer [not null, note: 'Applied to the check, tip excluded']
tip_cents integer [not null, default: 0, note: 'Card tips are usually added after the swipe, at tip adjust']
cash_tendered_cents integer [note: 'Cash handed over; change due is the difference']
card_brand varchar(20)
card_last4 char(4)
processor_reference varchar(100) [unique]
status payment_status [not null, default: 'authorized']
employee_id uuid [not null, ref: > employees.id, note: 'Who took the payment; tips and cash owed are counted from this']
drawer_session_id uuid [ref: > drawer_sessions.id, note: 'The drawer a cash payment went into']
created_at timestamptz [not null, default: `now()`]
Note: 'Each tender on a check. Splitting evenly, by seat or by amount is just several rows; the check closes when they cover the total.'
}
Table cash_drawers [headercolor: #b98cf0] {
id uuid [pk]
location_id uuid [not null, ref: > locations.id]
name varchar(60) [not null, note: 'e.g. Bar 1, Front counter']
terminal_id varchar(60) [note: 'The terminal the drawer is attached to']
Note: 'Physical cash drawers.'
}
Table drawer_sessions [headercolor: #b98cf0] {
id uuid [pk]
cash_drawer_id uuid [not null, ref: > cash_drawers.id]
business_day_id uuid [not null, ref: > business_days.id]
employee_id uuid [not null, ref: > employees.id, note: 'The one person accountable for the drawer']
opened_at timestamptz [not null]
starting_cash_cents integer [not null, note: 'The counted float']
closed_at timestamptz
counted_cash_cents integer [note: 'Blind count: entered without seeing the expected amount']
expected_cash_cents integer [note: 'Float plus cash payments and paid-ins, minus paid-outs and drops']
over_short_cents integer [note: 'Counted minus expected']
verified_by uuid [ref: > employees.id, note: 'Manager who verified the count']
indexes {
cash_drawer_id [name: 'one_open_session', note: 'Partial unique index WHERE closed_at IS NULL: one person per drawer at a time']
}
Note: 'One employee accountable for one drawer for a stretch of time: the float, the blind count at close, and the variance.'
}
Table drawer_movements [headercolor: #b98cf0] {
id uuid [pk]
drawer_session_id uuid [not null, ref: > drawer_sessions.id]
kind drawer_movement_kind [not null]
amount_cents integer [not null, note: 'Zero for a no-sale opening']
reason varchar(200) [not null, note: 'e.g. "Paid out: ice delivery", "Safe drop"']
employee_id uuid [not null, ref: > employees.id]
approved_by uuid [ref: > employees.id]
created_at timestamptz [not null, default: `now()`]
Note: 'Cash in or out of a drawer that is not a sale: safe drops, paid-outs to vendors, paid-ins, and every no-sale opening, which is exactly what managers audit.'
}
// ---------------------------------------------------------------------------
// ENUMS
// ---------------------------------------------------------------------------
Enum table_shape {
round
square
rectangle
booth
bar_seat
}
Enum tax_class {
food
alcohol
non_taxable
}
Enum unit_of_measure {
gram
milliliter
each
}
Enum permission {
ring_items
transfer_check
reopen_check
void_item
comp_item
apply_discount
open_drawer_no_sale
paid_in_out
edit_time_punch
close_business_day
view_reports
}
Enum order_type {
dine_in
takeout
delivery
bar_tab
}
Enum check_status {
open
closed
voided
}
Enum check_item_status {
held
fired
served
voided
}
Enum adjustment_kind {
void
comp
discount
}
Enum station_kind {
kitchen
bar
expo
}
Enum ticket_status {
new
in_progress
bumped
recalled
}
Enum business_day_status {
open
closing
closed
}
Enum tender_type {
cash
card
gift_card
house_account
}
Enum payment_status {
authorized
captured
voided
refunded
}
Enum drawer_movement_kind {
safe_drop
paid_in
paid_out
no_sale
}Restaurant Ordering and POS database schema as SQL
The same schema as CREATE TABLE statements, exported by DB Planner.
PostgreSQL is shown first; MySQL and SQL Server are below it.
PostgreSQL
CREATE TYPE "table_shape" AS ENUM (
'round',
'square',
'rectangle',
'booth',
'bar_seat'
);
CREATE TYPE "tax_class" AS ENUM (
'food',
'alcohol',
'non_taxable'
);
CREATE TYPE "unit_of_measure" AS ENUM (
'gram',
'milliliter',
'each'
);
CREATE TYPE "permission" AS ENUM (
'ring_items',
'transfer_check',
'reopen_check',
'void_item',
'comp_item',
'apply_discount',
'open_drawer_no_sale',
'paid_in_out',
'edit_time_punch',
'close_business_day',
'view_reports'
);
CREATE TYPE "order_type" AS ENUM (
'dine_in',
'takeout',
'delivery',
'bar_tab'
);
CREATE TYPE "check_status" AS ENUM (
'open',
'closed',
'voided'
);
CREATE TYPE "check_item_status" AS ENUM (
'held',
'fired',
'served',
'voided'
);
CREATE TYPE "adjustment_kind" AS ENUM (
'void',
'comp',
'discount'
);
CREATE TYPE "station_kind" AS ENUM (
'kitchen',
'bar',
'expo'
);
CREATE TYPE "ticket_status" AS ENUM (
'new',
'in_progress',
'bumped',
'recalled'
);
CREATE TYPE "business_day_status" AS ENUM (
'open',
'closing',
'closed'
);
CREATE TYPE "tender_type" AS ENUM (
'cash',
'card',
'gift_card',
'house_account'
);
CREATE TYPE "payment_status" AS ENUM (
'authorized',
'captured',
'voided',
'refunded'
);
CREATE TYPE "drawer_movement_kind" AS ENUM (
'safe_drop',
'paid_in',
'paid_out',
'no_sale'
);
CREATE TABLE "locations" (
"id" uuid PRIMARY KEY,
"name" varchar(200) NOT NULL,
"address" varchar(300) NOT NULL,
"timezone" varchar(64) NOT NULL,
"currency" char(3) NOT NULL,
"business_day_rollover" time NOT NULL DEFAULT '04:00',
"tax_rate_bps" integer NOT NULL,
"alcohol_tax_rate_bps" integer,
"is_active" boolean NOT NULL DEFAULT true
);
CREATE TABLE "dining_areas" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(100) NOT NULL,
"sort_order" smallint NOT NULL DEFAULT 0
);
CREATE TABLE "dining_tables" (
"id" uuid PRIMARY KEY,
"dining_area_id" uuid NOT NULL,
"label" varchar(20) NOT NULL,
"seats" smallint NOT NULL,
"shape" table_shape NOT NULL,
"pos_x" integer NOT NULL,
"pos_y" integer NOT NULL,
"is_active" boolean NOT NULL DEFAULT true
);
CREATE TABLE "dayparts" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(60) NOT NULL,
"starts_at" time NOT NULL,
"ends_at" time NOT NULL,
"days_mask" smallint NOT NULL DEFAULT 127
);
CREATE TABLE "menu_categories" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"daypart_id" uuid,
"name" varchar(100) NOT NULL,
"button_color" char(7),
"sort_order" smallint NOT NULL DEFAULT 0
);
CREATE TABLE "menu_items" (
"id" uuid PRIMARY KEY,
"menu_category_id" uuid NOT NULL,
"prep_station_id" uuid,
"name" varchar(200) NOT NULL,
"kitchen_name" varchar(40) NOT NULL,
"price_cents" integer NOT NULL,
"tax_class" tax_class NOT NULL,
"default_course" smallint NOT NULL DEFAULT 2,
"is_available" boolean NOT NULL DEFAULT true,
"sort_order" smallint NOT NULL DEFAULT 0
);
CREATE TABLE "item_daypart_prices" (
"menu_item_id" uuid NOT NULL,
"daypart_id" uuid NOT NULL,
"price_cents" integer NOT NULL,
PRIMARY KEY ("menu_item_id", "daypart_id")
);
CREATE TABLE "modifier_groups" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(100) NOT NULL,
"min_selections" smallint NOT NULL DEFAULT 0,
"max_selections" smallint NOT NULL DEFAULT 1
);
CREATE TABLE "modifier_options" (
"id" uuid PRIMARY KEY,
"modifier_group_id" uuid NOT NULL,
"name" varchar(100) NOT NULL,
"price_delta_cents" integer NOT NULL DEFAULT 0,
"sort_order" smallint NOT NULL DEFAULT 0
);
CREATE TABLE "menu_item_modifier_groups" (
"menu_item_id" uuid NOT NULL,
"modifier_group_id" uuid NOT NULL,
"sort_order" smallint NOT NULL DEFAULT 0,
PRIMARY KEY ("menu_item_id", "modifier_group_id")
);
CREATE TABLE "ingredients" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(120) NOT NULL,
"unit" unit_of_measure NOT NULL,
"cost_per_unit_cents" numeric(12,4) NOT NULL,
"par_level" numeric(12,3)
);
CREATE TABLE "recipe_lines" (
"id" uuid PRIMARY KEY,
"ingredient_id" uuid NOT NULL,
"menu_item_id" uuid,
"modifier_option_id" uuid,
"quantity" numeric(12,3) NOT NULL
);
CREATE TABLE "roles" (
"id" uuid PRIMARY KEY,
"name" varchar(60) UNIQUE NOT NULL,
"default_hourly_rate_cents" integer,
"is_tipped" boolean NOT NULL DEFAULT false
);
CREATE TABLE "role_permissions" (
"role_id" uuid NOT NULL,
"permission" permission NOT NULL,
PRIMARY KEY ("role_id", "permission")
);
CREATE TABLE "employees" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"role_id" uuid NOT NULL,
"first_name" varchar(100) NOT NULL,
"last_name" varchar(100) NOT NULL,
"pin_hash" varchar(100) NOT NULL,
"hourly_rate_cents" integer NOT NULL,
"hired_on" date NOT NULL,
"terminated_on" date
);
CREATE TABLE "time_clock_entries" (
"id" uuid PRIMARY KEY,
"employee_id" uuid NOT NULL,
"role_id" uuid NOT NULL,
"business_day_id" uuid NOT NULL,
"clock_in_at" timestamptz NOT NULL,
"clock_out_at" timestamptz,
"break_minutes" smallint NOT NULL DEFAULT 0,
"hourly_rate_cents" integer NOT NULL,
"declared_cash_tips_cents" integer,
"edited_by" uuid,
"edited_at" timestamptz
);
CREATE TABLE "checks" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"business_day_id" uuid NOT NULL,
"check_number" integer NOT NULL,
"order_type" order_type NOT NULL,
"dining_table_id" uuid,
"guest_count" smallint,
"server_id" uuid NOT NULL,
"customer_name" varchar(100),
"customer_phone" varchar(20),
"split_from_check_id" uuid,
"status" check_status NOT NULL DEFAULT 'open',
"subtotal_cents" integer NOT NULL DEFAULT 0,
"adjustments_cents" integer NOT NULL DEFAULT 0,
"tax_cents" integer NOT NULL DEFAULT 0,
"total_cents" integer NOT NULL DEFAULT 0,
"opened_at" timestamptz NOT NULL DEFAULT (now()),
"closed_at" timestamptz
);
CREATE TABLE "check_items" (
"id" uuid PRIMARY KEY,
"check_id" uuid NOT NULL,
"menu_item_id" uuid NOT NULL,
"item_name" varchar(200) NOT NULL,
"unit_price_cents" integer NOT NULL,
"quantity" smallint NOT NULL DEFAULT 1,
"seat_number" smallint,
"course" smallint NOT NULL,
"status" check_item_status NOT NULL DEFAULT 'held',
"special_request" varchar(200),
"rung_in_by" uuid NOT NULL,
"rung_in_at" timestamptz NOT NULL DEFAULT (now()),
"fired_at" timestamptz
);
CREATE TABLE "check_item_modifiers" (
"id" uuid PRIMARY KEY,
"check_item_id" uuid NOT NULL,
"modifier_option_id" uuid,
"option_name" varchar(100) NOT NULL,
"price_delta_cents" integer NOT NULL
);
CREATE TABLE "adjustment_reasons" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"kind" adjustment_kind NOT NULL,
"code" varchar(30) NOT NULL,
"label" varchar(100) NOT NULL,
"percent_bps" integer,
"requires_manager" boolean NOT NULL DEFAULT true,
"is_active" boolean NOT NULL DEFAULT true
);
CREATE TABLE "check_adjustments" (
"id" uuid PRIMARY KEY,
"check_id" uuid NOT NULL,
"check_item_id" uuid,
"kind" adjustment_kind NOT NULL,
"adjustment_reason_id" uuid NOT NULL,
"amount_cents" integer NOT NULL,
"after_fire" boolean NOT NULL DEFAULT false,
"requested_by" uuid NOT NULL,
"approved_by" uuid,
"comment" varchar(300),
"created_at" timestamptz NOT NULL DEFAULT (now())
);
CREATE TABLE "prep_stations" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(60) NOT NULL,
"kind" station_kind NOT NULL,
"printer_address" varchar(100),
"target_ticket_seconds" integer
);
CREATE TABLE "kitchen_tickets" (
"id" uuid PRIMARY KEY,
"check_id" uuid NOT NULL,
"prep_station_id" uuid NOT NULL,
"course" smallint NOT NULL,
"status" ticket_status NOT NULL DEFAULT 'new',
"is_rush" boolean NOT NULL DEFAULT false,
"fired_by" uuid NOT NULL,
"fired_at" timestamptz NOT NULL,
"started_at" timestamptz,
"bumped_at" timestamptz,
"recalled_at" timestamptz
);
CREATE TABLE "kitchen_ticket_items" (
"kitchen_ticket_id" uuid NOT NULL,
"check_item_id" uuid NOT NULL,
"quantity" smallint NOT NULL,
"is_void_notice" boolean NOT NULL DEFAULT false,
PRIMARY KEY ("kitchen_ticket_id", "check_item_id")
);
CREATE TABLE "business_days" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"business_date" date NOT NULL,
"status" business_day_status NOT NULL DEFAULT 'open',
"opened_at" timestamptz NOT NULL,
"closed_at" timestamptz,
"closed_by" uuid,
"net_sales_cents" bigint,
"tax_cents" bigint,
"tips_cents" bigint,
"cash_over_short_cents" integer
);
CREATE TABLE "payments" (
"id" uuid PRIMARY KEY,
"check_id" uuid NOT NULL,
"business_day_id" uuid NOT NULL,
"tender" tender_type NOT NULL,
"amount_cents" integer NOT NULL,
"tip_cents" integer NOT NULL DEFAULT 0,
"cash_tendered_cents" integer,
"card_brand" varchar(20),
"card_last4" char(4),
"processor_reference" varchar(100) UNIQUE,
"status" payment_status NOT NULL DEFAULT 'authorized',
"employee_id" uuid NOT NULL,
"drawer_session_id" uuid,
"created_at" timestamptz NOT NULL DEFAULT (now())
);
CREATE TABLE "cash_drawers" (
"id" uuid PRIMARY KEY,
"location_id" uuid NOT NULL,
"name" varchar(60) NOT NULL,
"terminal_id" varchar(60)
);
CREATE TABLE "drawer_sessions" (
"id" uuid PRIMARY KEY,
"cash_drawer_id" uuid NOT NULL,
"business_day_id" uuid NOT NULL,
"employee_id" uuid NOT NULL,
"opened_at" timestamptz NOT NULL,
"starting_cash_cents" integer NOT NULL,
"closed_at" timestamptz,
"counted_cash_cents" integer,
"expected_cash_cents" integer,
"over_short_cents" integer,
"verified_by" uuid
);
CREATE TABLE "drawer_movements" (
"id" uuid PRIMARY KEY,
"drawer_session_id" uuid NOT NULL,
"kind" drawer_movement_kind NOT NULL,
"amount_cents" integer NOT NULL,
"reason" varchar(200) NOT NULL,
"employee_id" uuid NOT NULL,
"approved_by" uuid,
"created_at" timestamptz NOT NULL DEFAULT (now())
);
CREATE UNIQUE INDEX ON "dining_tables" ("dining_area_id", "label");
CREATE INDEX "one_open_punch" ON "time_clock_entries" ("employee_id");
CREATE UNIQUE INDEX ON "checks" ("location_id", "business_day_id", "check_number");
CREATE INDEX ON "checks" ("dining_table_id", "status");
CREATE INDEX ON "check_items" ("check_id", "course");
CREATE UNIQUE INDEX ON "adjustment_reasons" ("location_id", "code");
CREATE INDEX ON "check_adjustments" ("requested_by", "created_at");
CREATE INDEX ON "kitchen_tickets" ("prep_station_id", "status", "fired_at");
CREATE UNIQUE INDEX ON "business_days" ("location_id", "business_date");
CREATE INDEX "one_open_session" ON "drawer_sessions" ("cash_drawer_id");
COMMENT ON TABLE "locations" IS 'One restaurant. Menu, floor plan, staff, kitchen stations and the cash office are all per location.';
COMMENT ON COLUMN "locations"."timezone" IS 'IANA zone';
COMMENT ON COLUMN "locations"."business_day_rollover" IS 'When the business date changes. A check opened at 1:30 am belongs to the previous business day.';
COMMENT ON COLUMN "locations"."tax_rate_bps" IS 'Sales tax on food in basis points; alcohol may use its own rate';
COMMENT ON TABLE "dining_areas" IS 'Sections of the floor plan. Servers are usually assigned a section per shift.';
COMMENT ON COLUMN "dining_areas"."name" IS 'e.g. Main room, Patio, Bar';
COMMENT ON TABLE "dining_tables" IS 'Tables as drawn on the host and server screens. A table shows as occupied because it has an open check, not because of a flag here.';
COMMENT ON COLUMN "dining_tables"."label" IS 'What staff call it, e.g. "12", "B4"';
COMMENT ON COLUMN "dining_tables"."pos_x" IS 'Position on the floor plan screen';
COMMENT ON TABLE "dayparts" IS 'Named windows of the trading day. A category can be limited to one, and an item can carry a different price during one.';
COMMENT ON COLUMN "dayparts"."name" IS 'e.g. Breakfast, Lunch, Happy hour, Late night';
COMMENT ON COLUMN "dayparts"."ends_at" IS 'Earlier than starts_at for a window that runs past midnight';
COMMENT ON COLUMN "dayparts"."days_mask" IS 'Bitmask of weekdays, Monday = 1 ... Sunday = 64; 127 is every day';
COMMENT ON TABLE "menu_categories" IS 'Buttons on the order screen, grouped the way servers expect to find them.';
COMMENT ON COLUMN "menu_categories"."daypart_id" IS 'Null for a category sold all day';
COMMENT ON COLUMN "menu_categories"."name" IS 'e.g. Starters, Mains, Draft beer';
COMMENT ON COLUMN "menu_categories"."button_color" IS 'Hex color of the button on the order screen';
COMMENT ON TABLE "menu_items" IS 'Anything that can be rung in.';
COMMENT ON COLUMN "menu_items"."prep_station_id" IS 'Where it is made. Null for items that need no kitchen, e.g. bottled water.';
COMMENT ON COLUMN "menu_items"."kitchen_name" IS 'Short form printed on tickets, e.g. "CHZ BGR"';
COMMENT ON COLUMN "menu_items"."default_course" IS '1 = starters, 2 = mains, 3 = dessert; the server can change it per line';
COMMENT ON COLUMN "menu_items"."is_available" IS 'Switched off when the kitchen runs out (86ed)';
COMMENT ON TABLE "item_daypart_prices" IS 'Price overrides by daypart, e.g. half-price wings during happy hour. The price actually charged is copied onto the check item at ring-in.';
COMMENT ON TABLE "modifier_groups" IS 'A reusable set of choices with its selection rules, so the POS prompts for exactly what the kitchen needs.';
COMMENT ON COLUMN "modifier_groups"."name" IS 'e.g. Temperature, Side, Add-ons';
COMMENT ON COLUMN "modifier_groups"."min_selections" IS '1 or more forces a choice, e.g. a steak temperature';
COMMENT ON TABLE "modifier_options" IS 'One choice within a modifier group.';
COMMENT ON COLUMN "modifier_options"."name" IS 'e.g. Medium rare, Fries, No onion, Add bacon';
COMMENT ON TABLE "menu_item_modifier_groups" IS 'Which modifier groups an item prompts for, in order.';
COMMENT ON TABLE "ingredients" IS 'Raw stock in its counting unit.';
COMMENT ON COLUMN "ingredients"."unit" IS 'The unit it is counted and costed in';
COMMENT ON COLUMN "ingredients"."cost_per_unit_cents" IS 'Fractional cents: a gram of cheese costs less than one cent';
COMMENT ON COLUMN "ingredients"."par_level" IS 'Target quantity on hand, for ordering';
COMMENT ON TABLE "recipe_lines" IS 'How much of each ingredient an item or a modifier uses (a check constraint keeps exactly one of the two set). Plate cost is the sum of these lines; theoretical usage for a day is sales times these quantities.';
COMMENT ON COLUMN "recipe_lines"."modifier_option_id" IS 'Set instead of menu_item_id for a modifier that uses stock, e.g. Add bacon';
COMMENT ON COLUMN "recipe_lines"."quantity" IS 'In the ingredient unit';
COMMENT ON TABLE "roles" IS 'Jobs. Permissions hang off the role, not the person, so promoting a server to shift lead is one update.';
COMMENT ON COLUMN "roles"."name" IS 'e.g. Server, Bartender, Host, Line cook, Shift lead, Manager';
COMMENT ON TABLE "role_permissions" IS 'What each role may do at the terminal: void, comp, discount, reopen a check, open the drawer with no sale, close the day.';
COMMENT ON TABLE "employees" IS 'Staff who sign in to the POS. Every check, void, comp, payment and drawer count records which employee did it.';
COMMENT ON COLUMN "employees"."location_id" IS 'Home location';
COMMENT ON COLUMN "employees"."pin_hash" IS 'Hash of the PIN typed at the terminal, never the PIN itself';
COMMENT ON COLUMN "employees"."terminated_on" IS 'Set instead of deleting: old checks and punches still point here';
COMMENT ON TABLE "time_clock_entries" IS 'Time clock punches, the source for payroll and labor cost per business day. A manager correction records who made it.';
COMMENT ON COLUMN "time_clock_entries"."role_id" IS 'The job worked on this shift, which sets the wage';
COMMENT ON COLUMN "time_clock_entries"."hourly_rate_cents" IS 'Snapshot of the wage at clock-in';
COMMENT ON COLUMN "time_clock_entries"."declared_cash_tips_cents" IS 'Cash tips declared at clock-out';
COMMENT ON COLUMN "time_clock_entries"."edited_by" IS 'Manager who corrected a missed punch, if anyone';
COMMENT ON TABLE "checks" IS 'A guest bill, the record everything else hangs off. Dine-in, takeout, delivery and bar tabs share one table, told apart by order_type.';
COMMENT ON COLUMN "checks"."check_number" IS 'Sequential per location per business day, printed on the receipt';
COMMENT ON COLUMN "checks"."dining_table_id" IS 'Dine-in only';
COMMENT ON COLUMN "checks"."guest_count" IS 'Covers, for per-guest averages';
COMMENT ON COLUMN "checks"."server_id" IS 'Who owns the check and its tips';
COMMENT ON COLUMN "checks"."customer_name" IS 'For takeout, delivery or a bar tab';
COMMENT ON COLUMN "checks"."split_from_check_id" IS 'Set when a check was split off another, e.g. separate checks per seat';
COMMENT ON COLUMN "checks"."subtotal_cents" IS 'Cached sum of the live check items';
COMMENT ON COLUMN "checks"."adjustments_cents" IS 'Cached sum of comps and discounts';
COMMENT ON TABLE "check_items" IS 'One line on a check. Once a line has been sent to the kitchen it is never deleted: a void sets status voided and writes a check_adjustments row.';
COMMENT ON COLUMN "check_items"."item_name" IS 'Snapshot at ring-in';
COMMENT ON COLUMN "check_items"."unit_price_cents" IS 'Snapshot, including any daypart price and the modifier deltas';
COMMENT ON COLUMN "check_items"."seat_number" IS 'Seat at the table, for serving and for splitting by seat; null for shared plates';
COMMENT ON COLUMN "check_items"."course" IS 'Fired in course order, starters before mains';
COMMENT ON COLUMN "check_items"."special_request" IS 'e.g. Allergy: no nuts';
COMMENT ON COLUMN "check_items"."fired_at" IS 'Sent to the kitchen. Null while held for a later course.';
COMMENT ON TABLE "check_item_modifiers" IS 'The choices on a line, snapshotted, e.g. Medium rare, Sub salad.';
COMMENT ON COLUMN "check_item_modifiers"."modifier_option_id" IS 'For reporting and recipe depletion';
COMMENT ON COLUMN "check_item_modifiers"."option_name" IS 'Snapshot, printed on the kitchen ticket';
COMMENT ON TABLE "adjustment_reasons" IS 'The fixed list of reasons staff must pick from. Free-text reasons make void and comp reports useless.';
COMMENT ON COLUMN "adjustment_reasons"."code" IS 'e.g. WRONG_ITEM, LONG_WAIT, EMPLOYEE_MEAL, SENIOR_10';
COMMENT ON COLUMN "adjustment_reasons"."percent_bps" IS 'For a percentage discount; null for an amount entered at the time';
COMMENT ON TABLE "check_adjustments" IS 'Every void, comp and discount, with the reason, who asked and which manager approved. Append-only: never updated, never deleted. A void says the item should not count as a sale; a comp says it was sold and given away.';
COMMENT ON COLUMN "check_adjustments"."check_item_id" IS 'Null for a discount on the whole check';
COMMENT ON COLUMN "check_adjustments"."amount_cents" IS 'Value taken off the check, always positive';
COMMENT ON COLUMN "check_adjustments"."after_fire" IS 'A void after the kitchen fired the item is food waste, not just a correction';
COMMENT ON COLUMN "check_adjustments"."approved_by" IS 'Manager who entered their PIN; required when the reason says so';
COMMENT ON TABLE "prep_stations" IS 'Kitchen display screens (and their backup printers). Every item routes to one station.';
COMMENT ON COLUMN "prep_stations"."name" IS 'e.g. Grill, Fry, Salad, Bar, Expo';
COMMENT ON COLUMN "prep_stations"."printer_address" IS 'Fallback ticket printer for when the screen is down';
COMMENT ON COLUMN "prep_stations"."target_ticket_seconds" IS 'Ticket time goal; the screen turns a ticket red past it';
COMMENT ON TABLE "kitchen_tickets" IS 'One firing of one course to one station. Mains for the grill and fries for the fryer are two tickets, and ticket time per station is bumped_at minus fired_at.';
COMMENT ON COLUMN "kitchen_tickets"."bumped_at" IS 'Marked done on the station screen';
COMMENT ON COLUMN "kitchen_tickets"."recalled_at" IS 'Brought back after a bump, e.g. a dish sent back';
COMMENT ON TABLE "kitchen_ticket_items" IS 'The check lines on a ticket, with their modifiers read through the check item. A void after firing goes to the same station as a new ticket flagged as a void notice, instead of silently vanishing from the screen.';
COMMENT ON COLUMN "kitchen_ticket_items"."is_void_notice" IS 'Shown as VOID so the line stops cooking it';
COMMENT ON TABLE "business_days" IS 'The trading day. Checks, payments, punches and drawer sessions all belong to one, so a 1:30 am bar tab is reported with the night it belongs to.';
COMMENT ON COLUMN "business_days"."business_date" IS 'The trading day, which can end after midnight';
COMMENT ON COLUMN "business_days"."closed_at" IS 'End-of-day close. The day is locked after it; later corrections land in the next day.';
COMMENT ON COLUMN "business_days"."net_sales_cents" IS 'Frozen at close for the end-of-day report';
COMMENT ON COLUMN "business_days"."cash_over_short_cents" IS 'Sum of drawer variances for the day';
COMMENT ON TABLE "payments" IS 'Each tender on a check. Splitting evenly, by seat or by amount is just several rows; the check closes when they cover the total.';
COMMENT ON COLUMN "payments"."amount_cents" IS 'Applied to the check, tip excluded';
COMMENT ON COLUMN "payments"."tip_cents" IS 'Card tips are usually added after the swipe, at tip adjust';
COMMENT ON COLUMN "payments"."cash_tendered_cents" IS 'Cash handed over; change due is the difference';
COMMENT ON COLUMN "payments"."employee_id" IS 'Who took the payment; tips and cash owed are counted from this';
COMMENT ON COLUMN "payments"."drawer_session_id" IS 'The drawer a cash payment went into';
COMMENT ON TABLE "cash_drawers" IS 'Physical cash drawers.';
COMMENT ON COLUMN "cash_drawers"."name" IS 'e.g. Bar 1, Front counter';
COMMENT ON COLUMN "cash_drawers"."terminal_id" IS 'The terminal the drawer is attached to';
COMMENT ON TABLE "drawer_sessions" IS 'One employee accountable for one drawer for a stretch of time: the float, the blind count at close, and the variance.';
COMMENT ON COLUMN "drawer_sessions"."employee_id" IS 'The one person accountable for the drawer';
COMMENT ON COLUMN "drawer_sessions"."starting_cash_cents" IS 'The counted float';
COMMENT ON COLUMN "drawer_sessions"."counted_cash_cents" IS 'Blind count: entered without seeing the expected amount';
COMMENT ON COLUMN "drawer_sessions"."expected_cash_cents" IS 'Float plus cash payments and paid-ins, minus paid-outs and drops';
COMMENT ON COLUMN "drawer_sessions"."over_short_cents" IS 'Counted minus expected';
COMMENT ON COLUMN "drawer_sessions"."verified_by" IS 'Manager who verified the count';
COMMENT ON TABLE "drawer_movements" IS 'Cash in or out of a drawer that is not a sale: safe drops, paid-outs to vendors, paid-ins, and every no-sale opening, which is exactly what managers audit.';
COMMENT ON COLUMN "drawer_movements"."amount_cents" IS 'Zero for a no-sale opening';
COMMENT ON COLUMN "drawer_movements"."reason" IS 'e.g. "Paid out: ice delivery", "Safe drop"';
ALTER TABLE "dining_areas" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "dining_tables" ADD FOREIGN KEY ("dining_area_id") REFERENCES "dining_areas" ("id");
ALTER TABLE "dayparts" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "menu_categories" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "menu_categories" ADD FOREIGN KEY ("daypart_id") REFERENCES "dayparts" ("id");
ALTER TABLE "menu_items" ADD FOREIGN KEY ("menu_category_id") REFERENCES "menu_categories" ("id");
ALTER TABLE "menu_items" ADD FOREIGN KEY ("prep_station_id") REFERENCES "prep_stations" ("id");
ALTER TABLE "item_daypart_prices" ADD FOREIGN KEY ("menu_item_id") REFERENCES "menu_items" ("id");
ALTER TABLE "item_daypart_prices" ADD FOREIGN KEY ("daypart_id") REFERENCES "dayparts" ("id");
ALTER TABLE "modifier_groups" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "modifier_options" ADD FOREIGN KEY ("modifier_group_id") REFERENCES "modifier_groups" ("id");
ALTER TABLE "menu_item_modifier_groups" ADD FOREIGN KEY ("menu_item_id") REFERENCES "menu_items" ("id");
ALTER TABLE "menu_item_modifier_groups" ADD FOREIGN KEY ("modifier_group_id") REFERENCES "modifier_groups" ("id");
ALTER TABLE "ingredients" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "recipe_lines" ADD FOREIGN KEY ("ingredient_id") REFERENCES "ingredients" ("id");
ALTER TABLE "recipe_lines" ADD FOREIGN KEY ("menu_item_id") REFERENCES "menu_items" ("id");
ALTER TABLE "recipe_lines" ADD FOREIGN KEY ("modifier_option_id") REFERENCES "modifier_options" ("id");
ALTER TABLE "role_permissions" ADD FOREIGN KEY ("role_id") REFERENCES "roles" ("id");
ALTER TABLE "employees" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "employees" ADD FOREIGN KEY ("role_id") REFERENCES "roles" ("id");
ALTER TABLE "time_clock_entries" ADD FOREIGN KEY ("employee_id") REFERENCES "employees" ("id");
ALTER TABLE "time_clock_entries" ADD FOREIGN KEY ("role_id") REFERENCES "roles" ("id");
ALTER TABLE "time_clock_entries" ADD FOREIGN KEY ("business_day_id") REFERENCES "business_days" ("id");
ALTER TABLE "time_clock_entries" ADD FOREIGN KEY ("edited_by") REFERENCES "employees" ("id");
ALTER TABLE "checks" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "checks" ADD FOREIGN KEY ("business_day_id") REFERENCES "business_days" ("id");
ALTER TABLE "checks" ADD FOREIGN KEY ("dining_table_id") REFERENCES "dining_tables" ("id");
ALTER TABLE "checks" ADD FOREIGN KEY ("server_id") REFERENCES "employees" ("id");
ALTER TABLE "checks" ADD FOREIGN KEY ("split_from_check_id") REFERENCES "checks" ("id");
ALTER TABLE "check_items" ADD FOREIGN KEY ("check_id") REFERENCES "checks" ("id");
ALTER TABLE "check_items" ADD FOREIGN KEY ("menu_item_id") REFERENCES "menu_items" ("id");
ALTER TABLE "check_items" ADD FOREIGN KEY ("rung_in_by") REFERENCES "employees" ("id");
ALTER TABLE "check_item_modifiers" ADD FOREIGN KEY ("check_item_id") REFERENCES "check_items" ("id");
ALTER TABLE "check_item_modifiers" ADD FOREIGN KEY ("modifier_option_id") REFERENCES "modifier_options" ("id");
ALTER TABLE "adjustment_reasons" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "check_adjustments" ADD FOREIGN KEY ("check_id") REFERENCES "checks" ("id");
ALTER TABLE "check_adjustments" ADD FOREIGN KEY ("check_item_id") REFERENCES "check_items" ("id");
ALTER TABLE "check_adjustments" ADD FOREIGN KEY ("adjustment_reason_id") REFERENCES "adjustment_reasons" ("id");
ALTER TABLE "check_adjustments" ADD FOREIGN KEY ("requested_by") REFERENCES "employees" ("id");
ALTER TABLE "check_adjustments" ADD FOREIGN KEY ("approved_by") REFERENCES "employees" ("id");
ALTER TABLE "prep_stations" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "kitchen_tickets" ADD FOREIGN KEY ("check_id") REFERENCES "checks" ("id");
ALTER TABLE "kitchen_tickets" ADD FOREIGN KEY ("prep_station_id") REFERENCES "prep_stations" ("id");
ALTER TABLE "kitchen_tickets" ADD FOREIGN KEY ("fired_by") REFERENCES "employees" ("id");
ALTER TABLE "kitchen_ticket_items" ADD FOREIGN KEY ("kitchen_ticket_id") REFERENCES "kitchen_tickets" ("id");
ALTER TABLE "kitchen_ticket_items" ADD FOREIGN KEY ("check_item_id") REFERENCES "check_items" ("id");
ALTER TABLE "business_days" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "business_days" ADD FOREIGN KEY ("closed_by") REFERENCES "employees" ("id");
ALTER TABLE "payments" ADD FOREIGN KEY ("check_id") REFERENCES "checks" ("id");
ALTER TABLE "payments" ADD FOREIGN KEY ("business_day_id") REFERENCES "business_days" ("id");
ALTER TABLE "payments" ADD FOREIGN KEY ("employee_id") REFERENCES "employees" ("id");
ALTER TABLE "payments" ADD FOREIGN KEY ("drawer_session_id") REFERENCES "drawer_sessions" ("id");
ALTER TABLE "cash_drawers" ADD FOREIGN KEY ("location_id") REFERENCES "locations" ("id");
ALTER TABLE "drawer_sessions" ADD FOREIGN KEY ("cash_drawer_id") REFERENCES "cash_drawers" ("id");
ALTER TABLE "drawer_sessions" ADD FOREIGN KEY ("business_day_id") REFERENCES "business_days" ("id");
ALTER TABLE "drawer_sessions" ADD FOREIGN KEY ("employee_id") REFERENCES "employees" ("id");
ALTER TABLE "drawer_sessions" ADD FOREIGN KEY ("verified_by") REFERENCES "employees" ("id");
ALTER TABLE "drawer_movements" ADD FOREIGN KEY ("drawer_session_id") REFERENCES "drawer_sessions" ("id");
ALTER TABLE "drawer_movements" ADD FOREIGN KEY ("employee_id") REFERENCES "employees" ("id");
ALTER TABLE "drawer_movements" ADD FOREIGN KEY ("approved_by") REFERENCES "employees" ("id");MySQL
CREATE TABLE `locations` (
`id` uuid PRIMARY KEY,
`name` varchar(200) NOT NULL,
`address` varchar(300) NOT NULL,
`timezone` varchar(64) NOT NULL COMMENT 'IANA zone',
`currency` char(3) NOT NULL,
`business_day_rollover` time NOT NULL DEFAULT '04:00' COMMENT 'When the business date changes. A check opened at 1:30 am belongs to the previous business day.',
`tax_rate_bps` integer NOT NULL COMMENT 'Sales tax on food in basis points; alcohol may use its own rate',
`alcohol_tax_rate_bps` integer,
`is_active` boolean NOT NULL DEFAULT true
);
CREATE TABLE `dining_areas` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(100) NOT NULL COMMENT 'e.g. Main room, Patio, Bar',
`sort_order` smallint NOT NULL DEFAULT 0
);
CREATE TABLE `dining_tables` (
`id` uuid PRIMARY KEY,
`dining_area_id` uuid NOT NULL,
`label` varchar(20) NOT NULL COMMENT 'What staff call it, e.g. "12", "B4"',
`seats` smallint NOT NULL,
`shape` ENUM ('round', 'square', 'rectangle', 'booth', 'bar_seat') NOT NULL,
`pos_x` integer NOT NULL COMMENT 'Position on the floor plan screen',
`pos_y` integer NOT NULL,
`is_active` boolean NOT NULL DEFAULT true
);
CREATE TABLE `dayparts` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(60) NOT NULL COMMENT 'e.g. Breakfast, Lunch, Happy hour, Late night',
`starts_at` time NOT NULL,
`ends_at` time NOT NULL COMMENT 'Earlier than starts_at for a window that runs past midnight',
`days_mask` smallint NOT NULL DEFAULT 127 COMMENT 'Bitmask of weekdays, Monday = 1 ... Sunday = 64; 127 is every day'
);
CREATE TABLE `menu_categories` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`daypart_id` uuid COMMENT 'Null for a category sold all day',
`name` varchar(100) NOT NULL COMMENT 'e.g. Starters, Mains, Draft beer',
`button_color` char(7) COMMENT 'Hex color of the button on the order screen',
`sort_order` smallint NOT NULL DEFAULT 0
);
CREATE TABLE `menu_items` (
`id` uuid PRIMARY KEY,
`menu_category_id` uuid NOT NULL,
`prep_station_id` uuid COMMENT 'Where it is made. Null for items that need no kitchen, e.g. bottled water.',
`name` varchar(200) NOT NULL,
`kitchen_name` varchar(40) NOT NULL COMMENT 'Short form printed on tickets, e.g. "CHZ BGR"',
`price_cents` integer NOT NULL,
`tax_class` ENUM ('food', 'alcohol', 'non_taxable') NOT NULL,
`default_course` smallint NOT NULL DEFAULT 2 COMMENT '1 = starters, 2 = mains, 3 = dessert; the server can change it per line',
`is_available` boolean NOT NULL DEFAULT true COMMENT 'Switched off when the kitchen runs out (86ed)',
`sort_order` smallint NOT NULL DEFAULT 0
);
CREATE TABLE `item_daypart_prices` (
`menu_item_id` uuid NOT NULL,
`daypart_id` uuid NOT NULL,
`price_cents` integer NOT NULL,
PRIMARY KEY (`menu_item_id`, `daypart_id`)
);
CREATE TABLE `modifier_groups` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(100) NOT NULL COMMENT 'e.g. Temperature, Side, Add-ons',
`min_selections` smallint NOT NULL DEFAULT 0 COMMENT '1 or more forces a choice, e.g. a steak temperature',
`max_selections` smallint NOT NULL DEFAULT 1
);
CREATE TABLE `modifier_options` (
`id` uuid PRIMARY KEY,
`modifier_group_id` uuid NOT NULL,
`name` varchar(100) NOT NULL COMMENT 'e.g. Medium rare, Fries, No onion, Add bacon',
`price_delta_cents` integer NOT NULL DEFAULT 0,
`sort_order` smallint NOT NULL DEFAULT 0
);
CREATE TABLE `menu_item_modifier_groups` (
`menu_item_id` uuid NOT NULL,
`modifier_group_id` uuid NOT NULL,
`sort_order` smallint NOT NULL DEFAULT 0,
PRIMARY KEY (`menu_item_id`, `modifier_group_id`)
);
CREATE TABLE `ingredients` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(120) NOT NULL,
`unit` ENUM ('gram', 'milliliter', 'each') NOT NULL COMMENT 'The unit it is counted and costed in',
`cost_per_unit_cents` numeric(12,4) NOT NULL COMMENT 'Fractional cents: a gram of cheese costs less than one cent',
`par_level` numeric(12,3) COMMENT 'Target quantity on hand, for ordering'
);
CREATE TABLE `recipe_lines` (
`id` uuid PRIMARY KEY,
`ingredient_id` uuid NOT NULL,
`menu_item_id` uuid,
`modifier_option_id` uuid COMMENT 'Set instead of menu_item_id for a modifier that uses stock, e.g. Add bacon',
`quantity` numeric(12,3) NOT NULL COMMENT 'In the ingredient unit'
);
CREATE TABLE `roles` (
`id` uuid PRIMARY KEY,
`name` varchar(60) UNIQUE NOT NULL COMMENT 'e.g. Server, Bartender, Host, Line cook, Shift lead, Manager',
`default_hourly_rate_cents` integer,
`is_tipped` boolean NOT NULL DEFAULT false
);
CREATE TABLE `role_permissions` (
`role_id` uuid NOT NULL,
`permission` ENUM ('ring_items', 'transfer_check', 'reopen_check', 'void_item', 'comp_item', 'apply_discount', 'open_drawer_no_sale', 'paid_in_out', 'edit_time_punch', 'close_business_day', 'view_reports') NOT NULL,
PRIMARY KEY (`role_id`, `permission`)
);
CREATE TABLE `employees` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL COMMENT 'Home location',
`role_id` uuid NOT NULL,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`pin_hash` varchar(100) NOT NULL COMMENT 'Hash of the PIN typed at the terminal, never the PIN itself',
`hourly_rate_cents` integer NOT NULL,
`hired_on` date NOT NULL,
`terminated_on` date COMMENT 'Set instead of deleting: old checks and punches still point here'
);
CREATE TABLE `time_clock_entries` (
`id` uuid PRIMARY KEY,
`employee_id` uuid NOT NULL,
`role_id` uuid NOT NULL COMMENT 'The job worked on this shift, which sets the wage',
`business_day_id` uuid NOT NULL,
`clock_in_at` timestamptz NOT NULL,
`clock_out_at` timestamptz,
`break_minutes` smallint NOT NULL DEFAULT 0,
`hourly_rate_cents` integer NOT NULL COMMENT 'Snapshot of the wage at clock-in',
`declared_cash_tips_cents` integer COMMENT 'Cash tips declared at clock-out',
`edited_by` uuid COMMENT 'Manager who corrected a missed punch, if anyone',
`edited_at` timestamptz
);
CREATE TABLE `checks` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`business_day_id` uuid NOT NULL,
`check_number` integer NOT NULL COMMENT 'Sequential per location per business day, printed on the receipt',
`order_type` ENUM ('dine_in', 'takeout', 'delivery', 'bar_tab') NOT NULL,
`dining_table_id` uuid COMMENT 'Dine-in only',
`guest_count` smallint COMMENT 'Covers, for per-guest averages',
`server_id` uuid NOT NULL COMMENT 'Who owns the check and its tips',
`customer_name` varchar(100) COMMENT 'For takeout, delivery or a bar tab',
`customer_phone` varchar(20),
`split_from_check_id` uuid COMMENT 'Set when a check was split off another, e.g. separate checks per seat',
`status` ENUM ('open', 'closed', 'voided') NOT NULL DEFAULT 'open',
`subtotal_cents` integer NOT NULL DEFAULT 0 COMMENT 'Cached sum of the live check items',
`adjustments_cents` integer NOT NULL DEFAULT 0 COMMENT 'Cached sum of comps and discounts',
`tax_cents` integer NOT NULL DEFAULT 0,
`total_cents` integer NOT NULL DEFAULT 0,
`opened_at` timestamptz NOT NULL DEFAULT (now()),
`closed_at` timestamptz
);
CREATE TABLE `check_items` (
`id` uuid PRIMARY KEY,
`check_id` uuid NOT NULL,
`menu_item_id` uuid NOT NULL,
`item_name` varchar(200) NOT NULL COMMENT 'Snapshot at ring-in',
`unit_price_cents` integer NOT NULL COMMENT 'Snapshot, including any daypart price and the modifier deltas',
`quantity` smallint NOT NULL DEFAULT 1,
`seat_number` smallint COMMENT 'Seat at the table, for serving and for splitting by seat; null for shared plates',
`course` smallint NOT NULL COMMENT 'Fired in course order, starters before mains',
`status` ENUM ('held', 'fired', 'served', 'voided') NOT NULL DEFAULT 'held',
`special_request` varchar(200) COMMENT 'e.g. Allergy: no nuts',
`rung_in_by` uuid NOT NULL,
`rung_in_at` timestamptz NOT NULL DEFAULT (now()),
`fired_at` timestamptz COMMENT 'Sent to the kitchen. Null while held for a later course.'
);
CREATE TABLE `check_item_modifiers` (
`id` uuid PRIMARY KEY,
`check_item_id` uuid NOT NULL,
`modifier_option_id` uuid COMMENT 'For reporting and recipe depletion',
`option_name` varchar(100) NOT NULL COMMENT 'Snapshot, printed on the kitchen ticket',
`price_delta_cents` integer NOT NULL
);
CREATE TABLE `adjustment_reasons` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`kind` ENUM ('void', 'comp', 'discount') NOT NULL,
`code` varchar(30) NOT NULL COMMENT 'e.g. WRONG_ITEM, LONG_WAIT, EMPLOYEE_MEAL, SENIOR_10',
`label` varchar(100) NOT NULL,
`percent_bps` integer COMMENT 'For a percentage discount; null for an amount entered at the time',
`requires_manager` boolean NOT NULL DEFAULT true,
`is_active` boolean NOT NULL DEFAULT true
);
CREATE TABLE `check_adjustments` (
`id` uuid PRIMARY KEY,
`check_id` uuid NOT NULL,
`check_item_id` uuid COMMENT 'Null for a discount on the whole check',
`kind` ENUM ('void', 'comp', 'discount') NOT NULL,
`adjustment_reason_id` uuid NOT NULL,
`amount_cents` integer NOT NULL COMMENT 'Value taken off the check, always positive',
`after_fire` boolean NOT NULL DEFAULT false COMMENT 'A void after the kitchen fired the item is food waste, not just a correction',
`requested_by` uuid NOT NULL,
`approved_by` uuid COMMENT 'Manager who entered their PIN; required when the reason says so',
`comment` varchar(300),
`created_at` timestamptz NOT NULL DEFAULT (now())
);
CREATE TABLE `prep_stations` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(60) NOT NULL COMMENT 'e.g. Grill, Fry, Salad, Bar, Expo',
`kind` ENUM ('kitchen', 'bar', 'expo') NOT NULL,
`printer_address` varchar(100) COMMENT 'Fallback ticket printer for when the screen is down',
`target_ticket_seconds` integer COMMENT 'Ticket time goal; the screen turns a ticket red past it'
);
CREATE TABLE `kitchen_tickets` (
`id` uuid PRIMARY KEY,
`check_id` uuid NOT NULL,
`prep_station_id` uuid NOT NULL,
`course` smallint NOT NULL,
`status` ENUM ('new', 'in_progress', 'bumped', 'recalled') NOT NULL DEFAULT 'new',
`is_rush` boolean NOT NULL DEFAULT false,
`fired_by` uuid NOT NULL,
`fired_at` timestamptz NOT NULL,
`started_at` timestamptz,
`bumped_at` timestamptz COMMENT 'Marked done on the station screen',
`recalled_at` timestamptz COMMENT 'Brought back after a bump, e.g. a dish sent back'
);
CREATE TABLE `kitchen_ticket_items` (
`kitchen_ticket_id` uuid NOT NULL,
`check_item_id` uuid NOT NULL,
`quantity` smallint NOT NULL,
`is_void_notice` boolean NOT NULL DEFAULT false COMMENT 'Shown as VOID so the line stops cooking it',
PRIMARY KEY (`kitchen_ticket_id`, `check_item_id`)
);
CREATE TABLE `business_days` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`business_date` date NOT NULL COMMENT 'The trading day, which can end after midnight',
`status` ENUM ('open', 'closing', 'closed') NOT NULL DEFAULT 'open',
`opened_at` timestamptz NOT NULL,
`closed_at` timestamptz COMMENT 'End-of-day close. The day is locked after it; later corrections land in the next day.',
`closed_by` uuid,
`net_sales_cents` bigint COMMENT 'Frozen at close for the end-of-day report',
`tax_cents` bigint,
`tips_cents` bigint,
`cash_over_short_cents` integer COMMENT 'Sum of drawer variances for the day'
);
CREATE TABLE `payments` (
`id` uuid PRIMARY KEY,
`check_id` uuid NOT NULL,
`business_day_id` uuid NOT NULL,
`tender` ENUM ('cash', 'card', 'gift_card', 'house_account') NOT NULL,
`amount_cents` integer NOT NULL COMMENT 'Applied to the check, tip excluded',
`tip_cents` integer NOT NULL DEFAULT 0 COMMENT 'Card tips are usually added after the swipe, at tip adjust',
`cash_tendered_cents` integer COMMENT 'Cash handed over; change due is the difference',
`card_brand` varchar(20),
`card_last4` char(4),
`processor_reference` varchar(100) UNIQUE,
`status` ENUM ('authorized', 'captured', 'voided', 'refunded') NOT NULL DEFAULT 'authorized',
`employee_id` uuid NOT NULL COMMENT 'Who took the payment; tips and cash owed are counted from this',
`drawer_session_id` uuid COMMENT 'The drawer a cash payment went into',
`created_at` timestamptz NOT NULL DEFAULT (now())
);
CREATE TABLE `cash_drawers` (
`id` uuid PRIMARY KEY,
`location_id` uuid NOT NULL,
`name` varchar(60) NOT NULL COMMENT 'e.g. Bar 1, Front counter',
`terminal_id` varchar(60) COMMENT 'The terminal the drawer is attached to'
);
CREATE TABLE `drawer_sessions` (
`id` uuid PRIMARY KEY,
`cash_drawer_id` uuid NOT NULL,
`business_day_id` uuid NOT NULL,
`employee_id` uuid NOT NULL COMMENT 'The one person accountable for the drawer',
`opened_at` timestamptz NOT NULL,
`starting_cash_cents` integer NOT NULL COMMENT 'The counted float',
`closed_at` timestamptz,
`counted_cash_cents` integer COMMENT 'Blind count: entered without seeing the expected amount',
`expected_cash_cents` integer COMMENT 'Float plus cash payments and paid-ins, minus paid-outs and drops',
`over_short_cents` integer COMMENT 'Counted minus expected',
`verified_by` uuid COMMENT 'Manager who verified the count'
);
CREATE TABLE `drawer_movements` (
`id` uuid PRIMARY KEY,
`drawer_session_id` uuid NOT NULL,
`kind` ENUM ('safe_drop', 'paid_in', 'paid_out', 'no_sale') NOT NULL,
`amount_cents` integer NOT NULL COMMENT 'Zero for a no-sale opening',
`reason` varchar(200) NOT NULL COMMENT 'e.g. "Paid out: ice delivery", "Safe drop"',
`employee_id` uuid NOT NULL,
`approved_by` uuid,
`created_at` timestamptz NOT NULL DEFAULT (now())
);
CREATE UNIQUE INDEX `dining_tables_index_0` ON `dining_tables` (`dining_area_id`, `label`);
CREATE INDEX `one_open_punch` ON `time_clock_entries` (`employee_id`);
CREATE UNIQUE INDEX `checks_index_2` ON `checks` (`location_id`, `business_day_id`, `check_number`);
CREATE INDEX `checks_index_3` ON `checks` (`dining_table_id`, `status`);
CREATE INDEX `check_items_index_4` ON `check_items` (`check_id`, `course`);
CREATE UNIQUE INDEX `adjustment_reasons_index_5` ON `adjustment_reasons` (`location_id`, `code`);
CREATE INDEX `check_adjustments_index_6` ON `check_adjustments` (`requested_by`, `created_at`);
CREATE INDEX `kitchen_tickets_index_7` ON `kitchen_tickets` (`prep_station_id`, `status`, `fired_at`);
CREATE UNIQUE INDEX `business_days_index_8` ON `business_days` (`location_id`, `business_date`);
CREATE INDEX `one_open_session` ON `drawer_sessions` (`cash_drawer_id`);
ALTER TABLE `locations` COMMENT = 'One restaurant. Menu, floor plan, staff, kitchen stations and the cash office are all per location.';
ALTER TABLE `dining_areas` COMMENT = 'Sections of the floor plan. Servers are usually assigned a section per shift.';
ALTER TABLE `dining_tables` COMMENT = 'Tables as drawn on the host and server screens. A table shows as occupied because it has an open check, not because of a flag here.';
ALTER TABLE `dayparts` COMMENT = 'Named windows of the trading day. A category can be limited to one, and an item can carry a different price during one.';
ALTER TABLE `menu_categories` COMMENT = 'Buttons on the order screen, grouped the way servers expect to find them.';
ALTER TABLE `menu_items` COMMENT = 'Anything that can be rung in.';
ALTER TABLE `item_daypart_prices` COMMENT = 'Price overrides by daypart, e.g. half-price wings during happy hour. The price actually charged is copied onto the check item at ring-in.';
ALTER TABLE `modifier_groups` COMMENT = 'A reusable set of choices with its selection rules, so the POS prompts for exactly what the kitchen needs.';
ALTER TABLE `modifier_options` COMMENT = 'One choice within a modifier group.';
ALTER TABLE `menu_item_modifier_groups` COMMENT = 'Which modifier groups an item prompts for, in order.';
ALTER TABLE `ingredients` COMMENT = 'Raw stock in its counting unit.';
ALTER TABLE `recipe_lines` COMMENT = 'How much of each ingredient an item or a modifier uses (a check constraint keeps exactly one of the two set). Plate cost is the sum of these lines; theoretical usage for a day is sales times these quantities.';
ALTER TABLE `roles` COMMENT = 'Jobs. Permissions hang off the role, not the person, so promoting a server to shift lead is one update.';
ALTER TABLE `role_permissions` COMMENT = 'What each role may do at the terminal: void, comp, discount, reopen a check, open the drawer with no sale, close the day.';
ALTER TABLE `employees` COMMENT = 'Staff who sign in to the POS. Every check, void, comp, payment and drawer count records which employee did it.';
ALTER TABLE `time_clock_entries` COMMENT = 'Time clock punches, the source for payroll and labor cost per business day. A manager correction records who made it.';
ALTER TABLE `checks` COMMENT = 'A guest bill, the record everything else hangs off. Dine-in, takeout, delivery and bar tabs share one table, told apart by order_type.';
ALTER TABLE `check_items` COMMENT = 'One line on a check. Once a line has been sent to the kitchen it is never deleted: a void sets status voided and writes a check_adjustments row.';
ALTER TABLE `check_item_modifiers` COMMENT = 'The choices on a line, snapshotted, e.g. Medium rare, Sub salad.';
ALTER TABLE `adjustment_reasons` COMMENT = 'The fixed list of reasons staff must pick from. Free-text reasons make void and comp reports useless.';
ALTER TABLE `check_adjustments` COMMENT = 'Every void, comp and discount, with the reason, who asked and which manager approved. Append-only: never updated, never deleted. A void says the item should not count as a sale; a comp says it was sold and given away.';
ALTER TABLE `prep_stations` COMMENT = 'Kitchen display screens (and their backup printers). Every item routes to one station.';
ALTER TABLE `kitchen_tickets` COMMENT = 'One firing of one course to one station. Mains for the grill and fries for the fryer are two tickets, and ticket time per station is bumped_at minus fired_at.';
ALTER TABLE `kitchen_ticket_items` COMMENT = 'The check lines on a ticket, with their modifiers read through the check item. A void after firing goes to the same station as a new ticket flagged as a void notice, instead of silently vanishing from the screen.';
ALTER TABLE `business_days` COMMENT = 'The trading day. Checks, payments, punches and drawer sessions all belong to one, so a 1:30 am bar tab is reported with the night it belongs to.';
ALTER TABLE `payments` COMMENT = 'Each tender on a check. Splitting evenly, by seat or by amount is just several rows; the check closes when they cover the total.';
ALTER TABLE `cash_drawers` COMMENT = 'Physical cash drawers.';
ALTER TABLE `drawer_sessions` COMMENT = 'One employee accountable for one drawer for a stretch of time: the float, the blind count at close, and the variance.';
ALTER TABLE `drawer_movements` COMMENT = 'Cash in or out of a drawer that is not a sale: safe drops, paid-outs to vendors, paid-ins, and every no-sale opening, which is exactly what managers audit.';
ALTER TABLE `dining_areas` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `dining_tables` ADD FOREIGN KEY (`dining_area_id`) REFERENCES `dining_areas` (`id`);
ALTER TABLE `dayparts` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `menu_categories` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `menu_categories` ADD FOREIGN KEY (`daypart_id`) REFERENCES `dayparts` (`id`);
ALTER TABLE `menu_items` ADD FOREIGN KEY (`menu_category_id`) REFERENCES `menu_categories` (`id`);
ALTER TABLE `menu_items` ADD FOREIGN KEY (`prep_station_id`) REFERENCES `prep_stations` (`id`);
ALTER TABLE `item_daypart_prices` ADD FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`);
ALTER TABLE `item_daypart_prices` ADD FOREIGN KEY (`daypart_id`) REFERENCES `dayparts` (`id`);
ALTER TABLE `modifier_groups` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `modifier_options` ADD FOREIGN KEY (`modifier_group_id`) REFERENCES `modifier_groups` (`id`);
ALTER TABLE `menu_item_modifier_groups` ADD FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`);
ALTER TABLE `menu_item_modifier_groups` ADD FOREIGN KEY (`modifier_group_id`) REFERENCES `modifier_groups` (`id`);
ALTER TABLE `ingredients` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `recipe_lines` ADD FOREIGN KEY (`ingredient_id`) REFERENCES `ingredients` (`id`);
ALTER TABLE `recipe_lines` ADD FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`);
ALTER TABLE `recipe_lines` ADD FOREIGN KEY (`modifier_option_id`) REFERENCES `modifier_options` (`id`);
ALTER TABLE `role_permissions` ADD FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`);
ALTER TABLE `employees` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `employees` ADD FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`);
ALTER TABLE `time_clock_entries` ADD FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);
ALTER TABLE `time_clock_entries` ADD FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`);
ALTER TABLE `time_clock_entries` ADD FOREIGN KEY (`business_day_id`) REFERENCES `business_days` (`id`);
ALTER TABLE `time_clock_entries` ADD FOREIGN KEY (`edited_by`) REFERENCES `employees` (`id`);
ALTER TABLE `checks` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `checks` ADD FOREIGN KEY (`business_day_id`) REFERENCES `business_days` (`id`);
ALTER TABLE `checks` ADD FOREIGN KEY (`dining_table_id`) REFERENCES `dining_tables` (`id`);
ALTER TABLE `checks` ADD FOREIGN KEY (`server_id`) REFERENCES `employees` (`id`);
ALTER TABLE `checks` ADD FOREIGN KEY (`split_from_check_id`) REFERENCES `checks` (`id`);
ALTER TABLE `check_items` ADD FOREIGN KEY (`check_id`) REFERENCES `checks` (`id`);
ALTER TABLE `check_items` ADD FOREIGN KEY (`menu_item_id`) REFERENCES `menu_items` (`id`);
ALTER TABLE `check_items` ADD FOREIGN KEY (`rung_in_by`) REFERENCES `employees` (`id`);
ALTER TABLE `check_item_modifiers` ADD FOREIGN KEY (`check_item_id`) REFERENCES `check_items` (`id`);
ALTER TABLE `check_item_modifiers` ADD FOREIGN KEY (`modifier_option_id`) REFERENCES `modifier_options` (`id`);
ALTER TABLE `adjustment_reasons` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `check_adjustments` ADD FOREIGN KEY (`check_id`) REFERENCES `checks` (`id`);
ALTER TABLE `check_adjustments` ADD FOREIGN KEY (`check_item_id`) REFERENCES `check_items` (`id`);
ALTER TABLE `check_adjustments` ADD FOREIGN KEY (`adjustment_reason_id`) REFERENCES `adjustment_reasons` (`id`);
ALTER TABLE `check_adjustments` ADD FOREIGN KEY (`requested_by`) REFERENCES `employees` (`id`);
ALTER TABLE `check_adjustments` ADD FOREIGN KEY (`approved_by`) REFERENCES `employees` (`id`);
ALTER TABLE `prep_stations` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `kitchen_tickets` ADD FOREIGN KEY (`check_id`) REFERENCES `checks` (`id`);
ALTER TABLE `kitchen_tickets` ADD FOREIGN KEY (`prep_station_id`) REFERENCES `prep_stations` (`id`);
ALTER TABLE `kitchen_tickets` ADD FOREIGN KEY (`fired_by`) REFERENCES `employees` (`id`);
ALTER TABLE `kitchen_ticket_items` ADD FOREIGN KEY (`kitchen_ticket_id`) REFERENCES `kitchen_tickets` (`id`);
ALTER TABLE `kitchen_ticket_items` ADD FOREIGN KEY (`check_item_id`) REFERENCES `check_items` (`id`);
ALTER TABLE `business_days` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `business_days` ADD FOREIGN KEY (`closed_by`) REFERENCES `employees` (`id`);
ALTER TABLE `payments` ADD FOREIGN KEY (`check_id`) REFERENCES `checks` (`id`);
ALTER TABLE `payments` ADD FOREIGN KEY (`business_day_id`) REFERENCES `business_days` (`id`);
ALTER TABLE `payments` ADD FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);
ALTER TABLE `payments` ADD FOREIGN KEY (`drawer_session_id`) REFERENCES `drawer_sessions` (`id`);
ALTER TABLE `cash_drawers` ADD FOREIGN KEY (`location_id`) REFERENCES `locations` (`id`);
ALTER TABLE `drawer_sessions` ADD FOREIGN KEY (`cash_drawer_id`) REFERENCES `cash_drawers` (`id`);
ALTER TABLE `drawer_sessions` ADD FOREIGN KEY (`business_day_id`) REFERENCES `business_days` (`id`);
ALTER TABLE `drawer_sessions` ADD FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);
ALTER TABLE `drawer_sessions` ADD FOREIGN KEY (`verified_by`) REFERENCES `employees` (`id`);
ALTER TABLE `drawer_movements` ADD FOREIGN KEY (`drawer_session_id`) REFERENCES `drawer_sessions` (`id`);
ALTER TABLE `drawer_movements` ADD FOREIGN KEY (`employee_id`) REFERENCES `employees` (`id`);
ALTER TABLE `drawer_movements` ADD FOREIGN KEY (`approved_by`) REFERENCES `employees` (`id`);SQL Server
CREATE TABLE [locations] (
[id] uuid PRIMARY KEY,
[name] varchar(200) NOT NULL,
[address] varchar(300) NOT NULL,
[timezone] varchar(64) NOT NULL,
[currency] char(3) NOT NULL,
[business_day_rollover] time NOT NULL DEFAULT '04:00',
[tax_rate_bps] integer NOT NULL,
[alcohol_tax_rate_bps] integer,
[is_active] boolean NOT NULL DEFAULT (true)
)
GO
CREATE TABLE [dining_areas] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(100) NOT NULL,
[sort_order] smallint NOT NULL DEFAULT (0)
)
GO
CREATE TABLE [dining_tables] (
[id] uuid PRIMARY KEY,
[dining_area_id] uuid NOT NULL,
[label] varchar(20) NOT NULL,
[seats] smallint NOT NULL,
[shape] nvarchar(255) NOT NULL CHECK ([shape] IN ('round', 'square', 'rectangle', 'booth', 'bar_seat')),
[pos_x] integer NOT NULL,
[pos_y] integer NOT NULL,
[is_active] boolean NOT NULL DEFAULT (true)
)
GO
CREATE TABLE [dayparts] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(60) NOT NULL,
[starts_at] time NOT NULL,
[ends_at] time NOT NULL,
[days_mask] smallint NOT NULL DEFAULT (127)
)
GO
CREATE TABLE [menu_categories] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[daypart_id] uuid,
[name] varchar(100) NOT NULL,
[button_color] char(7),
[sort_order] smallint NOT NULL DEFAULT (0)
)
GO
CREATE TABLE [menu_items] (
[id] uuid PRIMARY KEY,
[menu_category_id] uuid NOT NULL,
[prep_station_id] uuid,
[name] varchar(200) NOT NULL,
[kitchen_name] varchar(40) NOT NULL,
[price_cents] integer NOT NULL,
[tax_class] nvarchar(255) NOT NULL CHECK ([tax_class] IN ('food', 'alcohol', 'non_taxable')),
[default_course] smallint NOT NULL DEFAULT (2),
[is_available] boolean NOT NULL DEFAULT (true),
[sort_order] smallint NOT NULL DEFAULT (0)
)
GO
CREATE TABLE [item_daypart_prices] (
[menu_item_id] uuid NOT NULL,
[daypart_id] uuid NOT NULL,
[price_cents] integer NOT NULL,
PRIMARY KEY ([menu_item_id], [daypart_id])
)
GO
CREATE TABLE [modifier_groups] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(100) NOT NULL,
[min_selections] smallint NOT NULL DEFAULT (0),
[max_selections] smallint NOT NULL DEFAULT (1)
)
GO
CREATE TABLE [modifier_options] (
[id] uuid PRIMARY KEY,
[modifier_group_id] uuid NOT NULL,
[name] varchar(100) NOT NULL,
[price_delta_cents] integer NOT NULL DEFAULT (0),
[sort_order] smallint NOT NULL DEFAULT (0)
)
GO
CREATE TABLE [menu_item_modifier_groups] (
[menu_item_id] uuid NOT NULL,
[modifier_group_id] uuid NOT NULL,
[sort_order] smallint NOT NULL DEFAULT (0),
PRIMARY KEY ([menu_item_id], [modifier_group_id])
)
GO
CREATE TABLE [ingredients] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(120) NOT NULL,
[unit] nvarchar(255) NOT NULL CHECK ([unit] IN ('gram', 'milliliter', 'each')),
[cost_per_unit_cents] numeric(12,4) NOT NULL,
[par_level] numeric(12,3)
)
GO
CREATE TABLE [recipe_lines] (
[id] uuid PRIMARY KEY,
[ingredient_id] uuid NOT NULL,
[menu_item_id] uuid,
[modifier_option_id] uuid,
[quantity] numeric(12,3) NOT NULL
)
GO
CREATE TABLE [roles] (
[id] uuid PRIMARY KEY,
[name] varchar(60) UNIQUE NOT NULL,
[default_hourly_rate_cents] integer,
[is_tipped] boolean NOT NULL DEFAULT (false)
)
GO
CREATE TABLE [role_permissions] (
[role_id] uuid NOT NULL,
[permission] nvarchar(255) NOT NULL CHECK ([permission] IN ('ring_items', 'transfer_check', 'reopen_check', 'void_item', 'comp_item', 'apply_discount', 'open_drawer_no_sale', 'paid_in_out', 'edit_time_punch', 'close_business_day', 'view_reports')),
PRIMARY KEY ([role_id], [permission])
)
GO
CREATE TABLE [employees] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[role_id] uuid NOT NULL,
[first_name] varchar(100) NOT NULL,
[last_name] varchar(100) NOT NULL,
[pin_hash] varchar(100) NOT NULL,
[hourly_rate_cents] integer NOT NULL,
[hired_on] date NOT NULL,
[terminated_on] date
)
GO
CREATE TABLE [time_clock_entries] (
[id] uuid PRIMARY KEY,
[employee_id] uuid NOT NULL,
[role_id] uuid NOT NULL,
[business_day_id] uuid NOT NULL,
[clock_in_at] timestamptz NOT NULL,
[clock_out_at] timestamptz,
[break_minutes] smallint NOT NULL DEFAULT (0),
[hourly_rate_cents] integer NOT NULL,
[declared_cash_tips_cents] integer,
[edited_by] uuid,
[edited_at] timestamptz
)
GO
CREATE TABLE [checks] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[business_day_id] uuid NOT NULL,
[check_number] integer NOT NULL,
[order_type] nvarchar(255) NOT NULL CHECK ([order_type] IN ('dine_in', 'takeout', 'delivery', 'bar_tab')),
[dining_table_id] uuid,
[guest_count] smallint,
[server_id] uuid NOT NULL,
[customer_name] varchar(100),
[customer_phone] varchar(20),
[split_from_check_id] uuid,
[status] nvarchar(255) NOT NULL CHECK ([status] IN ('open', 'closed', 'voided')) DEFAULT 'open',
[subtotal_cents] integer NOT NULL DEFAULT (0),
[adjustments_cents] integer NOT NULL DEFAULT (0),
[tax_cents] integer NOT NULL DEFAULT (0),
[total_cents] integer NOT NULL DEFAULT (0),
[opened_at] timestamptz NOT NULL DEFAULT (now()),
[closed_at] timestamptz
)
GO
CREATE TABLE [check_items] (
[id] uuid PRIMARY KEY,
[check_id] uuid NOT NULL,
[menu_item_id] uuid NOT NULL,
[item_name] varchar(200) NOT NULL,
[unit_price_cents] integer NOT NULL,
[quantity] smallint NOT NULL DEFAULT (1),
[seat_number] smallint,
[course] smallint NOT NULL,
[status] nvarchar(255) NOT NULL CHECK ([status] IN ('held', 'fired', 'served', 'voided')) DEFAULT 'held',
[special_request] varchar(200),
[rung_in_by] uuid NOT NULL,
[rung_in_at] timestamptz NOT NULL DEFAULT (now()),
[fired_at] timestamptz
)
GO
CREATE TABLE [check_item_modifiers] (
[id] uuid PRIMARY KEY,
[check_item_id] uuid NOT NULL,
[modifier_option_id] uuid,
[option_name] varchar(100) NOT NULL,
[price_delta_cents] integer NOT NULL
)
GO
CREATE TABLE [adjustment_reasons] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('void', 'comp', 'discount')),
[code] varchar(30) NOT NULL,
[label] varchar(100) NOT NULL,
[percent_bps] integer,
[requires_manager] boolean NOT NULL DEFAULT (true),
[is_active] boolean NOT NULL DEFAULT (true)
)
GO
CREATE TABLE [check_adjustments] (
[id] uuid PRIMARY KEY,
[check_id] uuid NOT NULL,
[check_item_id] uuid,
[kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('void', 'comp', 'discount')),
[adjustment_reason_id] uuid NOT NULL,
[amount_cents] integer NOT NULL,
[after_fire] boolean NOT NULL DEFAULT (false),
[requested_by] uuid NOT NULL,
[approved_by] uuid,
[comment] varchar(300),
[created_at] timestamptz NOT NULL DEFAULT (now())
)
GO
CREATE TABLE [prep_stations] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(60) NOT NULL,
[kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('kitchen', 'bar', 'expo')),
[printer_address] varchar(100),
[target_ticket_seconds] integer
)
GO
CREATE TABLE [kitchen_tickets] (
[id] uuid PRIMARY KEY,
[check_id] uuid NOT NULL,
[prep_station_id] uuid NOT NULL,
[course] smallint NOT NULL,
[status] nvarchar(255) NOT NULL CHECK ([status] IN ('new', 'in_progress', 'bumped', 'recalled')) DEFAULT 'new',
[is_rush] boolean NOT NULL DEFAULT (false),
[fired_by] uuid NOT NULL,
[fired_at] timestamptz NOT NULL,
[started_at] timestamptz,
[bumped_at] timestamptz,
[recalled_at] timestamptz
)
GO
CREATE TABLE [kitchen_ticket_items] (
[kitchen_ticket_id] uuid NOT NULL,
[check_item_id] uuid NOT NULL,
[quantity] smallint NOT NULL,
[is_void_notice] boolean NOT NULL DEFAULT (false),
PRIMARY KEY ([kitchen_ticket_id], [check_item_id])
)
GO
CREATE TABLE [business_days] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[business_date] date NOT NULL,
[status] nvarchar(255) NOT NULL CHECK ([status] IN ('open', 'closing', 'closed')) DEFAULT 'open',
[opened_at] timestamptz NOT NULL,
[closed_at] timestamptz,
[closed_by] uuid,
[net_sales_cents] bigint,
[tax_cents] bigint,
[tips_cents] bigint,
[cash_over_short_cents] integer
)
GO
CREATE TABLE [payments] (
[id] uuid PRIMARY KEY,
[check_id] uuid NOT NULL,
[business_day_id] uuid NOT NULL,
[tender] nvarchar(255) NOT NULL CHECK ([tender] IN ('cash', 'card', 'gift_card', 'house_account')),
[amount_cents] integer NOT NULL,
[tip_cents] integer NOT NULL DEFAULT (0),
[cash_tendered_cents] integer,
[card_brand] varchar(20),
[card_last4] char(4),
[processor_reference] varchar(100) UNIQUE,
[status] nvarchar(255) NOT NULL CHECK ([status] IN ('authorized', 'captured', 'voided', 'refunded')) DEFAULT 'authorized',
[employee_id] uuid NOT NULL,
[drawer_session_id] uuid,
[created_at] timestamptz NOT NULL DEFAULT (now())
)
GO
CREATE TABLE [cash_drawers] (
[id] uuid PRIMARY KEY,
[location_id] uuid NOT NULL,
[name] varchar(60) NOT NULL,
[terminal_id] varchar(60)
)
GO
CREATE TABLE [drawer_sessions] (
[id] uuid PRIMARY KEY,
[cash_drawer_id] uuid NOT NULL,
[business_day_id] uuid NOT NULL,
[employee_id] uuid NOT NULL,
[opened_at] timestamptz NOT NULL,
[starting_cash_cents] integer NOT NULL,
[closed_at] timestamptz,
[counted_cash_cents] integer,
[expected_cash_cents] integer,
[over_short_cents] integer,
[verified_by] uuid
)
GO
CREATE TABLE [drawer_movements] (
[id] uuid PRIMARY KEY,
[drawer_session_id] uuid NOT NULL,
[kind] nvarchar(255) NOT NULL CHECK ([kind] IN ('safe_drop', 'paid_in', 'paid_out', 'no_sale')),
[amount_cents] integer NOT NULL,
[reason] varchar(200) NOT NULL,
[employee_id] uuid NOT NULL,
[approved_by] uuid,
[created_at] timestamptz NOT NULL DEFAULT (now())
)
GO
CREATE UNIQUE INDEX [dining_tables_index_0] ON [dining_tables] ("dining_area_id", "label")
GO
CREATE INDEX [one_open_punch] ON [time_clock_entries] ("employee_id")
GO
CREATE UNIQUE INDEX [checks_index_2] ON [checks] ("location_id", "business_day_id", "check_number")
GO
CREATE INDEX [checks_index_3] ON [checks] ("dining_table_id", "status")
GO
CREATE INDEX [check_items_index_4] ON [check_items] ("check_id", "course")
GO
CREATE UNIQUE INDEX [adjustment_reasons_index_5] ON [adjustment_reasons] ("location_id", "code")
GO
CREATE INDEX [check_adjustments_index_6] ON [check_adjustments] ("requested_by", "created_at")
GO
CREATE INDEX [kitchen_tickets_index_7] ON [kitchen_tickets] ("prep_station_id", "status", "fired_at")
GO
CREATE UNIQUE INDEX [business_days_index_8] ON [business_days] ("location_id", "business_date")
GO
CREATE INDEX [one_open_session] ON [drawer_sessions] ("cash_drawer_id")
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One restaurant. Menu, floor plan, staff, kitchen stations and the cash office are all per location.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'locations';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'IANA zone',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'locations',
@level2type = N'Column', @level2name = 'timezone';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'When the business date changes. A check opened at 1:30 am belongs to the previous business day.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'locations',
@level2type = N'Column', @level2name = 'business_day_rollover';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Sales tax on food in basis points; alcohol may use its own rate',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'locations',
@level2type = N'Column', @level2name = 'tax_rate_bps';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Sections of the floor plan. Servers are usually assigned a section per shift.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dining_areas';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Main room, Patio, Bar',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dining_areas',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Tables as drawn on the host and server screens. A table shows as occupied because it has an open check, not because of a flag here.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dining_tables';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'What staff call it, e.g. "12", "B4"',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dining_tables',
@level2type = N'Column', @level2name = 'label';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Position on the floor plan screen',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dining_tables',
@level2type = N'Column', @level2name = 'pos_x';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Named windows of the trading day. A category can be limited to one, and an item can carry a different price during one.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dayparts';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Breakfast, Lunch, Happy hour, Late night',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dayparts',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Earlier than starts_at for a window that runs past midnight',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dayparts',
@level2type = N'Column', @level2name = 'ends_at';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Bitmask of weekdays, Monday = 1 ... Sunday = 64; 127 is every day',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'dayparts',
@level2type = N'Column', @level2name = 'days_mask';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Buttons on the order screen, grouped the way servers expect to find them.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_categories';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for a category sold all day',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_categories',
@level2type = N'Column', @level2name = 'daypart_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Starters, Mains, Draft beer',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_categories',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Hex color of the button on the order screen',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_categories',
@level2type = N'Column', @level2name = 'button_color';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Anything that can be rung in.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_items';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Where it is made. Null for items that need no kitchen, e.g. bottled water.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_items',
@level2type = N'Column', @level2name = 'prep_station_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Short form printed on tickets, e.g. "CHZ BGR"',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_items',
@level2type = N'Column', @level2name = 'kitchen_name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = '1 = starters, 2 = mains, 3 = dessert; the server can change it per line',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_items',
@level2type = N'Column', @level2name = 'default_course';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Switched off when the kitchen runs out (86ed)',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_items',
@level2type = N'Column', @level2name = 'is_available';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Price overrides by daypart, e.g. half-price wings during happy hour. The price actually charged is copied onto the check item at ring-in.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'item_daypart_prices';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'A reusable set of choices with its selection rules, so the POS prompts for exactly what the kitchen needs.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'modifier_groups';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Temperature, Side, Add-ons',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'modifier_groups',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = '1 or more forces a choice, e.g. a steak temperature',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'modifier_groups',
@level2type = N'Column', @level2name = 'min_selections';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One choice within a modifier group.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'modifier_options';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Medium rare, Fries, No onion, Add bacon',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'modifier_options',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Which modifier groups an item prompts for, in order.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'menu_item_modifier_groups';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Raw stock in its counting unit.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'ingredients';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The unit it is counted and costed in',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'ingredients',
@level2type = N'Column', @level2name = 'unit';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Fractional cents: a gram of cheese costs less than one cent',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'ingredients',
@level2type = N'Column', @level2name = 'cost_per_unit_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Target quantity on hand, for ordering',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'ingredients',
@level2type = N'Column', @level2name = 'par_level';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'How much of each ingredient an item or a modifier uses (a check constraint keeps exactly one of the two set). Plate cost is the sum of these lines; theoretical usage for a day is sales times these quantities.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'recipe_lines';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Set instead of menu_item_id for a modifier that uses stock, e.g. Add bacon',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'recipe_lines',
@level2type = N'Column', @level2name = 'modifier_option_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'In the ingredient unit',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'recipe_lines',
@level2type = N'Column', @level2name = 'quantity';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Jobs. Permissions hang off the role, not the person, so promoting a server to shift lead is one update.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'roles';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Server, Bartender, Host, Line cook, Shift lead, Manager',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'roles',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'What each role may do at the terminal: void, comp, discount, reopen a check, open the drawer with no sale, close the day.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'role_permissions';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Staff who sign in to the POS. Every check, void, comp, payment and drawer count records which employee did it.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'employees';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Home location',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'employees',
@level2type = N'Column', @level2name = 'location_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Hash of the PIN typed at the terminal, never the PIN itself',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'employees',
@level2type = N'Column', @level2name = 'pin_hash';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Set instead of deleting: old checks and punches still point here',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'employees',
@level2type = N'Column', @level2name = 'terminated_on';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Time clock punches, the source for payroll and labor cost per business day. A manager correction records who made it.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'time_clock_entries';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The job worked on this shift, which sets the wage',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'time_clock_entries',
@level2type = N'Column', @level2name = 'role_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Snapshot of the wage at clock-in',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'time_clock_entries',
@level2type = N'Column', @level2name = 'hourly_rate_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Cash tips declared at clock-out',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'time_clock_entries',
@level2type = N'Column', @level2name = 'declared_cash_tips_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Manager who corrected a missed punch, if anyone',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'time_clock_entries',
@level2type = N'Column', @level2name = 'edited_by';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'A guest bill, the record everything else hangs off. Dine-in, takeout, delivery and bar tabs share one table, told apart by order_type.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Sequential per location per business day, printed on the receipt',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'check_number';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Dine-in only',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'dining_table_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Covers, for per-guest averages',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'guest_count';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Who owns the check and its tips',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'server_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'For takeout, delivery or a bar tab',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'customer_name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Set when a check was split off another, e.g. separate checks per seat',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'split_from_check_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Cached sum of the live check items',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'subtotal_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Cached sum of comps and discounts',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'checks',
@level2type = N'Column', @level2name = 'adjustments_cents';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One line on a check. Once a line has been sent to the kitchen it is never deleted: a void sets status voided and writes a check_adjustments row.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Snapshot at ring-in',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'item_name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Snapshot, including any daypart price and the modifier deltas',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'unit_price_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Seat at the table, for serving and for splitting by seat; null for shared plates',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'seat_number';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Fired in course order, starters before mains',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'course';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Allergy: no nuts',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'special_request';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Sent to the kitchen. Null while held for a later course.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_items',
@level2type = N'Column', @level2name = 'fired_at';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The choices on a line, snapshotted, e.g. Medium rare, Sub salad.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_item_modifiers';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'For reporting and recipe depletion',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_item_modifiers',
@level2type = N'Column', @level2name = 'modifier_option_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Snapshot, printed on the kitchen ticket',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_item_modifiers',
@level2type = N'Column', @level2name = 'option_name';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The fixed list of reasons staff must pick from. Free-text reasons make void and comp reports useless.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'adjustment_reasons';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. WRONG_ITEM, LONG_WAIT, EMPLOYEE_MEAL, SENIOR_10',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'adjustment_reasons',
@level2type = N'Column', @level2name = 'code';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'For a percentage discount; null for an amount entered at the time',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'adjustment_reasons',
@level2type = N'Column', @level2name = 'percent_bps';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Every void, comp and discount, with the reason, who asked and which manager approved. Append-only: never updated, never deleted. A void says the item should not count as a sale; a comp says it was sold and given away.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_adjustments';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Null for a discount on the whole check',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_adjustments',
@level2type = N'Column', @level2name = 'check_item_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Value taken off the check, always positive',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_adjustments',
@level2type = N'Column', @level2name = 'amount_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'A void after the kitchen fired the item is food waste, not just a correction',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_adjustments',
@level2type = N'Column', @level2name = 'after_fire';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Manager who entered their PIN; required when the reason says so',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'check_adjustments',
@level2type = N'Column', @level2name = 'approved_by';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Kitchen display screens (and their backup printers). Every item routes to one station.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'prep_stations';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Grill, Fry, Salad, Bar, Expo',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'prep_stations',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Fallback ticket printer for when the screen is down',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'prep_stations',
@level2type = N'Column', @level2name = 'printer_address';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Ticket time goal; the screen turns a ticket red past it',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'prep_stations',
@level2type = N'Column', @level2name = 'target_ticket_seconds';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One firing of one course to one station. Mains for the grill and fries for the fryer are two tickets, and ticket time per station is bumped_at minus fired_at.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'kitchen_tickets';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Marked done on the station screen',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'kitchen_tickets',
@level2type = N'Column', @level2name = 'bumped_at';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Brought back after a bump, e.g. a dish sent back',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'kitchen_tickets',
@level2type = N'Column', @level2name = 'recalled_at';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The check lines on a ticket, with their modifiers read through the check item. A void after firing goes to the same station as a new ticket flagged as a void notice, instead of silently vanishing from the screen.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'kitchen_ticket_items';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Shown as VOID so the line stops cooking it',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'kitchen_ticket_items',
@level2type = N'Column', @level2name = 'is_void_notice';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'The trading day. Checks, payments, punches and drawer sessions all belong to one, so a 1:30 am bar tab is reported with the night it belongs to.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'business_days';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The trading day, which can end after midnight',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'business_days',
@level2type = N'Column', @level2name = 'business_date';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'End-of-day close. The day is locked after it; later corrections land in the next day.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'business_days',
@level2type = N'Column', @level2name = 'closed_at';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Frozen at close for the end-of-day report',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'business_days',
@level2type = N'Column', @level2name = 'net_sales_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Sum of drawer variances for the day',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'business_days',
@level2type = N'Column', @level2name = 'cash_over_short_cents';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Each tender on a check. Splitting evenly, by seat or by amount is just several rows; the check closes when they cover the total.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Applied to the check, tip excluded',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments',
@level2type = N'Column', @level2name = 'amount_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Card tips are usually added after the swipe, at tip adjust',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments',
@level2type = N'Column', @level2name = 'tip_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Cash handed over; change due is the difference',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments',
@level2type = N'Column', @level2name = 'cash_tendered_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Who took the payment; tips and cash owed are counted from this',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments',
@level2type = N'Column', @level2name = 'employee_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The drawer a cash payment went into',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'payments',
@level2type = N'Column', @level2name = 'drawer_session_id';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Physical cash drawers.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'cash_drawers';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. Bar 1, Front counter',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'cash_drawers',
@level2type = N'Column', @level2name = 'name';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The terminal the drawer is attached to',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'cash_drawers',
@level2type = N'Column', @level2name = 'terminal_id';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'One employee accountable for one drawer for a stretch of time: the float, the blind count at close, and the variance.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The one person accountable for the drawer',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'employee_id';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'The counted float',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'starting_cash_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Blind count: entered without seeing the expected amount',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'counted_cash_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Float plus cash payments and paid-ins, minus paid-outs and drops',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'expected_cash_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Counted minus expected',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'over_short_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Manager who verified the count',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_sessions',
@level2type = N'Column', @level2name = 'verified_by';
GO
EXEC sp_addextendedproperty
@name = N'Table_Description',
@value = 'Cash in or out of a drawer that is not a sale: safe drops, paid-outs to vendors, paid-ins, and every no-sale opening, which is exactly what managers audit.',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_movements';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'Zero for a no-sale opening',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_movements',
@level2type = N'Column', @level2name = 'amount_cents';
GO
EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'e.g. "Paid out: ice delivery", "Safe drop"',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'drawer_movements',
@level2type = N'Column', @level2name = 'reason';
GO
ALTER TABLE [dining_areas] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [dining_tables] ADD FOREIGN KEY ([dining_area_id]) REFERENCES [dining_areas] ([id])
GO
ALTER TABLE [dayparts] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [menu_categories] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [menu_categories] ADD FOREIGN KEY ([daypart_id]) REFERENCES [dayparts] ([id])
GO
ALTER TABLE [menu_items] ADD FOREIGN KEY ([menu_category_id]) REFERENCES [menu_categories] ([id])
GO
ALTER TABLE [menu_items] ADD FOREIGN KEY ([prep_station_id]) REFERENCES [prep_stations] ([id])
GO
ALTER TABLE [item_daypart_prices] ADD FOREIGN KEY ([menu_item_id]) REFERENCES [menu_items] ([id])
GO
ALTER TABLE [item_daypart_prices] ADD FOREIGN KEY ([daypart_id]) REFERENCES [dayparts] ([id])
GO
ALTER TABLE [modifier_groups] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [modifier_options] ADD FOREIGN KEY ([modifier_group_id]) REFERENCES [modifier_groups] ([id])
GO
ALTER TABLE [menu_item_modifier_groups] ADD FOREIGN KEY ([menu_item_id]) REFERENCES [menu_items] ([id])
GO
ALTER TABLE [menu_item_modifier_groups] ADD FOREIGN KEY ([modifier_group_id]) REFERENCES [modifier_groups] ([id])
GO
ALTER TABLE [ingredients] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [recipe_lines] ADD FOREIGN KEY ([ingredient_id]) REFERENCES [ingredients] ([id])
GO
ALTER TABLE [recipe_lines] ADD FOREIGN KEY ([menu_item_id]) REFERENCES [menu_items] ([id])
GO
ALTER TABLE [recipe_lines] ADD FOREIGN KEY ([modifier_option_id]) REFERENCES [modifier_options] ([id])
GO
ALTER TABLE [role_permissions] ADD FOREIGN KEY ([role_id]) REFERENCES [roles] ([id])
GO
ALTER TABLE [employees] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [employees] ADD FOREIGN KEY ([role_id]) REFERENCES [roles] ([id])
GO
ALTER TABLE [time_clock_entries] ADD FOREIGN KEY ([employee_id]) REFERENCES [employees] ([id])
GO
ALTER TABLE [time_clock_entries] ADD FOREIGN KEY ([role_id]) REFERENCES [roles] ([id])
GO
ALTER TABLE [time_clock_entries] ADD FOREIGN KEY ([business_day_id]) REFERENCES [business_days] ([id])
GO
ALTER TABLE [time_clock_entries] ADD FOREIGN KEY ([edited_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [checks] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [checks] ADD FOREIGN KEY ([business_day_id]) REFERENCES [business_days] ([id])
GO
ALTER TABLE [checks] ADD FOREIGN KEY ([dining_table_id]) REFERENCES [dining_tables] ([id])
GO
ALTER TABLE [checks] ADD FOREIGN KEY ([server_id]) REFERENCES [employees] ([id])
GO
ALTER TABLE [checks] ADD FOREIGN KEY ([split_from_check_id]) REFERENCES [checks] ([id])
GO
ALTER TABLE [check_items] ADD FOREIGN KEY ([check_id]) REFERENCES [checks] ([id])
GO
ALTER TABLE [check_items] ADD FOREIGN KEY ([menu_item_id]) REFERENCES [menu_items] ([id])
GO
ALTER TABLE [check_items] ADD FOREIGN KEY ([rung_in_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [check_item_modifiers] ADD FOREIGN KEY ([check_item_id]) REFERENCES [check_items] ([id])
GO
ALTER TABLE [check_item_modifiers] ADD FOREIGN KEY ([modifier_option_id]) REFERENCES [modifier_options] ([id])
GO
ALTER TABLE [adjustment_reasons] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [check_adjustments] ADD FOREIGN KEY ([check_id]) REFERENCES [checks] ([id])
GO
ALTER TABLE [check_adjustments] ADD FOREIGN KEY ([check_item_id]) REFERENCES [check_items] ([id])
GO
ALTER TABLE [check_adjustments] ADD FOREIGN KEY ([adjustment_reason_id]) REFERENCES [adjustment_reasons] ([id])
GO
ALTER TABLE [check_adjustments] ADD FOREIGN KEY ([requested_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [check_adjustments] ADD FOREIGN KEY ([approved_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [prep_stations] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [kitchen_tickets] ADD FOREIGN KEY ([check_id]) REFERENCES [checks] ([id])
GO
ALTER TABLE [kitchen_tickets] ADD FOREIGN KEY ([prep_station_id]) REFERENCES [prep_stations] ([id])
GO
ALTER TABLE [kitchen_tickets] ADD FOREIGN KEY ([fired_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [kitchen_ticket_items] ADD FOREIGN KEY ([kitchen_ticket_id]) REFERENCES [kitchen_tickets] ([id])
GO
ALTER TABLE [kitchen_ticket_items] ADD FOREIGN KEY ([check_item_id]) REFERENCES [check_items] ([id])
GO
ALTER TABLE [business_days] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [business_days] ADD FOREIGN KEY ([closed_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [payments] ADD FOREIGN KEY ([check_id]) REFERENCES [checks] ([id])
GO
ALTER TABLE [payments] ADD FOREIGN KEY ([business_day_id]) REFERENCES [business_days] ([id])
GO
ALTER TABLE [payments] ADD FOREIGN KEY ([employee_id]) REFERENCES [employees] ([id])
GO
ALTER TABLE [payments] ADD FOREIGN KEY ([drawer_session_id]) REFERENCES [drawer_sessions] ([id])
GO
ALTER TABLE [cash_drawers] ADD FOREIGN KEY ([location_id]) REFERENCES [locations] ([id])
GO
ALTER TABLE [drawer_sessions] ADD FOREIGN KEY ([cash_drawer_id]) REFERENCES [cash_drawers] ([id])
GO
ALTER TABLE [drawer_sessions] ADD FOREIGN KEY ([business_day_id]) REFERENCES [business_days] ([id])
GO
ALTER TABLE [drawer_sessions] ADD FOREIGN KEY ([employee_id]) REFERENCES [employees] ([id])
GO
ALTER TABLE [drawer_sessions] ADD FOREIGN KEY ([verified_by]) REFERENCES [employees] ([id])
GO
ALTER TABLE [drawer_movements] ADD FOREIGN KEY ([drawer_session_id]) REFERENCES [drawer_sessions] ([id])
GO
ALTER TABLE [drawer_movements] ADD FOREIGN KEY ([employee_id]) REFERENCES [employees] ([id])
GO
ALTER TABLE [drawer_movements] ADD FOREIGN KEY ([approved_by]) REFERENCES [employees] ([id])
GOHow to use this template
- Open the ER diagram to see the tables and how they relate.
- Copy it into your workspace. You get your own editable copy, in DBML.
- Export it as PostgreSQL, MySQL, or SQL Server DDL, or as Prisma, Drizzle, SQLAlchemy, TypeScript, Zod or C# models.
The copy opens in DB Planner’s ER diagram tool, with the schema as text in the DBML editor beside it. Have a database already? Turn its SQL into an ER diagram instead.
Frequently asked questions
- Which table is at the centre of the Restaurant Ordering and POS database schema?
- locations. It is referenced by 11 other tables: adjustment_reasons, business_days, cash_drawers, checks, dayparts and 6 more.
- How is adjustment_reasons related to locations?
- adjustment_reasons.location_id references locations.id, a many to one relationship. All 60 relationships in the schema are listed on this page.
- Which table in the Restaurant Ordering and POS database schema has the most columns?
- checks, with 18 columns, followed by payments (14) and check_items (13). The schema has 220 columns across 29 tables.
- Can I export it to PostgreSQL or MySQL?
- Yes. Every DB Planner template exports as DBML, as PostgreSQL, MySQL, or SQL Server DDL, and as C# models.
- Is this template free?
- Yes. You can open it in the browser without an account, and copy it into your own workspace with a free DB Planner account.
- Can I change it after copying it?
- Yes. A copy is yours: you can rename tables, add columns, and export it. Changes the author makes later do not affect your copy.