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.
- Languages
eng- Formats
csv
Recipe
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 —
productsis the parent table: one row per product, with a source-systemproduct_code(PRD-######) and agtinbarcode that are both unique, the way an import file carries its own keys instead of relying on an internal id. - Stock records —
stock_levelsis the on-hand record table, related toproductsthroughproduct_id(fk(products.id)) and grouped byper(products, 1, 4), so every product has between one and four stock records. - Record identity — each
stock_levelsrow carries its ownrecord_no(INV-######), awarehousecode (WH-###), aquantity, areorder_point, thelast_counteddate and a stockstatus. - Product details — each product has a
name, acategory, aunitof measure and a boundedprice. - Trade codes —
tariff_codeis an eight-digit customs code shaped like the EU Combined Nomenclature (use[0-9]{6}for HS or[0-9]{10}for HTS), andorigin_porta UN/LOCODE shaped code for Germany. Both areregexpvalues 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_idreferencesproducts.id; every stock record names an existing product, and theperrule keeps the records grouped within one to four per product.
Adapt it
- Change the
product_code,record_noandwarehousemasks to match your source system's reference formats. - Add or drop columns to mirror the exact columns of your import template.
- Replace the
categoryandstatusvalues with the states your target system accepts. - Raise the product
rowsand widen theper(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