CRUD Basics
SELECT, WHERE & ORDER
IDs & Primary Keys
Foreign Keys & Relationships
SQL Challenge
100

What does CRUD stand for?

Create, Read, Update, Delete

100

Which SQL command is used to read information from a table?

SELECT

100

What is an ID used for in a database?

To identify a record.

100

What is the purpose of a Foreign Key?

To connect records from related tables.

100

Is this query safe or dangerous? DELETE FROM players;

Dangerous. It deletes every row.

200

Which SQL command is normally used to add a new record?

INSERT

200

What does SELECT * FROM players; show?

All columns and all rows from players.

200

Can two rows have the same Primary Key value?

No

200

In a relationship between teams and players, which table would normally contain id_team as a Foreign Key?

players

200

What is missing here? UPDATE players SET wins = 10; if we only want to modify player 3.

WHERE id_player = 3

300

Which SQL command is used to modify an existing record?

UPDATE

300

Write the condition to show only players with more than 5 wins.

WHERE wins > 5

300

What does AUTO_INCREMENT do?

Automatically generates the next numeric ID.

300

What does a 1:N relationship mean?

One record from one table can be related to many records in another table.

300

Write a query to delete only the player with id_player = 5.

DELETE FROM players WHERE id_player = 5;

400

Which SQL command is used to remove a record from a table?

DELETE

400

What does ORDER BY wins DESC do?

Orders the results from highest wins to lowest wins.

400

Why is an ID usually safer than a name when using UPDATE or DELETE?

Because an ID is unique, while names can be repeated.

400

If one team can have many players, can the same id_team appear several times in the players table?

YES

400

A player with id_player = 2 earns 3 additional wins. Write the query without replacing the current value manually.

UPDATE players SET wins = wins + 3 WHERE id_player = 2;

500

A student says that CREATE TABLE represents the “Create” operation in CRUD. Why is this not correct when we are talking about records?

Because CRUD “Create” normally refers to creating a record with INSERT, not creating the table structure.

500

Write a query that shows only nickname and wins for players with 8 or more wins, ordered from highest to lowest wins.

SELECT nickname, wins FROM players WHERE wins >= 8 ORDER BY wins DESC;

500

What is the difference between an ID column and a Primary Key?

An ID is a column/value used for identification; PRIMARY KEY is the rule that guarantees uniqueness and prevents NULL values.

500

What should happen if a player is inserted with id_team = 99, but team 99 does not exist? Why?

MySQL should reject it because the Foreign Key would violate referential integrity.

500

Write the important line that connects players.id_team with teams.id_team when creating the players table.

FOREIGN KEY (id_team) REFERENCES teams(id_team)

M
e
n
u