Sikau

Databases and SQL · Day 12 · about 45 min

Project: Table bookings

Design a schema and query it.

From idea to schema

The café wants online table bookings: guests book a table for a time and party size. Design the tables with the right keys and constraints, add sample data, and answer a question with a JOIN.

Test the rules with bad data

Once the schema exists, try to break it on purpose. Insert a booking for a guest id that doesn't exist, a party of zero, and two bookings for the same table and time. Each insert should fail with a clear constraint error. If one succeeds, a rule is missing.

This habit of testing the unhappy paths is how real teams gain confidence in a schema before any app code depends on it.

The rest of this lesson

  • From sentences to tablesexplain
  • Constraints that model the businessexplain
  • Answering with a JOINexplain
  • Rule to constraintmatch
  • Creation orderorder
  • Bookings schemachallenge
  • Badge quizquiz
  • Unit 2 complete!recap

Continue this lesson free — run real code in your browser

Continue with Google

See all 17 lessons of Databases and SQL