Structured identifiers and uniqueness
Templates, regexps, masks and every identifier scheme, several unique per row.
- Languages
eng- Formats
csv
Recipe
gbddl 1
language eng
table structured_identifiers rows 20 (
id int64 autoincrement primarykey
code text unique pattern(pattern: "W-#####-X")
ref text unique regexp(pattern: "[A-Z]{2}[0-9]{6}")
label text template(template: "{{code}}-{{group}}")
group text enum(values: ["alpha", "beta", "gamma"])
uid uuid unique uuid()
ulid text unique ulid()
mongo_id text unique mongodbObjectId()
slug text unique slug(words: 3)
isbn text isbn(formatted: true)
issn text issn(formatted: true)
card text creditCard()
version text semver()
)
output csv
This is the exact recipe.gbddl committed to the repository. Copy it, or download the raw source.
About this recipe
Structured identifiers
A single-table recipe that generates structured identifiers: masks, regexps, templates and every identifier scheme, several unique per row.
What it demonstrates
- Masks and regexps —
codeis apatternmask andrefaregexp, bothunique. - Templates —
labelrenders{{code}}-{{group}}from other columns. - Identifier schemes —
uid,ulid,mongo_idandslugareunique;isbn,issn,cardandversionare publication, payment and version identifiers with valid check digits or shapes.
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 CSV table file, structured_identifiers.csv, holding
twenty rows.
Adapt it
- Change the
patternmask to your own code scheme. - Add
identifier(kind: "cnpj")for a Brazilian company id.
Guarantees
Every row has a unique id, code, ref, uid, ulid, mongo_id and
slug; label always combines code and group. Identifiers are synthetic.
Tested features
Smart types, physical types, rules and formats this recipe exercises and verifies.
patternregexptemplateenumuuidulidmongodbObjectIdslugisbnissncreditCardsemveruniqueautoincrementprimary-key