We use cookies to enhance your experience on the site
CodeWorlds

The Magnum Opus - Callimachus's challenge

Welcome one last time, @name! Look how far you have come. When you stood at the Library Gate, you could not write a single

SELECT
. Today you know filtering (
WHERE
), sorting (
ORDER BY
), joins (
JOIN
), grouping (
GROUP BY
), subqueries, indexes and transactions. I am proud of you.

But a true master does not merely read the catalog - they create it. So I set before you one final challenge: you will design your own small library system.

What we will build together

In this location we will revisit the whole art of data management, but this time from the architect's side:

  • You will design a new table and link it to an existing one through a foreign key.
  • You will fill it with data using the
    INSERT
    statement.
  • You will ask wise questions by joining tables and grouping results.
  • You will reach for subqueries and
    HAVING
    to draw out hidden knowledge.

Foreign key - a short reminder

A foreign key (

FOREIGN KEY
) is a cross-reference between shelves. It points to a column in another table and ensures the value always matches an existing row:

1CREATE TABLE recenzje (
2  id INT PRIMARY KEY AUTO_INCREMENT,
3  ksiazka_id INT,
4  tresc TEXT,
5  FOREIGN KEY (ksiazka_id) REFERENCES ksiazki(id)
6);

Here

ksiazka_id
always points to a real book on the
ksiazki
shelf. Thanks to this, no "ghost" review will ever exist - an opinion about a book that is not there.

Take a deep breath. It is time to create something of your own. THE TREASURY OPENS FOR YOU!

Go to CodeWorlds