# curated.kitchen_orders

## Purpose

This table is the kitchen-facing order header surface used by monitors, APIs, and operational warehouse reads. Each row represents one kitchen order and carries the high-level facts needed to analyze volume, throughput, and order mix.

It is the parent surface for `curated.kitchen_order_items` and the primary entry point for kitchen order trend analysis.

## Schema contract

The deployed SQL under `backend/Kds.Ai.Warehouse/Sql/Bootstrap/Tenant/Curated/` is the source of truth for the current column names, types, and nullability.

## Column groups

- Business properties describe the business entity, event, fact, or reference record represented by the table.
- Technical and ETL properties describe warehouse lineage, surrogate keys, source reconciliation, tenant scoping, slowly changing dimension controls, and ingestion metadata.

## Business properties

| Column | Type | Nullable | Business Meaning | Notes |
|---|---|---|---|---|
| `guid` | `VARCHAR(36)` | No | Unique identifier of the kitchen order row. |  |
| `store_guid` | `VARCHAR(36)` | No | Tenant store or location identifier for the order. |  |
| `destination` | `VARCHAR(255)` | Yes | Kitchen station, queue, or operational destination label. |  |
| `is_priority` | `SMALLINT` | No | Priority flag used by kitchen workflow and anomaly detection. |  |
| `items_count` | `INTEGER` | No | Number of items attached to the order. |  |
| `order_type` | `VARCHAR(199)` | Yes | Business order type such as dine-in, takeout, or delivery. |  |
| `pos_terminal` | `VARCHAR(199)` | Yes | POS terminal that created or owns the order. |  |
| `preparation_time` | `INTEGER` | Yes | Total order preparation duration. |  |
| `done` | `SMALLINT` | No | Completion flag indicating whether the order is finished. |  |
| `create_time` | `INTEGER` | No | Canonical creation timestamp used for time-window analysis. |  |
| `is_deleted` | `SMALLINT` | No | Soft-delete flag for downstream filtering. |  |
| `external_id` | `VARCHAR(199)` | No | External source identifier for the order. |  |
| `guest_table` | `VARCHAR(199)` | Yes | Dining table label or guest location marker. |  |
| `update_time` | `INTEGER` | No | Canonical last update timestamp for the order. |  |
| `phone` | `VARCHAR(65535)` | Yes | Customer phone captured on the order when available. |  |
| `create_local_time` | `INTEGER` | Yes | Local-time mirror of order creation time. |  |
| `customer_guid` | `VARCHAR(36)` | Yes | Reference to a customer entity when one exists. |  |
| `smart_order_start_time` | `INTEGER` | Yes | Legacy smart-order scheduling or workflow start timestamp. |  |
| `order_messages` | `VARCHAR(255)` | No | Short order-level message or instructions summary. |  |
| `customer_name` | `VARCHAR(60)` | Yes | Customer-facing name attached to the order. |  |
| `seat` | `INTEGER` | Yes | Seat number within a party when tracked. |  |
| `order_status` | `INTEGER` | Yes | Numeric order status code from the source contract. |  |
| `store_name` | `VARCHAR(255)` | Yes | Readable store name associated with the kitchen order. |  |
| `pos_terminal_name` | `VARCHAR(255)` | Yes | Readable terminal or channel name that created the order. |  |
| `order_status_name` | `VARCHAR(100)` | Yes | Readable business label for the order status. |  |
| `service_channel` | `VARCHAR(100)` | Yes | Standardized business channel such as dine-in, takeout, drive-thru, or delivery. |  |
| `business_date` | `DATE` | Yes | Business date associated with the kitchen order in curated logic. |  |
| `create_time_utc` | `TIMESTAMP` | Yes | UTC timestamp when the kitchen order was created in canonical warehouse time. |  |
| `timezone_name` | `VARCHAR(100)` | Yes | Canonical IANA or business-standard time zone name used to interpret local kitchen timestamps. |  |

## Technical and ETL properties

| Column | Type | Nullable | Technical Meaning | Notes |
|---|---|---|---|---|
| `kitchen_order_key` | `BIGINT` | Yes | Stable warehouse key for the kitchen order entity. |  |
| `source_system` | `VARCHAR(100)` | Yes | Canonical name of the source platform that produced the kitchen order row. |  |
| `source_order_id` | `VARCHAR(199)` | Yes | Original kitchen or POS order identifier from the source platform. |  |
| `tenant_key` | `BIGINT` | Yes | Stable warehouse key for the tenant, brand, or client that owns the kitchen order. |  |
| `tenant_name` | `VARCHAR(255)` | Yes | Readable tenant, brand, or client name associated with the kitchen order. |  |
| `_etl_batch_id` | `VARCHAR(256)` | Yes | ETL batch lineage identifier. |  |
| `_etl_source_type` | `VARCHAR(100)` | Yes | Source adapter type used by ETL. |  |
| `_etl_ingested_at` | `TIMESTAMP` | No | Warehouse ingestion timestamp for the curated row. | Required ingestion audit timestamp. |
