How do you declare a single-column primary key when creating a table?
Add `PRIMARY KEY` to that column’s definition.
Which column is the primary key of the `adherents` table?
`cin CHAR(8)`.
Which fields and types make up the `adherents` table besides its primary key?
`nom VARCHAR(30)`, `prenom VARCHAR(30)`, `email VARCHAR(40)`, `age INT`, and `adresse VARCHAR(50)`.
How is the composite primary key `(cin, codeAct)` declared?
Once at the end of the table as `PRIMARY KEY (cin, codeAct)`.
Why is declaring `PRIMARY KEY` separately for each composite-key column an error?
A composite primary key must be declared once at the end of the table.
How does `ALTER TABLE` make a column mandatory using `MODIFY`?
Use `MODIFY column TYPE NOT NULL`, rewriting the column’s type.
What does the `uqEmail` constraint prevent in `adherents.email`?
It prevents two adherents from having the same email.
Which ages satisfy `CHECK (age BETWEEN 12 AND 70)`?
Ages from 12 through 70, inclusive.
What does the `ckTarif` constraint require for `activites.tarif`?
The tariff must be greater than zero.
What does `ON DELETE CASCADE` on `inscriptions.cin` do when an adherent is deleted?
It deletes that adherent’s inscriptions.
How do you add a column to a table with `ALTER TABLE`?
`ALTER TABLE table ADD column TYPE`.
How is `telephone CHAR(8)` stored for an eight-digit phone number?
As a character string, not a number for calculations.
How do you rename a column and set its type with `ALTER TABLE`?
`ALTER TABLE table CHANGE oldName newName TYPE`.
How can `adresse` become `ville VARCHAR(30)`?
Use `ALTER TABLE table CHANGE adresse ville VARCHAR(30)`.
How do you update the age condition in the named constraint `ckAge`?
Drop `ckAge` with `ALTER TABLE table DROP CONSTRAINT name`, then add it again with the updated condition.
How is an unknown value entered in SQL?
As NULL without apostrophes.
What value does an omitted INSERT column receive?
Its default value.
What does `SELECT * FROM table_name` return?
All columns of the chosen table.
Which comparison operators can a `SELECT` query use in `WHERE` to filter rows?
`=`, `<>`, `<`, `>`, `<=`, and `>=`.
When does an `AND` filter select a row?
Only when both conditions are true.
What is the default sort order for `ORDER BY`?
Ascending order.
How do you create and select a database named `name`?
Run `CREATE DATABASE name;` followed by `USE name;`.
Which column is the primary key of the `activites` table?
`codeAct CHAR(4)`.
How many digits can `DECIMAL(6,3)` store before the decimal point?
Three digits.
What must an email contain to satisfy `CHECK (email LIKE '%@%')`?
The `@` character.
What happens when an insertion omits `activites.places` after its default is set to 20?
The column receives 20 places.
What does `DEFAULT (CURRENT_DATE)` assign to `inscriptions.dateInsc` when omitted?
The current date.
How can `genre CHAR(1)` be restricted to `H` or `F` with a named constraint?
Use `ckGenre` with `CHECK (genre IN ('H', 'F'))`.
How do you change a column's type with `ALTER TABLE`?
`ALTER TABLE table MODIFY column newType`.
What happens to the separately declared `uqEmail` constraint when `email` becomes `VARCHAR(50)`?
The `uqEmail` constraint is preserved.
Which columns does the adherents table contain?
cin, nom, prenom, email, age, ville, telephone, and genre.
What default places value does activity TEN1 receive when omitted?
20 places.
On what date did Yassine register for swimming and karate?
15 September 2026.
On what date did Salma register for fitness?
20 September 2026.
On what date did Ines register for fitness and swimming?
1 October 2026.
Which activities does `SELECT libelle, tarif FROM activites WHERE tarif < 40` return, with their tariffs?
Fitness at 35.000 and Karaté at 30.000.
In an `OR` filter comparing one column with multiple values, what must each condition repeat?
The column name.
Which activities are registered for CIN '44556677' on 2026-10-01?
FIT1 and NAT1.
Which CINs are registered for NAT1?
'11223344' and '44556677'.
Answer 17 questions on SQL Data Entry and Queries.
1. An `age` check uses `CHECK (age BETWEEN 12 AND 70)`. Which age is accepted by the constraint?
2. Which definition correctly specifies the `adherents` table’s columns and primary key?
Go over the full study guide for SQL Data Entry and Queries.
Read the study guide →Upload your class notes and Revizly writes your flashcards in about a minute.
Flashcard maker