SQL Data Entry and Queries Flashcards (39 cards)

All cards

1Question

How do you declare a single-column primary key when creating a table?

Answer

Add `PRIMARY KEY` to that column’s definition.

2Question

Which column is the primary key of the `adherents` table?

Answer

`cin CHAR(8)`.

3Question

Which fields and types make up the `adherents` table besides its primary key?

Answer

`nom VARCHAR(30)`, `prenom VARCHAR(30)`, `email VARCHAR(40)`, `age INT`, and `adresse VARCHAR(50)`.

4Question

How is the composite primary key `(cin, codeAct)` declared?

Answer

Once at the end of the table as `PRIMARY KEY (cin, codeAct)`.

5Question

Why is declaring `PRIMARY KEY` separately for each composite-key column an error?

Answer

A composite primary key must be declared once at the end of the table.

6Question

How does `ALTER TABLE` make a column mandatory using `MODIFY`?

Answer

Use `MODIFY column TYPE NOT NULL`, rewriting the column’s type.

7Question

What does the `uqEmail` constraint prevent in `adherents.email`?

Answer

It prevents two adherents from having the same email.

8Question

Which ages satisfy `CHECK (age BETWEEN 12 AND 70)`?

Answer

Ages from 12 through 70, inclusive.

9Question

What does the `ckTarif` constraint require for `activites.tarif`?

Answer

The tariff must be greater than zero.

10Question

What does `ON DELETE CASCADE` on `inscriptions.cin` do when an adherent is deleted?

Answer

It deletes that adherent’s inscriptions.

11Question

How do you add a column to a table with `ALTER TABLE`?

Answer

`ALTER TABLE table ADD column TYPE`.

12Question

How is `telephone CHAR(8)` stored for an eight-digit phone number?

Answer

As a character string, not a number for calculations.

13Question

How do you rename a column and set its type with `ALTER TABLE`?

Answer

`ALTER TABLE table CHANGE oldName newName TYPE`.

14Question

How can `adresse` become `ville VARCHAR(30)`?

Answer

Use `ALTER TABLE table CHANGE adresse ville VARCHAR(30)`.

15Question

How do you update the age condition in the named constraint `ckAge`?

Answer

Drop `ckAge` with `ALTER TABLE table DROP CONSTRAINT name`, then add it again with the updated condition.

16Question

How is an unknown value entered in SQL?

Answer

As NULL without apostrophes.

17Question

What value does an omitted INSERT column receive?

Answer

Its default value.

18Question

What does `SELECT * FROM table_name` return?

Answer

All columns of the chosen table.

19Question

Which comparison operators can a `SELECT` query use in `WHERE` to filter rows?

Answer

`=`, `<>`, `<`, `>`, `<=`, and `>=`.

20Question

When does an `AND` filter select a row?

Answer

Only when both conditions are true.

21Question

What is the default sort order for `ORDER BY`?

Answer

Ascending order.

22Question

How do you create and select a database named `name`?

Answer

Run `CREATE DATABASE name;` followed by `USE name;`.

23Question

Which column is the primary key of the `activites` table?

Answer

`codeAct CHAR(4)`.

24Question

How many digits can `DECIMAL(6,3)` store before the decimal point?

Answer

Three digits.

25Question

What must an email contain to satisfy `CHECK (email LIKE '%@%')`?

Answer

The `@` character.

26Question

What happens when an insertion omits `activites.places` after its default is set to 20?

Answer

The column receives 20 places.

27Question

What does `DEFAULT (CURRENT_DATE)` assign to `inscriptions.dateInsc` when omitted?

Answer

The current date.

28Question

How can `genre CHAR(1)` be restricted to `H` or `F` with a named constraint?

Answer

Use `ckGenre` with `CHECK (genre IN ('H', 'F'))`.

29Question

How do you change a column's type with `ALTER TABLE`?

Answer

`ALTER TABLE table MODIFY column newType`.

30Question

What happens to the separately declared `uqEmail` constraint when `email` becomes `VARCHAR(50)`?

Answer

The `uqEmail` constraint is preserved.

31Question

Which columns does the adherents table contain?

Answer

cin, nom, prenom, email, age, ville, telephone, and genre.

32Question

What default places value does activity TEN1 receive when omitted?

Answer

20 places.

33Question

On what date did Yassine register for swimming and karate?

Answer

15 September 2026.

34Question

On what date did Salma register for fitness?

Answer

20 September 2026.

35Question

On what date did Ines register for fitness and swimming?

Answer

1 October 2026.

36Question

Which activities does `SELECT libelle, tarif FROM activites WHERE tarif < 40` return, with their tariffs?

Answer

Fitness at 35.000 and Karaté at 30.000.

37Question

In an `OR` filter comparing one column with multiple values, what must each condition repeat?

Answer

The column name.

38Question

Which activities are registered for CIN '44556677' on 2026-10-01?

Answer

FIT1 and NAT1.

39Question

Which CINs are registered for NAT1?

Answer

'11223344' and '44556677'.

Test yourself with the quiz

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?

Take the quiz →

Read the study guide

Go over the full study guide for SQL Data Entry and Queries.

Read the study guide →

Related classes

Make your own flashcards

Upload your class notes and Revizly writes your flashcards in about a minute.

Flashcard maker