Data Models

The fastest way to get a useful app is to be specific about your data. Give CodeSky a list of entities and their fields, and it produces the whole vertical slice for each one — table, model, API, and UI.

What a data model produces

  • A migration file (SQL or framework-specific).
  • An ORM model (Sequelize, EF Core, SQLAlchemy — matched to your backend).
  • CRUD endpoints under /api/{entity} with pagination and filtering.
  • List, detail, create, and edit pages on the frontend, wired to those endpoints.

Example prompt

"Patients have name, dob, phone, and a list of appointments.
 Appointments belong to a patient and a doctor, with start_time and status."

From that you get two tables, foreign keys in both directions, list pages with search by name, and a "book appointment" form that picks an existing patient and doctor.

Describe relationships plainly

  • "each order has many line items" → one-to-many with a foreign key.
  • "a student belongs to one class" → a class_id on students.
  • "products and tags are many-to-many" → a join table, generated for you.

Evolving the model safely

  • Add a field by prompt — "add a `priority` enum to tasks (low/medium/high)" — and the migration, model, API, and form update together.
  • Ask for a migration whenever the schema changes so production can be updated in order.
  • Mention soft-deletes, timestamps, or an audit trail and they're wired through both the model and the queries.

Common mistakes to avoid

  • Vague fields. "user info" gives you a guess; "name, email (unique), role" gives you the right columns.
  • Forgetting relationships. Say how entities connect, or you'll get isolated tables with no foreign keys.
  • Renaming in the UI only. Rename in the data model so the change flows through the whole stack.

FAQ

Which database should I choose?

PostgreSQL is a solid default for most apps. SQL Server pairs with the .NET backend; SQLite is great for small or embedded apps. See Database Connections.

Can I change a field type later?

Yes — ask for the change and a migration; the model and forms follow. Existing data is migrated where the change is safe.

Does it seed sample data?

When relevant, yes — enough rows to make the preview meaningful. Ask for more or specific seed data if you need it.

Was this article helpful?