World 2A / Quest 2A.0

Preview: Schema First

See why the database model comes before JPA entities.

Concept

Phase 2A refuses to let Hibernate invent the model. The database gets the invariants first, then entities map onto what the database already knows.

Task

  1. Read the frozen domain model.
  2. Explain why occupied_until is stored on showtime.
  3. Sketch the Postgres exclusion constraint in schema-notes.md.

Run

docker compose up -d postgres
./gradlew flywayMigrate

Expected Result

  • Your notes explain row-local occupancy windows and source-system-aware external IDs.

Common Traps

  • Trying to join movie.duration_minutes inside a Postgres exclusion constraint.
  • Using a floating-point price.
  • Making source_external_id globally unique without source_system.

Hint Ladder

Hint 1

A showtime is a booking fact. Later movie duration corrections must not rewrite history.

Hint 2

The exclusion constraint can only see columns on the showtime row.

Hint 3

The schema should say what the app means, even when demo data is small.

Solution

Preview only. Full solution lands with World 2A.