LEARN WITH ABDOU / LAB 13 NORMALIZATION REHEARSAL
Original fictional Harbor Workshops data; not the assigned inherited.db from Canvas.
Keep the original rehearsal.db and use a working copy for every investigation.

RULES FOR THIS SMALL PROGRAM
One row is one booked seat in one session. Only one session starts per date/time.
Seat codes are unique across both rooms. Event titles and host names are unique
identifiers in this fixture. Learner email identifies a current directory entry.
If these rules change (parallel rooms, reused titles, historical contact data),
the keys and dependencies must be reconsidered; do not assume they are universal.
The office knows of an announced Bookbinding event and an April 5 session with no
bookings. They do not appear in the six-row inherited booking sheet.

CONFIRMED CORRECTIONS (invented facts supplied for this exercise)
Ari confirmed the current phone is 555-0199. Bea confirmed 555-0102 for the missing
entry. The host confirmed the facilitator spelling Mina Park, not Mina Prak.
Do not infer this policy from frequency or dates. A historical-phone model would
need different rules. All names, contacts, addresses and payments are fictional.

STAGES
1. rehearsal.db starts with raw_bookings only: six rows, 19 nullable columns,
   no declared keys. Use raw input for key, dependency and anomaly questions.
2. clean.sql keeps raw input, creates cleaned_bookings and records three field
   corrections in resolution_log. It runs once per fresh copy.
3. schema.sql creates seven EMPTY destination tables. All required attributes
   are NOT NULL, natural identifiers UNIQUE, with seven declared FK relationships.
4. migrate.sql loads corrected input parents-first in one transaction and checks
   row preservation, reconstruction and room agreement before COMMIT.
5. verify.sql compares counts, fees, both reconstruction directions, room agreement
   and foreign keys; it also shows the correction audit. Run before payoff changes.
The evidence tables are retained alongside the seven normalized destination tables.

SQLITE SHELL
First copy rehearsal.db to a new file called working-copy.db using your file manager.
Then, in a terminal in this extracted directory:
  sqlite3 working-copy.db
At sqlite>:
  .bail on
  .headers on
  .mode column
  PRAGMA foreign_keys=ON;
  .read clean.sql
  .read schema.sql
  .read migrate.sql
  .read verify.sql
If a script fails in an interactive connection, inspect the error, ROLLBACK if a
transaction is open, and retry from a fresh copy. Do not continue to COMMIT manually.
The dot commands belong to sqlite3, not a browser SQL textarea.

REBUILD THE RAW FIXTURE (optional)
Open an unused filename with sqlite3 and .read source.sql. Then follow the stages.
To check only the destination DDL, .read schema.sql in a different empty database.
No deletion is necessary. Scripts are meant for fresh objects, not reruns in used files.

LIMITS AND EVIDENCE
Money is integer cents. Paid amounts remain historical booking facts.
Separate seat/session FKs do not enforce equal rooms; verify.sql checks that rule.
The source-row number in resolution_log is provenance in this fixed snapshot,
not a business key or a declared foreign key to the raw table.
Compare reconstruction to CLEANED input. Raw differences must match the audit.
EXCEPT uses distinct rows: compare counts and business-key uniqueness as well.

WORKSHOP: https://learnwithabdou.com/courses/mis3220/labs/schema-rescue
OFFICIAL LAB: https://learnwithabdou.com/courses/mis3220/labs/lab-13
In class: official Q1–Q7 and Part B client audit. Q8–Q12 continue at home.
Use Canvas instructions, exact question numbers and your own reflections for the
individual report. Nothing in this kit submits to Canvas or uploads client files.
