1. Home
  2. Explore
  3. Computer Science
  4. SQL Course Introduction

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

SQL Course Introduction

  • 42Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Database Fundamentals
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is a database?

Tap to flipClick to flipspace

A collection of data stored in a format that can be easily accessed.

Or swipe the card

42 cards

  1. What is a database?

    A collection of data stored in a format that can be easily accessed.

  2. What is a DBMS?

    Database Management System – software used to manage databases, execute instructions for querying or modifying data.

  3. What are the two main categories of databases?

    Relational (SQL) and Non-relational (NoSQL).

  4. What is SQL used for?

    To work with relational database management systems – querying and modifying data.

  5. What is the historical significance of the name 'SQL'?

    Originally called SEQUEL (Structured English Query Language), but the acronym was changed to SQL because SEQUEL was trademarked by an airplane company.

  6. Which relational DBMS is used in the course and why?

    MySQL – the most popular open source database in the world.

  7. How do you select a database in MySQL?

    Use the USE statement: USE database_name; or double-click the database in the navigator panel.

  8. What is the basic syntax of a SELECT statement?

    SELECT columns FROM table WHERE condition ORDER BY column LIMIT number;

  9. How do you select all columns from a table?

    SELECT * FROM table_name;

  10. How do you create an alias for a column?

    SELECT column_name AS alias FROM table; – the AS keyword is optional.

  11. How do you remove duplicate rows from a result set?

    Use the DISTINCT keyword: SELECT DISTINCT column FROM table;

  12. What arithmetic operators can be used in SQL?

    Addition (+), subtraction (-), multiplication (*), division (/), modulus (%). Order of operations follows math: */ before +-.

  13. How do you filter rows based on a condition?

    Use the WHERE clause with comparison operators: =, <> or !=, >, <, >=, <=.

  14. How do you combine multiple conditions?

    Use AND (both true), OR (at least one true), and NOT (negates). AND has higher precedence than OR; use parentheses to override.

  15. How do you test if a column value is in a list?

    Use the IN operator: WHERE column IN (value1, value2, ...).

  16. How do you test if a column value falls within a range?

    Use the BETWEEN operator: WHERE column BETWEEN value1 AND value2 – inclusive.

  17. What wildcards does the LIKE operator use?

    % matches any number of characters (including zero); _ matches exactly one character.

  18. What special characters are used in REGEXP for pattern matching?

    ^ – beginning of string; $ – end of string; | – logical OR; [] – match any single character listed; [a-z] – range.

  19. How do you check for NULL values?

    Use IS NULL or IS NOT NULL. Example: WHERE phone IS NULL.

  20. How do you sort query results?

    Use ORDER BY column1 [ASC|DESC], column2 .... Default is ascending (ASC).

  21. How do you limit the number of rows returned?

    Use LIMIT number or LIMIT offset, number. LIMIT 3 returns first 3 rows; LIMIT 6, 3 skips 6 rows and returns 3.

  22. What is an INNER JOIN?

    SELECT * FROM table1 JOIN table2 ON condition; Returns only rows where the join condition is true in both tables.

  23. How do you join tables from different databases?

    Prefix the table name with the database name: FROM db1.table1 JOIN db2.table2 ON ...

  24. What is a self join and how is it used?

    Joining a table with itself using different aliases. Example: FROM employees e JOIN employees m ON e.reports_to = m.employee_id.

  25. What is a compound join condition?

    A join condition that uses multiple columns with AND. Example: ON t1.col1 = t2.col1 AND t1.col2 = t2.col2.

  26. What is the difference between INNER and OUTER joins?

    INNER JOIN returns only matching rows; LEFT JOIN returns all rows from the left table, with NULLs for non-matching right table; RIGHT JOIN is the opposite.

  27. How does the USING clause simplify joins?

    FROM table1 JOIN table2 USING (common_column); – works when the column name is identical in both tables.

  28. What is a natural join and why is it discouraged?

    FROM table1 NATURAL JOIN table2; – The database engine automatically joins on all columns with the same name.

  29. What is a cross join?

    Combines every row from the first table with every row from the second table. Syntax: FROM table1 CROSS JOIN table2 or FROM table1, table2 (implicit).

  30. How does the UNION operator work?

    Combines results from multiple SELECT statements into one result set. The number of columns in each SELECT must be equal.

  31. How do you insert a single row into a table?

    INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

  32. How do you insert multiple rows in one statement?

    INSERT INTO table_name (columns) VALUES (row1), (row2), ...;

  33. How do you insert hierarchical data (parent and child rows)?

    Insert the parent row, then use LAST_INSERT_ID() to get the generated ID for the child rows. Example: INSERT INTO orders ...; INSERT INTO order_items (order_id, ...) VALUES (LAST_INSERT_ID(), ...);

  34. How do you create a copy of a table using a subquery?

    CREATE TABLE new_table AS SELECT * FROM existing_table;

  35. How do you insert data from one table into another using a subquery?

    INSERT INTO target_table SELECT ... FROM source_table WHERE condition;

  36. What is the syntax for updating rows?

    UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;

  37. How do you use expressions in UPDATE statements?

    You can set a column to an expression involving other columns, e.g., SET points = points + 15 or SET payment_total = invoice_total * 0.5.

  38. How do you use a subquery in an UPDATE statement?

    Place the subquery inside parentheses in the WHERE clause. Example: UPDATE invoices SET ... WHERE client_id = (SELECT client_id FROM clients WHERE name = 'Myworks');

  39. How do you delete rows from a table?

    DELETE FROM table_name WHERE condition; – without WHERE, all rows are deleted.

  40. Why should you restore the databases after practicing DML operations?

    To return the databases to their original state to avoid unexpected results in future exercises.

  41. What is the correct order of clauses in a SELECT statement?

    SELECT -> FROM -> WHERE -> ORDER BY -> LIMIT

  42. How do you add comments in SQL?

    Use -- for single-line comments or /* ... */ for multi-line comments.

Card 1 of 42
Card 1 of 42

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent