---
tags: [products, database]
module: Products
---

# [DB]DatabaseTables

## Connections
[[_Products]] · [[[Model]Product]] · [[[Model]WarehouseProduct]] · [[[Model]Category]] · [[[Model]Unit]] · [[[Model]CostCenter]]

## Tables (tenant connection)

### products
| Column | Type | Notes |
|---|---|---|
| id | bigInt | PK |
| name_ar / name_en | string | translatable |
| identifier | string | auto-generated prefix+sequence |
| barcode | string | nullable |
| image_path | string | nullable |
| type | string | ProductTypeEnum |
| quantity | double | total across warehouses |
| total_cost / average_cost | decimal | calculated |
| additional_cost | decimal | extra costs |
| recipe_warehouse_id | FK → warehouses | for RECIPE type |
| category_id | FK → categories | |
| unit_id | FK → units | |
| inventory/selling/purchasing/additional_cost_account_id | FK → accounts | 4 linked accounts |
| tax_id | FK → taxes | |
| selling_price / buying_price | float | |
| custom_fields | JSON | |
| deleted_at | timestamp | soft delete |

### categories
`id` · `name_ar/en` · `desc` · `parent_id→categories` · `deleted_at`

### units
`id` · `name_ar/en` · `symbol` · `unit_type_id→unit_types` · `zatca_code` · `deleted_at`

### unit_types
`id` · `name_ar/en` — 4 seeded rows (Weight, Distance, Time, Unit)

### cost_centers
`id` · `name_ar/en` · `parent_id→cost_centers` · `code` (unique) · `physical_address` · `custom_fields` · `deleted_at`

### cost_center_integrations
`id` · `cost_center_id→cost_centers` · `branch_id` · `branch_name_en/ar` · `branch_reference` · `integration_type` · `is_active`

### warehouse_products
| Column | Type | Notes |
|---|---|---|
| product_id | FK → products | |
| warehouse_id | FK → warehouses | |
| cost_center_id | FK → cost_centers | |
| quantity | double | per-warehouse stock |
| minimum_quantity | double | low-stock threshold |
| allow_notification | boolean | enable low-stock alerts |
| selling_price / buying_price | float | per-warehouse pricing |
| total_cost / average_cost | decimal | per-warehouse cost |
| inventory_account_id | FK → accounts | |
| deleted_at | timestamp | soft delete |

### product_recipe
`id` · `recipe_id→products` · `product_id→products` · `warehouse_product_id→warehouse_products` · `quantity` · `cost` · `deleted_at`

### product_quantities (legacy audit)
`id` · `product_id→products` · `bill_id→purchase_bill` · `bill_return_id→bill_return` · `quantity` · `date` · `change` (0=decrease, 1=increase)
