Demo mode This site is not live. It is currently being tested and developed. Nothing on here represents an offer.
← Exit course WEB-301 Full-Stack Web Development with PHP and Laravel
Course progress, 0 of 17 parts done0%

Data that keeps its own rules

Relational databases and SQL

From spreadsheet to database

Tables, types, rules and questions for the Walk Office

Who enforces the rules?

Spreadsheet

  • Any cell takes anything
  • Two editors overwrite each other
  • Rules live in people's heads

Relational database

  • Every column has a type
  • Constraints refuse bad rows
  • Changes are all or nothing

UPDATE 6

the command tag when a price change for one walk forgot its WHERE clause

Check first, then commit

  1. SELECT with the WHERE you plan to use
  2. BEGIN
  3. UPDATE or DELETE with the same WHERE
  4. Read the count, then COMMIT or ROLLBACK

Aisha has no phone number recorded. Which query finds her?

  1. WHERE phone = NULL
  2. WHERE phone IS NULL
  3. WHERE phone = ''
Show the answer

NULL means unknown, so comparing it with = is never true. IS NULL is the test that works. An empty string is a value, not a missing one.

Never store rand in floating point. Store moments as timestamptz, in the Africa/Johannesburg zone.

Now watch the video

Watch how WHERE chooses rows, why text needs single quotes, and how UPDATE and DELETE change only what you mean.

Watch the video