Skip to content
🗄️

Databases & SQL

150 exercises

Practice exercises for databases & sql.

  1. 1

    What Is a Database?

    Test your understanding of what a database is and why applications need one.

    Multiple Choice Beginner
  2. 2

    Relational vs NoSQL

    Distinguish between relational and NoSQL databases.

    Multiple Choice Easy
  3. 3

    Primary Key Purpose

    Understand the role of a primary key in a relational table.

    Multiple Choice Easy
  4. 4

    SQL Command Categories

    Identify which SQL category the SELECT statement belongs to.

    Multiple Choice Easy
  5. 5

    SELECT * Meaning

    Understand what the asterisk means in a SELECT query.

    Multiple Choice Beginner
  6. 6

    WHERE vs HAVING

    Distinguish between WHERE and HAVING clauses.

    Multiple Choice Medium
  7. 7

    INNER JOIN Behavior

    Understand what INNER JOIN returns.

    Multiple Choice Easy
  8. 8

    LEFT JOIN Behavior

    Understand what LEFT JOIN returns.

    Multiple Choice Easy
  9. 9

    COUNT(*) Meaning

    Understand what COUNT(*) returns.

    Multiple Choice Beginner
  10. 10

    GROUP BY Purpose

    Understand the purpose of GROUP BY.

    Multiple Choice Easy
  11. 11

    Foreign Key Purpose

    Understand what a foreign key does.

    Multiple Choice Easy
  12. 12

    Transaction ACID - Atomicity

    Understand the Atomicity property of ACID transactions.

    Multiple Choice Medium
  13. 13

    Normalization Goal

    Understand the purpose of normalization.

    Multiple Choice Medium
  14. 14

    Index Trade-off

    Understand the trade-off of adding database indexes.

    Multiple Choice Medium
  15. 15

    NoSQL Characteristic

    Identify a key characteristic of NoSQL databases.

    Multiple Choice Easy
  16. 16

    INSERT Statement

    Understand what the INSERT statement does.

    Multiple Choice Beginner
  17. 17

    ACID - Durability

    Understand the Durability property of ACID.

    Multiple Choice Medium
  18. 18

    Subquery Placement

    Identify where a subquery can be placed in a SQL statement.

    Multiple Choice Medium
  19. 19

    Connection Pool Purpose

    Understand why connection pools are used.

    Multiple Choice Medium
  20. 20

    Migration Purpose

    Understand the purpose of database migrations.

    Multiple Choice Medium
  21. 21

    Predict Simple SELECT

    Predict the output of a simple SELECT query.

    Predict Output Beginner
  22. 22

    Predict WHERE Filter

    Predict how many rows a WHERE clause returns.

    Predict Output Easy
  23. 23

    Predict SUM Result

    Predict the result of a SUM aggregation.

    Predict Output Easy
  24. 24

    Predict AVG Result

    Predict the result of an AVG aggregation.

    Predict Output Easy
  25. 25

    Predict GROUP BY Count

    Predict the number of groups returned by GROUP BY.

    Predict Output Medium
  26. 26

    Predict LIKE Match

    Predict how many rows a LIKE pattern matches.

    Predict Output Easy
  27. 27

    Predict INNER JOIN Rows

    Predict the number of rows from an INNER JOIN.

    Predict Output Medium
  28. 28

    Predict LEFT JOIN Rows

    Predict the number of rows from a LEFT JOIN.

    Predict Output Medium
  29. 29

    Predict MIN MAX

    Predict the result of MIN and MAX functions.

    Predict Output Easy
  30. 30

    Predict LIMIT Result

    Predict how many rows LIMIT returns.

    Predict Output Beginner
  31. 31

    Predict IN Clause

    Predict the result of a WHERE IN clause.

    Predict Output Easy
  32. 32

    Predict HAVING Filter

    Predict how many groups pass a HAVING filter.

    Predict Output Medium
  33. 33

    Predict UPDATE Result

    Predict the effect of an UPDATE statement.

    Predict Output Easy
  34. 34

    Predict Subquery Result

    Predict the result of a query with a subquery.

    Predict Output Medium
  35. 35

    Predict COUNT with NULL

    Predict the difference between COUNT(*) and COUNT(column).

    Predict Output Medium
  36. 36

    Predict BETWEEN Result

    Predict how many rows a BETWEEN clause matches.

    Predict Output Easy
  37. 37

    Predict DISTINCT Count

    Predict the result of a DISTINCT query.

    Predict Output Easy
  38. 38

    Predict SUM per Group

    Predict the SUM for a specific group.

    Predict Output Medium
  39. 39

    Predict AND OR Logic

    Predict the result of combined AND/OR conditions.

    Predict Output Medium
  40. 40

    Predict Transaction Outcome

    Predict the state after a committed transaction.

    Predict Output Medium
  41. 41

    Complete SELECT Query

    Fill in the missing keyword to select all columns from the users table.

    Fill in the Blank Beginner
  42. 42

    Complete WHERE Clause

    Fill in the keyword to filter rows in a query.

    Fill in the Blank Beginner
  43. 43

    Complete CREATE TABLE

    Fill in the keyword to create a new table.

    Fill in the Blank Beginner
  44. 44

    Complete INSERT Statement

    Fill in the keyword to add a new row.

    Fill in the Blank Beginner
  45. 45

    Complete GROUP BY

    Fill in the keyword to group rows for aggregation.

    Fill in the Blank Easy
  46. 46

    Complete JOIN Clause

    Fill in the join type to return only matching rows.

    Fill in the Blank Easy
  47. 47

    Complete PRIMARY KEY

    Fill in the constraint keyword for a unique row identifier.

    Fill in the Blank Easy
  48. 48

    Complete FOREIGN KEY

    Fill in the keyword to create a foreign key reference.

    Fill in the Blank Easy
  49. 49

    Complete ORDER BY

    Fill in the keyword to sort results.

    Fill in the Blank Beginner
  50. 50

    Complete COMMIT

    Fill in the command to save a transaction.

    Fill in the Blank Easy
  51. 51

    Complete ROLLBACK

    Fill in the command to undo a transaction.

    Fill in the Blank Easy
  52. 52

    Complete UPDATE Statement

    Fill in the keyword to modify existing rows.

    Fill in the Blank Beginner
  53. 53

    Complete DELETE Statement

    Fill in the keyword to remove rows.

    Fill in the Blank Beginner
  54. 54

    Complete COUNT Function

    Fill in the aggregate function to count rows.

    Fill in the Blank Beginner
  55. 55

    Complete SUM Function

    Fill in the aggregate function to total a column.

    Fill in the Blank Easy
  56. 56

    Complete NOT NULL

    Fill in the constraint to prevent NULL values.

    Fill in the Blank Easy
  57. 57

    Complete LIMIT Clause

    Fill in the keyword to restrict the number of rows.

    Fill in the Blank Easy
  58. 58

    Complete LIKE Pattern

    Fill in the pattern to match emails ending in .com.

    Fill in the Blank Medium
  59. 59

    Complete HAVING Clause

    Fill in the keyword to filter groups after aggregation.

    Fill in the Blank Medium
  60. 60

    Complete CREATE INDEX

    Fill in the keyword to create an index.

    Fill in the Blank Medium
  61. 61

    Find the SELECT Mistake

    Find the syntax error in a SELECT query.

    Find the Mistake Beginner
  62. 62

    Find the WHERE Mistake

    Find the error in a WHERE clause.

    Find the Mistake Beginner
  63. 63

    Find the UPDATE Mistake

    Find the dangerous mistake in an UPDATE statement.

    Find the Mistake Easy
  64. 64

    Find the DELETE Mistake

    Find the dangerous mistake in a DELETE statement.

    Find the Mistake Easy
  65. 65

    Find the GROUP BY Mistake

    Find the error in a GROUP BY query.

    Find the Mistake Medium
  66. 66

    Find the JOIN Mistake

    Find the error in a JOIN query.

    Find the Mistake Easy
  67. 67

    Find the CREATE TABLE Mistake

    Find the error in a CREATE TABLE statement.

    Find the Mistake Easy
  68. 68

    Find the Aggregation Mistake

    Find the error in an aggregation query.

    Find the Mistake Medium
  69. 69

    Find the WHERE with Aggregate Mistake

    Find the error in using an aggregate in WHERE.

    Find the Mistake Medium
  70. 70

    Find the ORDER BY Mistake

    Find the error in an ORDER BY clause.

    Find the Mistake Easy
  71. 71

    Find the Constraint Mistake

    Find the error in a table with constraints.

    Find the Mistake Medium
  72. 72

    Find the Ambiguous Column Mistake

    Find the ambiguous column error in a JOIN.

    Find the Mistake Medium
  73. 73

    Find the INSERT Mistake

    Find the error in an INSERT statement.

    Find the Mistake Easy
  74. 74

    Find the String Literal Mistake

    Find the error with string quoting.

    Find the Mistake Easy
  75. 75

    Find the Transaction Mistake

    Find the error in a transaction.

    Find the Mistake Medium
  76. 76

    Find the Subquery Mistake

    Find the error in a subquery.

    Find the Mistake Medium
  77. 77

    Find the Semicolon Mistake

    Find the error with statement termination.

    Find the Mistake Beginner
  78. 78

    Find the NULL Comparison Mistake

    Find the error in a NULL comparison.

    Find the Mistake Medium
  79. 79

    Find the Clause Order Mistake

    Find the error in SQL clause ordering.

    Find the Mistake Medium
  80. 80

    Find the Division by Zero Mistake

    Find the potential division by zero error.

    Find the Mistake Medium
  81. 81

    Database vs Spreadsheet

    Check your understanding of why databases are better than spreadsheets for apps.

    Concept Check Beginner
  82. 82

    Why Tables and Rows?

    Understand the relational model's table structure.

    Concept Check Easy
  83. 83

    Declarative Nature of SQL

    Understand that SQL is declarative.

    Concept Check Medium
  84. 84

    When to Use JOIN

    Understand when a JOIN is needed.

    Concept Check Easy
  85. 85

    Why Normalize?

    Understand the practical benefit of normalization.

    Concept Check Medium
  86. 86

    When to Use Transactions

    Understand when transactions are necessary.

    Concept Check Medium
  87. 87

    When to Add an Index

    Understand when adding an index is beneficial.

    Concept Check Medium
  88. 88

    When to Choose NoSQL

    Understand when NoSQL is a better choice than relational.

    Concept Check Medium
  89. 89

    ACID - Isolation

    Understand the Isolation property of ACID.

    Concept Check Medium
  90. 90

    Why Use Constraints?

    Understand the value of database constraints.

    Concept Check Easy
  91. 91

    One-to-Many Relationship

    Understand how to model a one-to-many relationship.

    Concept Check Easy
  92. 92

    Many-to-Many Relationship

    Understand how to model a many-to-many relationship.

    Concept Check Medium
  93. 93

    Aggregate Without GROUP BY

    Understand what happens when you use an aggregate without GROUP BY.

    Concept Check Medium
  94. 94

    Connection Leak

    Understand what a connection leak is.

    Concept Check Medium
  95. 95

    Why Use Migrations?

    Understand the benefit of migration tools.

    Concept Check Medium
  96. 96

    Full Table Scan

    Understand what a full table scan is and why it is slow.

    Concept Check Medium
  97. 97

    View vs Table

    Understand the difference between a view and a table.

    Concept Check Medium
  98. 98

    SQL Injection Prevention

    Understand how to prevent SQL injection.

    Concept Check Medium
  99. 99

    Redis Use Cases

    Understand when Redis is the right tool.

    Concept Check Medium
  100. 100

    Schema Design First

    Understand the importance of designing the schema before coding.

    Concept Check Easy
  101. 101

    SQL Purpose

    What is SQL used for?

    Multiple Choice Beginner
  102. 102

    SELECT Clause

    What does SELECT do in SQL?

    Multiple Choice Beginner
  103. 103

    WHERE Clause

    What does the WHERE clause do?

    Multiple Choice Beginner
  104. 104

    INNER JOIN

    What does INNER JOIN return?

    Multiple Choice Easy
  105. 105

    LEFT JOIN

    What does LEFT JOIN return?

    Multiple Choice Easy
  106. 106

    GROUP BY Purpose

    What does GROUP BY do?

    Multiple Choice Easy
  107. 107

    HAVING vs WHERE

    How does HAVING differ from WHERE?

    Multiple Choice Medium
  108. 108

    COUNT Function

    What does COUNT(*) return?

    Multiple Choice Beginner
  109. 109

    Primary Key

    What is a primary key?

    Multiple Choice Beginner
  110. 110

    Foreign Key

    What is a foreign key?

    Multiple Choice Easy
  111. 111

    INDEX Purpose

    Why create an index on a table?

    Multiple Choice Easy
  112. 112

    ACID Properties

    What does ACID stand for in databases?

    Multiple Choice Medium
  113. 113

    Normalization Purpose

    What is the goal of normalization?

    Multiple Choice Medium
  114. 114

    Subquery Type

    What is a correlated subquery?

    Multiple Choice Medium
  115. 115

    Transaction Commit

    What does COMMIT do?

    Multiple Choice Easy
  116. 116

    Transaction Rollback

    What does ROLLBACK do?

    Multiple Choice Easy
  117. 117

    DISTINCT Keyword

    What does SELECT DISTINCT do?

    Multiple Choice Easy
  118. 118

    ORDER BY Clause

    What does ORDER BY do?

    Multiple Choice Beginner
  119. 119

    LIMIT Clause

    What does LIMIT do?

    Multiple Choice Easy
  120. 120

    UNION Operator

    What does UNION do?

    Multiple Choice Medium
  121. 121

    View Definition

    What is a database view?

    Multiple Choice Medium
  122. 122

    NoSQL vs SQL

    What is a key difference between NoSQL and SQL databases?

    Multiple Choice Easy
  123. 123

    Aggregate AVG

    What does AVG() calculate?

    Multiple Choice Easy
  124. 124

    JOIN ON Clause

    What does the ON clause specify in a JOIN?

    Multiple Choice Easy
  125. 125

    Database Migration

    What is a database migration?

    Multiple Choice Medium
  126. 126

    Connection Pool

    What is a database connection pool?

    Multiple Choice Medium
  127. 127

    SQL Injection

    What is SQL injection?

    Multiple Choice Medium
  128. 128

    Redis Data Type

    What type of database is Redis?

    Multiple Choice Easy
  129. 129

    Database Index Type

    What is a composite index?

    Multiple Choice Medium
  130. 130

    CASCADE Delete

    What does ON DELETE CASCADE do?

    Multiple Choice Medium
  131. 131

    SELECT All

    Predict the output.

    Predict Output Beginner
  132. 132

    WHERE Filter

    Predict the output.

    Predict Output Beginner
  133. 133

    COUNT Rows

    Predict the output.

    Predict Output Beginner
  134. 134

    SUM Aggregate

    Predict the output.

    Predict Output Easy
  135. 135

    AVG Aggregate

    Predict the output.

    Predict Output Easy
  136. 136

    GROUP BY Count

    Predict the output.

    Predict Output Easy
  137. 137

    HAVING Filter

    Predict the output.

    Predict Output Medium
  138. 138

    INNER JOIN Result

    Predict the output.

    Predict Output Easy
  139. 139

    LEFT JOIN Result

    Predict the output.

    Predict Output Easy
  140. 140

    DISTINCT Result

    Predict the output.

    Predict Output Easy
  141. 141

    ORDER BY Result

    Predict the output.

    Predict Output Beginner
  142. 142

    LIMIT Result

    Predict the output.

    Predict Output Beginner
  143. 143

    MIN MAX

    Predict the output.

    Predict Output Easy
  144. 144

    Subquery Result

    Predict the output.

    Predict Output Medium
  145. 145

    COUNT DISTINCT

    Predict the output.

    Predict Output Medium
  146. 146

    UNION Result

    Predict the output.

    Predict Output Medium
  147. 147

    COALESCE Result

    Predict the output.

    Predict Output Medium
  148. 148

    CASE Expression

    Predict the output.

    Predict Output Medium
  149. 149

    String Concatenation

    Predict the output.

    Predict Output Easy
  150. 150

    ROUND Function

    Predict the output.

    Predict Output Easy

Build real projects

Apply what you learned by building guided projects with starter code and solutions.

View projects