Try your tables

You have two empty tables and a database viewer. It works just like a spreadsheet — you click a cell, type a value, and save. Before writing any code to save data, let's try it by hand.

Add a form

In Drizzle Studio, click the forms table in the sidebar, then click the + Add record button to add a new row.

You'll see an empty row appear. To type a value, double-click the cell — the first click only shows buttons for the multiline, date, or JSON editor. Double-clicking opens the cell as a plain text field.

Fill in the columns:

  • id — leave it empty. The database assigns this automatically.
  • titleContact Form
  • fields — paste the JSON below
  • tokenabc123
[
  { "name": "email", "type": "email" },
  { "name": "message", "type": "textarea" }
]
?What is JSON?

Click Save changes.

Form row 1

Form row 2

Your first row. The database remembered it — just like saving a row in a spreadsheet, except your app can read and write to it too.

Add a submission

Now click the submissions table, then click the + Add record button:

  • id — leave it empty
  • form_id1 (this links it to the form you just created)
  • data — paste the JSON below
{ "email": "hello@example.com", "message": "Hi there!" }

Click Save changes.

Submission row 1

Submission row 2

Two tables, two rows, one connection. The submission knows which form it belongs to through form_id. This is how your app will work — someone creates a form, someone else fills it out, and the submission links back to the form it's responding to.

Now break it

Your database accepted perfectly good data. But will it accept bad data? Try it.

Go back to the forms table and add another row:

  • title — leave it completely empty
  • fieldshello
  • tokenabc123 (same as before — a duplicate)

Save it. The database rejects it — title can't be empty and token must be unique. Your schema's notNull() and unique() constraints caught those. Good.

Broken 1

Broken 2

Now try something the schema doesn't catch. Add a row with:

  • titlex
  • fieldshello
  • tokenanything

Problem 1

Problem 2

This one goes through. A one-letter title and a plain word where a JSON array should be. The database stored it without complaint because notNull() only checks that something is there — it has no opinion about what that something looks like.

The problem

Look at your forms table now. A real form row sitting next to a garbage row. The database treats them the same — it enforces basic rules like "this column can't be empty," but it can't check whether a title is too short or whether the fields column contains valid JSON.

When your app starts saving data through code instead of by hand, bad data like this will slip right in. The bugs won't show up when data is saved — they'll show up later, when someone tries to use it.

The fix: check the data before it reaches the database. That's called validation, and it's what you'll set up next.

Clean up

Before moving on, delete the bad row you just added. Click it in Drizzle Studio and hit the delete button. Keep the good "Contact Form" and its submission — you'll reference them later.

Cleanup 1

Cleanup 2

Cleanup 3