Skip to content

Customer invoices and lines

Customers, invoices and invoice lines related by foreign keys, written as JSON lines.

related volume small InvoicesCustomersRelationships
Languages
eng
Formats
jsonl

Recipe

recipe.gbddl
gbddl 1
language eng

table customers rows 8 (
  id    int64 autoincrement primarykey
  name  text same(person) fullName()
  email text same(person) email()
)

table invoices rows 16 per(customers, 1, 3) (
  id          int64 autoincrement primarykey
  customer_id int64 fk(customers.id)
  number      text unique pattern(pattern: "INV-#####")
  issued_on   date date(min: "2023-01-01", max: "2024-12-31")
  due_on      date date(min: "2023-01-15", max: "2025-01-31")
  status      text enum(values: ["draft", "issued", "paid", "overdue"])
)

table invoice_lines rows 40 per(invoices, 1, 4) (
  id          int64 autoincrement primarykey
  invoice_id  int64 fk(invoices.id)
  description text words(maxWords: 4)
  quantity    int64 integer(min: 1, max: 10)
  unit_price  decimal(8, 2) decimal(min: 1, max: 1000)
)

output jsonl (maxRowsPerFile: 10)

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

About this recipe

Customer invoices

A multi-table recipe that generates customer invoices: customers, invoices and invoice lines, related by foreign keys.

What it demonstrates

  • Relationships — invoices references customers, and invoice_lines references invoices.
  • Row distribution — per(...) groups each customer's invoices (1 to 3) and each invoice's lines (1 to 4).
  • Invoice identity — number is a unique pattern mask and the dates and status are bounded.
  • JSON Lines output — each table is written as one JSON object per line.

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 JSON Lines files: customers.jsonl, invoices.jsonl and invoice_lines.jsonl.

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.

fullNameemailpatterndateenumwordsintegerdecimaluniquefkpersame:personautoincrementprimary-keyjsonl.maxRowsPerFile