Skip to content

Accounts payable

Suppliers, bills and payments related by foreign keys, written as SQL inserts.

related volume small AccountingPaymentsSuppliersRelationships
Languages
eng
Formats
sql

Recipe

recipe.gbddl
gbddl 1
language eng

table suppliers rows 6 (
  id   int64 autoincrement primarykey
  name text company()
)

table bills rows 12 per(suppliers, 1, 2) (
  id          int64 autoincrement primarykey
  supplier_id int64 fk(suppliers.id)
  number      text unique pattern(pattern: "BILL-#####")
  amount      decimal(10, 2) decimal(min: 50, max: 20000)
  due_on      date date(min: "2023-01-01", max: "2024-12-31")
)

table bill_payments rows 14 per(bills, 0, 2) (
  id      int64 autoincrement primarykey
  bill_id int64 fk(bills.id)
  amount  decimal(10, 2) decimal(min: 10, max: 10000)
  paid_on date date(min: "2023-01-01", max: "2025-01-31")
)

output sql (rowsPerInsert: 3, maxRowsPerFile: 20)

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

About this recipe

Accounts payable

A multi-table recipe that generates payables: suppliers, bills and payments, related by foreign keys and written as SQL inserts.

What it demonstrates

  • Relationships — bills references suppliers, and bill_payments references bills.
  • Row distribution — per(...) groups each supplier's bills (1 to 2) and each bill's payments (0 to 2).
  • SQL output — each table is written as CREATE TABLE plus INSERT statements.

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 one SQL file, suppliers.sql and its sibling tables, with the schema and rows for each table.

Guarantees

Every primary key is unique, every foreign key names an existing parent row, and per(...) grouping holds. Values are synthetic and not a balanced ledger.

Tested features

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

companypatterndecimaldateuniquefkperautoincrementprimary-keysql.rowsPerInsertsql.maxRowsPerFile