Skip to main content

Your First Data Model

This walkthrough builds a complete Global Sustainable Supply Chain (GSSC) schema from scratch. It covers tables, relationships, enums, and export.

1. Start a new session

Open talkingschema.ai. You'll see the chat panel on the left and an empty ERD canvas on the right.

2. Create the core tables

In the chat input, type:

Create a supply chain schema with suppliers, products, warehouses, purchase orders, and shipments. Suppliers have a carbon_tier rating. Products belong to a supplier and have a carbon_intensity_score.

TalkingSchema will generate:

  • suppliers — id, name, carbon_tier, country, is_active, created_at
  • products — id, name, supplier_id, carbon_intensity_score, unit_price, sku, created_at
  • warehouses — id, name, location, capacity_units, created_at
  • purchase_orders — id, supplier_id, warehouse_id, status, created_at, updated_at
  • shipments — id, purchase_order_id, carrier, emissions_kg, shipped_at, delivered_at

The ERD auto-updates with relationships shown as connecting lines.

3. Add enums

Enums represent a fixed set of values. Add two for this schema:

Add a carbon_tier enum with values: A, B, C, D. Use it on the suppliers table. Add an order_status enum with values: pending, confirmed, processing, shipped, delivered, cancelled. Use it on the purchase_orders table.

The suppliers table now has carbon_tier and purchase_orders has status — both backed by their respective enum types.

4. Add carbon offset tracking

Add a carbon_offset_credits table linked to suppliers. Include: tonnes_co2 as DECIMAL(10,2), vintage_year as INTEGER, verified_by as VARCHAR(255), and created_at.

This models real-world carbon offset certificates tied to individual suppliers.

5. Review the ERD

Look at your ERD:

  • Solid lines = foreign key relationships
  • Crow's foot notation = one-to-many cardinality
  • PK badge = primary key fields

Click any table node to expand and see all fields.

6. Refine with follow-ups

Try these refinements:

  • "Add a sales_orders table with a customers table. Sales orders have line items."
  • "Add an inventory table that tracks quantity per product per warehouse"
  • "Add created_at and updated_at timestamps to all tables that are missing them"

7. Export your schema

Click ExportSQLPostgreSQL.

The downloaded file contains complete CREATE TABLE statements with:

  • Primary keys
  • Foreign key constraints
  • Enum type definitions (carbon_tier, order_status)
  • NOT NULL constraints

What you learned

  • Describing multi-table schemas in plain English
  • Adding enums via chat
  • Iterating with follow-up messages
  • Reading the ERD diagram
  • Exporting production-ready SQL

Next: Understand AI Copilot modes →