Guide 04 / 4
Resources and review
Learn to consult documentation, solve an error and check what you have learned.
Find reliable information and explain what you have built.
01 · Exploring the manual
The official links are grouped under the guide.
MySQL · Tutorial
Explore creating a database, loading data and first searches. Turn each example into a question about the recipes.
Example
Mission : écrire « quelles recettes durent moins de 30 minutes ? » en SQL.
MySQL · CREATE TABLE and constraints
Check the types, the constraints and the relationship between categories and recipes in the CREATE TABLE reference.
Example
Mission : expliquer ce que CHECK empêche que NOT NULL n’empêche pas.
MySQL · Joins and transactions
Find ON again in the joins reference. Read the limits of transactions and the implicit commits of structure statements.
Example
Mission : expliquer pourquoi l’essai UPDATE est annulable, alors que CREATE TABLE ne se traite pas de la même façon.
02 · Troubleshooting and preparing for PDO
Read the server's message before changing the query.
Access denied or Unknown database
Access denied concerns the account, the password or the privileges. Unknown database indicates a missing or different name. Check the target server and the selected database.
Example
SELECT DATABASE();
SELECT CURRENT_USER();
Do not grant all privileges to the application to mask a configuration problem.
Syntax or foreign key error
Check commas, apostrophes and the semicolon. A foreign key error often means the requested category does not exist or a parent is still in use.
Example
SHOW TABLES;
DESCRIBE recettes;
SELECT id, nom FROM categories;
Self-assessment
Create the two tables in order, explain the keys, write a join and find the quick menu again. Do an UPDATE in a transaction then cancel it.
Example
Je sais :
□ distinguer SQL et MySQL ;
□ choisir quelques types ;
□ insérer et sélectionner ;
□ joindre deux tables ;
□ modifier une ligne avec WHERE ;
□ expliquer COMMIT et ROLLBACK.
Next: PDO will have PHP run these queries, with form values passed as parameters.