# ZYchatBI Project Information

## 6. Example Queries (for reference, not to be directly used by LLM)
- Get total sales for last week:
  ```sql
  SELECT SUM(sales_amount) FROM orders WHERE order_date BETWEEN 'start_of_last_week' AND 'end_of_last_week';
  ```
- Get sales by product:
  ```sql
  SELECT product_id, SUM(amount) FROM chatbi_forge_dev GROUP BY product_id;
  ```

对于数据库 sales_data_warehouse 相关的规则：
<sales_data_warehouse>
**重要关联路径：**
对于数据源 'sales_data_warehouse'，请严格遵循以下关于表连接的规则：

-   **`orders` 表与 `stores` / `employees` 的连接：**
    -   `orders` 表不包含 `store_id` 或 `employee_id`。因此，`orders` 表无法直接与 `stores` 或 `employees` 表进行连接以聚合销售数据。
    -   `orders` 表的主要连接键是 `customer_id` 和 `product_id`。
    -   如果需要将销售数据（来自 `orders`）与门店信息（来自 `stores`）或员工信息（来自 `employees`）关联，必须通过以下方式：
        -   **`orders` -> `customers` -> ... -> `stores` / `employees`** (如果 `customers` 表能间接连接到 `stores` 或 `employees`)
        -   **`orders` -> `products` -> ... -> `stores` / `employees`** (如果 `products` 表能间接连接到 `stores` 或 `employees`)
    -   **如果当前架构中不存在可行的中间连接路径，你必须明确指出无法将销售数据与门店/员工信息关联。**

**特别注意：在涉及产品价格或销售额计算时，`products` 表不包含 `price` 列。`price` 列位于 `orders` 表中。例如，计算销售额时，应使用 `orders.quantity * orders.price`。

## 7. Data Limitations and Interpretations

- **客户年龄段 (Customer Age Groups):** 当前 `customers` 表中不包含 `birth_date` 或其他可直接用于计算年龄的字段。因此，无法进行基于客户年龄段的分析。如需此类分析，需要更新数据库 schema 以包含相关年龄数据。
- **客户忠诚度 (Customer Loyalty):** 数据库 schema 中没有明确的 `customer_loyalty` 字段。在处理相关查询时，请尝试从现有数据（如购买频率、总消费额、购买时长等）推断，或明确指出此限制。
- **客户购买品类数量 (Customer Purchase Category Quantity):** 数据库中没有直接统计客户购买品类数量的字段。在处理此类查询时，请考虑统计每个订单的品类数量，或明确指出此限制。如果需要统计客户在所有订单中购买的不同品类总数，需要进行更复杂的跨订单聚合。

</sales_data_warehouse>
