Skip to content

Generic product and stock records

A two-file inventory import: a product master table and its on-hand stock records, related by an explicit foreign key.

related volume small InventoryProductsImportRelationships
Languages
eng
Formats
csv

Recipe

recipe.gbddl
gbddl 1
language eng

table products rows 20 (
  id           int64 autoincrement primarykey
  product_code text unique pattern(pattern: "PRD-######")
  gtin         varchar(13) unique gtin()
  name         text words(maxWords: 4)
  category     text enum(values: ["electronics", "apparel", "food", "office", "tools"])
  unit         text unitOfMeasure()
  tariff_code  text regexp(pattern: "[0-9]{8}")
  origin_port  text regexp(pattern: "DE[A-Z]{3}")
  price        decimal(10, 2) decimal(min: 0.01, max: 5000)
)

table stock_levels rows 40 per(products, 1, 4) (
  id            int64 autoincrement primarykey
  record_no     text unique pattern(pattern: "INV-######")
  product_id    int64 fk(products.id)
  warehouse     text pattern(pattern: "WH-###")
  quantity      int64 integer(min: 0, max: 500)
  reorder_point int64 integer(min: 5, max: 60)
  last_counted  date date(min: "2024-01-01", max: "2026-10-31")
  status        text enum(values: ["available", "low", "out"])
)

output csv

This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.

About this recipe

Inventory import

A two-table recipe that generates a generic inventory import: a product master file and a matching stock-on-hand record file, shaped like the interchange CSV an integration tool or a warehouse system would hand over. It demonstrates a common product-plus-stock shape, not compliance with any named ERP.

What it demonstrates

  • Product master — products is the parent table: one row per product, with a source-system product_code (PRD-######) and a gtin barcode that are both unique, the way an import file carries its own keys instead of relying on an internal id.
  • Stock records — stock_levels is the on-hand record table, related to products through product_id (fk(products.id)) and grouped by per(products, 1, 4), so every product has between one and four stock records.
  • Record identity — each stock_levels row carries its own record_no (INV-######), a warehouse code (WH-###), a quantity, a reorder_point, the last_counted date and a stock status.
  • Product details — each product has a name, a category, a unit of measure and a bounded price.
  • Trade codes — tariff_code is an eight-digit customs code shaped like the EU Combined Nomenclature (use [0-9]{6} for HS or [0-9]{10} for HTS), and origin_port a UN/LOCODE shaped code for Germany. Both are regexp values with plausible structure only: they are not looked up in the official lists and carry no descriptions.

Run it

Submit the recipe body to POST /api/v1/jobs?input_format=gbddl, or paste it into Chef, to generate the data. The repository's local runner (run by task test) also generates it and verifies its output.

The recipe outputs two CSV table files: products.csv (twenty product rows) and stock_levels.csv (forty stock rows).

Table relationships

  • stock_levels.product_id references products.id; every stock record names an existing product, and the per rule keeps the records grouped within one to four per product.

Adapt it

  • Change the product_code, record_no and warehouse masks to match your source system's reference formats.
  • Add or drop columns to mirror the exact columns of your import template.
  • Replace the category and status values with the states your target system accepts.
  • Raise the product rows and widen the per(products, 1, 4) bounds to produce a larger import.

Guarantees and limitations

Every product has a unique id, product_code and gtin; every stock record has a unique id and record_no and references an existing product through product_id. Values are synthetic and do not reference real products or warehouses. The recipe does not reconcile stock against movements or compute a running balance; it only shapes the import relationship.

Tested features

Smart types, physical types, rules and formats this recipe exercises and verifies.

patterngtinwordsenumunitOfMeasureregexpdecimalintegerdateuniquefkperautoincrementprimary-key