-
Notifications
You must be signed in to change notification settings - Fork 4
Relationship Aware Data Generation
Ravi Kiran Pagidi edited this page Jun 28, 2026
·
2 revisions
After generate_from_schema, use generate_relational when your lower environment needs several connected tables.
from great_generator import generate_relational
data = generate_relational(
tables={
"customers": {
"schema": "customer_id int primary key, customer_name string, email string",
"rows": 1000,
},
"orders": {
"schema": "order_id int primary key, customer_id int references customers.customer_id, order_amount double, order_date date",
"rows": 5000,
},
},
engine="pandas",
)
customers_df = data["customers"]
orders_df = data["orders"]The result is a dictionary keyed by table name:
{
"customers": customers_df,
"orders": orders_df,
}This makes storage optional and flexible:
customers_df.to_parquet("customers.parquet", index=False)
orders_df.to_parquet("orders.parquet", index=False)In a Spark notebook, select engine="spark" to receive Spark DataFrames and use normal Spark writers for Delta, Snowflake, Azure SQL, cloud storage, or catalog tables.
Parent tables are generated before child tables. Child foreign keys are selected from valid parent keys, so this relationship remains valid:
orders.customer_id -> customers.customer_id
Orphan keys are not introduced unless an explicit anomaly configuration requests them.
Relationships can be declared inline:
customer_id int references customers.customer_id
or separately:
data = generate_relational(
tables={
"customers": "customer_id int primary key, customer_name string",
"orders": "order_id int primary key, customer_id int, order_amount double",
},
relationships=["orders.customer_id -> customers.customer_id"],
rows={"customers": 1000, "orders": 5000},
)- Use
generate_from_schemafor one table. - Use
generate_relationalfor your own connected tables. - Use
generate_domainlater for ready-made demonstrations and learning datasets. - Use dimensional and Data Vault generators later when you specifically need those modeling patterns.