Lab 03: Data, State, SQL
Understand what the system remembers and how to query it.
Analogy
Section titled “Analogy”The database is the system’s memory. A schema is the filing cabinet design. A query is a question. A migration is remodeling the cabinet while people still need the files.
- Install or use SQLite.
- Create tables for users, tickets, comments, and audit events.
- Insert sample records.
- Query all open tickets.
- Query ticket history with comments.
- Query tickets assigned to a user.
- Add a new column with a migration.
- Write a rollback note.
- Try inserting invalid data and record what happens.
Example Schema
Section titled “Example Schema”create table users ( id integer primary key, email text not null unique, name text not null);
create table tickets ( id integer primary key, title text not null, status text not null, created_by integer not null references users(id));Questions
Section titled “Questions”- What data must be unique?
- What data can be null?
- What relationships exist?
- What query needs an index?
- What should be immutable?
- What is the danger of deleting data?
Artifact
Section titled “Artifact”Create data-state-sql.md with:
- Schema.
- Insert statements.
- Five queries.
- Query results.
- Migration plan.
- Rollback plan.
Done When
Section titled “Done When”You can create, query, change, and explain a small relational data model.