Subscription billing
Customers, plans, subscriptions and invoices for recurring billing.
- Languages
eng- Formats
csv
Recipe
gbddl 1
language eng
table customers rows 8 (
id int64 autoincrement primarykey
name text same(person) fullName()
email text same(person) email()
)
table plans rows 4 (
id int64 autoincrement primarykey
name text enum(values: ["free", "starter", "pro", "enterprise"])
price decimal(8, 2) decimal(min: 0, max: 500)
)
table subscriptions rows 12 per(customers, 1, 2) (
id int64 autoincrement primarykey
customer_id int64 fk(customers.id)
plan_id int64 fk(plans.id)
started_on date date(min: "2023-01-01", max: "2024-12-31")
status text enum(values: ["active", "paused", "cancelled"])
)
table invoices rows 20 per(subscriptions, 1, 3) (
id int64 autoincrement primarykey
subscription_id int64 fk(subscriptions.id)
amount decimal(8, 2) decimal(min: 0, max: 500)
issued_on date date(min: "2023-01-01", max: "2024-12-31")
)
output csv
This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.
About this recipe
Subscription billing
A multi-table recipe that generates subscription billing: customers, plans, subscriptions and invoices.
What it demonstrates
- Relationships —
subscriptionsreferencescustomersandplans;invoicesreferencessubscriptions. - Row distribution —
per(...)groups each customer's subscriptions and each subscription's invoices. - Plans —
plansis a fixedenumof tiers with aprice.
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 CSV files: customers.csv, plans.csv,
subscriptions.csv and invoices.csv.
Guarantees
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.
fullNameemailenumdecimaldatefkpersame:personautoincrementprimary-key