In Week 3 you drew the CRM's data model on paper. This is how that drawing becomes real tables: a chat writes the CREATE TABLE statements, you load them, and you check the result against your drawing. It is the same loop as Assignment 1 phase 1, step 4, on a smaller model.
The repository
github.com/dsgn425-fall2026/crm. Click Use this template, then Create a new repository in your own account. In your copy: Code, then Codespaces, then Create codespace on main. The first start takes about three minutes.
Its README has the stories, the steps, and what every file is for. The short version follows.
The steps
-
In the terminal, run
bin/rails serverand open the port it offers. Then open a second terminal with the + on the terminal panel; the server keeps the first one busy. -
Give a chat a photo of your ERD (or the stories in the README) and ask for SQLite
CREATE TABLEstatements. Paste them intoschema/crm.sql. -
In the second terminal:
bin/loadIt rebuilds the database from nothing, from
schema/crm.sql, and lists the tables it made. If a statement has an error, it stops, names the line, and leaves the database as it was. -
Open the Schema page. Is each table in your drawing there, with the columns you drew? Does each foreign key point where you meant it to? Where the chat differs from your drawing, decide who is right. In Assignment 1 the chat reviews your drawing before it writes any SQL, and
NOTES.mdrecords what it would change and what you took.
solutions/crm.sql has one possible answer. Compare it once you have your own.
Why the terminal, not the Run SQL box
Changing a database's structure (CREATE TABLE, ALTER TABLE, DROP TABLE) never happens inside an app. The Run SQL box is for reading data. An occasional INSERT, UPDATE or DELETE is closer to what apps do every day, but tables are built from a file, through the terminal. Paste a CREATE TABLE into the box and it refuses, and tells you where it goes instead.
It is the same idea as the database user roles from Week 2: read data, write data, change the structure. Most people need only the first. If your job is analyzing data, ask for a read-only login. Not because anyone thinks you can't be trusted; so that a slip can't break anything.
Assignment 1 works the same way: kmdb is the same app, with schema/kmdb.sql, data/kmdb.sql, and bin/load.