🌍 freeCodeCamp · flashcards

freeCodeCamp Relational Databases Flashcards

50 question-and-answer cards covering Relational Databases as it is examined in freeCodeCamp. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

50Cards in deck
24Free preview
16Syllabus topics
~245Chars per answer
FreePrice

24 sample cards from the Relational Databases deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. What do the NOT NULL, UNIQUE, and CHECK constraints enforce?

    NOT NULL requires the column to always have a value; UNIQUE forbids duplicate values in the column; CHECK enforces a boolean condition on inserted values, e.g. `CHECK (price > 0)`.

  2. Give the syntax for inserting one or more rows into a table.

    `INSERT INTO table_name(col1, col2) VALUES (val1, val2);` — multiple rows can be inserted at once by separating value tuples with commas: `VALUES (a, b), (c, d);`. Text values are wrapped in single quotes.

  3. How do you change existing rows with UPDATE, and what happens if you omit the WHERE clause?

    `UPDATE table_name SET column = new_value WHERE condition;` changes only matching rows. Without WHERE, every row in the table is updated — a common and dangerous mistake.

  4. How do you delete specific rows from a table in SQL?

    `DELETE FROM table_name WHERE condition;` removes only the rows matching the condition. `DELETE FROM table_name;` with no WHERE clause removes all rows while keeping the table structure.

  5. What is the basic syntax of a SELECT query, and how do ORDER BY, LIMIT, and DISTINCT modify it?

    `SELECT columns FROM table;` (`*` selects all columns). `ORDER BY col ASC|DESC` sorts the results, `LIMIT n` returns at most $n$ rows, and `SELECT DISTINCT col` removes duplicate values from the output.

  6. List the main comparison and logical operators used in a WHERE clause.

    Comparisons: `=`, `!=` (or `<>`), `<`, `>`, `<=`, `>=`; range/set tests: `BETWEEN a AND b`, `IN (list)`, `IS NULL` / `IS NOT NULL`; conditions are combined with `AND`, `OR`, and negated with `NOT`.

  7. How do the wildcards in LIKE work, and what does ILIKE do in PostgreSQL?

    In `WHERE name LIKE pattern`, `%` matches any sequence of characters (including none) and `_` matches exactly one character — e.g., `'W%'` matches names starting with W. `ILIKE` performs the same match case-insensitively.

  8. What rows does an INNER JOIN return? Give the syntax.

    `SELECT * FROM a INNER JOIN b ON a.key = b.key;` returns only rows where the join condition matches in both tables — rows without a match on either side are excluded.

  9. What is the difference between a LEFT JOIN and a RIGHT JOIN?

    LEFT JOIN returns all rows from the left (first) table plus matching rows from the right table, filling non-matches with NULL; RIGHT JOIN does the mirror image, keeping all rows of the right table.

  10. What does a FULL (OUTER) JOIN return?

    All rows from both tables: matched rows are combined, and rows with no match in the other table appear with NULL for the missing side. It is the union of the LEFT and RIGHT join results.

  11. When can you use USING instead of ON in a join, and how does it differ?

    `JOIN b USING(col)` works when the join column has the same name in both tables; it is shorthand for `ON a.col = b.col` and outputs the column once instead of twice. Multiple tables can be chained: `FULL JOIN c USING(col)`.

  12. Name the five core SQL aggregate functions and state what AVG computes.

    COUNT, SUM, AVG, MIN, MAX. AVG returns the arithmetic mean of a column: $$\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_{i}$$ NULL values are ignored by aggregates (except `COUNT(*)`, which counts rows).

  13. What does GROUP BY do, and what rule applies to the columns in the SELECT list when it is used?

    GROUP BY collapses rows sharing the same value(s) into groups so aggregates are computed per group, e.g. `SELECT major, COUNT(*) FROM students GROUP BY major;`. Every selected column must either appear in the GROUP BY clause or be inside an aggregate function.

  14. What is the difference between WHERE and HAVING?

    WHERE filters individual rows before grouping and cannot contain aggregate functions; HAVING filters the groups after GROUP BY and may use aggregates, e.g. `GROUP BY major HAVING COUNT(*) > 5;`.

  15. How is a one-to-many relationship implemented between two tables?

    The "many" side table gets a foreign key column referencing the primary key of the "one" side. Example: many `orders` rows carry a `customer_id` that references `customers(customer_id)` — one customer, many orders.

  16. How is a many-to-many relationship implemented in a relational database?

    With a third junction (join) table containing foreign keys to both tables — e.g., `students_courses(student_id, course_id)` referencing `students` and `courses` — often with a composite primary key `PRIMARY KEY(student_id, course_id)` to prevent duplicate pairs.

  17. What does First Normal Form (1NF) require?

    Every column holds atomic (indivisible) values, each row is unique (there is a primary key), and there are no repeating groups — e.g., no comma-separated lists or `phone1, phone2, phone3` columns.

  18. State the requirements of Second Normal Form (2NF) and Third Normal Form (3NF).

    2NF: the table is in 1NF and every non-key column depends on the whole primary key (no partial dependencies on part of a composite key). 3NF: the table is in 2NF and non-key columns depend only on the key, not on other non-key columns (no transitive dependencies).

  19. In the freeCodeCamp Celestial Bodies project, what tables and key structure are required?

    A `universe` database with at least the tables `galaxy`, `star`, `planet`, and `moon` (plus one more). Each table needs a `name` column and a primary key named `table_name_id` that auto-increments (SERIAL). Foreign keys model the hierarchy: each star references a galaxy, each planet a star, each moon a planet.

  20. How do you back up and restore a PostgreSQL database as a .sql file (as done in the Celestial Bodies project)?

    Dump: `pg_dump -cC --inserts -U freecodecamp universe > universe.sql` writes SQL that recreates the database. Restore: `psql -U postgres < universe.sql` runs that file to rebuild it.

  21. Describe the schema and workflow of the freeCodeCamp World Cup project.

    A `worldcup` database with a `teams` table (`team_id SERIAL PRIMARY KEY`, unique `name`) and a `games` table whose `winner_id` and `opponent_id` are foreign keys to `teams(team_id)`. A bash script reads `games.csv` line by line (with `while read` and IFS set to a comma), inserts teams if missing, then inserts each game; a second script answers queries such as win percentages, e.g. $\frac{\text{wins}}{\text{games}} \times 100$ rounded with ROUND.

  22. In the Salon Appointment Scheduler project, how are the tables related and how does the bash script talk to the database?

    Tables: `customers` (unique `phone`), `services`, and `appointments` with foreign keys `customer_id` and `service_id`. The script defines `PSQL="psql --username=freecodecamp --dbname=salon -t --no-align -c"` and runs queries via command substitution, e.g. `CUSTOMER_ID=$($PSQL "SELECT customer_id FROM customers WHERE phone='$PHONE'")`, inserting a new customer when no row is returned.

  23. Outline the schema and script behavior of the Periodic Table project.

    The `periodic_table` database is normalized into `elements` (atomic_number, symbol, name), `properties` (melting/boiling points, `atomic_mass DECIMAL`, and a `type_id` foreign key), and a `types` table (metal, nonmetal, metalloid). The bash script takes one argument — an atomic number, symbol, or element name — decides which with a numeric test, joins the tables, and prints a sentence describing the element, or "Could not find that element in the database." if absent.

  24. In the Number Guessing Game project, how is the random number generated and what is stored in the database?

    Bash's `$RANDOM` variable with the modulo operator: `SECRET=$(( RANDOM % 1000 + 1 ))` yields an integer in $[1, 1000]$. The script asks for a username, looks it up in the database, reports games played and best game (fewest guesses), loops with `read` until the guess matches (printing higher/lower hints), then saves the game's guess count for that user.

What this deck covers

The Relational Databases deck follows the freeCodeCamp Relational Databases syllabus — 5 chapters and 16 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 10.0 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 245 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Relational Databases flashcards FAQ

How many Relational Databases flashcards are in this freeCodeCamp deck?

50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these freeCodeCamp flashcards free?

Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.

What do the Relational Databases cards cover?

They follow the freeCodeCamp Relational Databases syllabus — 5 chapters and 16 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.