We use cookies to enhance your experience on the site
CodeWorlds

The Watchtower - guarding integrity

Welcome @name to the Watchtower - the highest tower of the Great Library of Alexandria. From here I, Callimachus, keep watch so that no scroll is lost and no record is distorted. This is the place where we guard the integrity of the data.

So far you have learned to read and change data. But a true Keeper knows that some operations must happen together - or not at all.

Why does it matter?

Imagine borrowing a book. That is two steps:

  1. we record in
    wypozyczenia
    who took the scroll and when,
  2. we mark in
    ksiazki
    that the scroll is unavailable (
    dostepna = 0
    ).

Now think: what if the first step succeeds, but during the second the server crashes? We would have a record of a loan for a book that still shows as available. Chaos. Two readers would demand the same scroll.

What you will learn in the Watchtower

  • Transactions - a way to make a group of operations "all or nothing".
  • The ACID principles - the four pillars that trust in a database stands on.
  • Views (VIEW) - saved queries, ready to use like virtual shelves.
  • Common Table Expressions (WITH) - a way to write clear, complex queries.
  • Window functions - ranking and numbering rows, e.g. books by price.

These are the Library's most powerful tools. Let us climb the tower and take our watch!

Go to CodeWorlds