INTERACTIVE LECTURES
Build and change a database
Guided class activity · apply the ideas from the full SQL lessons.
Open the detailed lessons for this activity
Detailed lessons in this module
Open the full explanations, examples, and SQL exercises directly.
Preparing for Lab 10 · After practice, try the team challenge.
Opening your saved work…
Sign in to save across devices → · Download your guest work before switching accounts.
Prove the scripts can recreate the result
Step 9 of 9 · Database: Trail Gear: build rehearsal
READ & UNDERSTAND
The desktop kit contains schema.sql, load.sql, verify.sql and a six-row CSV. From its extracted folder, open sqlite3 with a new database filename and use .read schema.sql followed by .read load.sql and .read verify.sql. The README gives the exact sequence. Repeat with another new filename so you can compare both builds without deleting the first.
The scripts enable foreign keys in their own connections and use .bail on to stop the CLI after an error. That is not a transaction rollback. A failed run may have earlier successful work; use a fresh rehearsal database to retry. The scripts intentionally target an empty database rather than silently appending on rerun.
Verify more than a file existing: schema and constraints, independent source/loaded/excluded counts, clean NULLs versus empty strings, ordered row values, a sanity join, and deliberately rejected CHECK, UNIQUE and FOREIGN KEY cases on a disposable copy. For Lab 10, Parts 1–3 are the in-class target; complete Part 4 and your own report by the current Canvas deadline. Assign every remaining client file an owner for Milestone 3.
Worked example
SELECT id, serial, type_id, daily_rate, note FROM items ORDER BY id;
The ordered item rows establish an identity-and-value baseline, including NULL notes.
The sanity totals are sums of listed daily rates. No rental transactions or rental durations exist in this fixture, so the sum cannot establish revenue.
Your question
Return gear_type and SUM(i.daily_rate) AS rate_sum for each type with loaded items, grouped by g.id and g.name and ordered by g.id.
Explain your evidence
Why is rate_sum not rental revenue? What evidence would you compare between two fresh builds before trusting reproducibility?
Try a query to unlock the worked-answer discussion.
Query results
Predict the result, then run your query.Predict the result, then run your query.
Read-only activity · One statement per run · First 200 rows displayed · Checks compare the complete bounded result, not just this preview.
Explore this query freely in the playground ↗Check the save status above. Account-saved work is available in My Progress. Explanations are for discussion, not automatically graded. No prerequisite locks.