Time to combine everything you have learned: types and constraints in one complete statement. We will build the recenzje (reviews) shelf - here readers will leave ratings of books.
1CREATE TABLE recenzje (
2 id INT AUTO_INCREMENT PRIMARY KEY,
3 ksiazka_id INT NOT NULL,
4 ocena INT,
5 tresc TEXT,
6 data_dodania DATE
7);id INT AUTO_INCREMENT PRIMARY KEY - the primary key, numbered automatically. Each review gets its own catalog number.ksiazka_id INT NOT NULL - points to which book the review concerns. A required field - a review without a book does not exist.ocena INT - a numeric rating (e.g. from 1 to 5). A plain whole number.tresc TEXT - the content of the review, that is a long text without a strict limit.data_dodania DATE - when the review was added.data_dodania DATE).) and a semicolon ";".This is a model shelf - remember its shape. We build most tables in the Library exactly like this: the primary key on top, then columns with appropriate types and constraints.