Bird
Raised Fist0
SQLquery~20 mins

What is a database in SQL - Practice Questions & Exercises

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Database Basics Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:00remaining
Understanding the core purpose of a database

Which of the following best describes the main purpose of a database?

ATo create graphics and animations for websites
BTo write and compile programming code
CTo store and organize data so it can be easily accessed and managed
DTo design user interfaces for mobile apps
Attempts:
2 left
💡 Hint

Think about what you do when you want to keep information safe and find it quickly later.

🧠 Conceptual
intermediate
1:00remaining
Identifying database components

Which of these is NOT a typical component of a database system?

AWeb browser for internet surfing
BData storage
CUser interface for data entry
DDatabase Management System (DBMS)
Attempts:
2 left
💡 Hint

Think about what parts help manage data versus what is used for browsing the internet.

❓ query_result
advanced
1:30remaining
Query result from a simple database table

Given a table Users with columns id and name, what is the result of this query?

SELECT name FROM Users WHERE id = 2;
SQL
CREATE TABLE Users (id INT, name VARCHAR(20));
INSERT INTO Users VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie');
A[]
B[{'id': 2}]
C[{'name': 'Alice'}]
D[{'name': 'Bob'}]
Attempts:
2 left
💡 Hint

Look for the row where id equals 2 and return the name.

📝 Syntax
advanced
1:30remaining
Identify the syntax error in SQL query

Which option contains a syntax error in the SQL query?

SELECT * FROM Customers WHERE age > 30;
ASELECT * Customers WHERE age > 30;
B;03 > ega EREHW sremotsuC MORF * TCELES
CSELECT * FROM Customers WHERE age > 30
DSELECT * FROM Customers WHERE age > 30;
Attempts:
2 left
💡 Hint

Check if the keyword FROM is used correctly.

❓ optimization
expert
2:00remaining
Optimizing a database query for performance

You have a large table Orders with millions of rows. Which query is likely to run faster?

Option 1: SELECT * FROM Orders WHERE order_date = '2023-01-01';
Option 2: SELECT * FROM Orders WHERE YEAR(order_date) = 2023 AND MONTH(order_date) = 1 AND DAY(order_date) = 1;
AOption 2 runs faster because it breaks the date into parts.
BOption 1 runs faster because it can use an index on order_date directly.
CBoth run at the same speed because they filter the same data.
DNeither runs faster; a full table scan is always needed.
Attempts:
2 left
💡 Hint

Think about how indexes work with functions on columns.

Practice

(1/5)
1. What is a database primarily used for?
easy
A. Writing emails
B. Designing websites
C. Storing and organizing data
D. Creating graphics

Solution

  1. Step 1: Understand the purpose of a database

    A database is designed to store and organize data efficiently.
  2. Step 2: Compare with other options

    Designing websites, writing emails, and creating graphics are not main functions of a database.
  3. Final Answer:

    Storing and organizing data -> Option C
  4. Quick Check:

    Database = Store and organize data [OK]
Hint: Databases store data, not create websites or emails [OK]
Common Mistakes:
  • Confusing database with website design
  • Thinking database is for email writing
  • Mixing database with graphic creation
2. Which SQL command is used to create a new table in a database?
easy
A. INSERT
B. UPDATE
C. SELECT
D. CREATE

Solution

  1. Step 1: Identify the command for creating tables

    The SQL command to create a new table is CREATE.
  2. Step 2: Understand other commands

    INSERT adds data, SELECT retrieves data, and UPDATE modifies data, none create tables.
  3. Final Answer:

    CREATE -> Option D
  4. Quick Check:

    CREATE = Make new table [OK]
Hint: CREATE makes tables; INSERT adds data [OK]
Common Mistakes:
  • Using INSERT to create tables
  • Confusing SELECT with CREATE
  • Thinking UPDATE creates tables
3. Given the table Users with columns id and name, what does this query return?
SELECT name FROM Users WHERE id = 2;
medium
A. User name with id 2
B. All user names
C. User id 2
D. Error: missing table

Solution

  1. Step 1: Analyze the SELECT statement

    The query selects the name column from Users where id equals 2.
  2. Step 2: Understand the WHERE clause effect

    It filters rows to only those with id = 2, so only that user's name is returned.
  3. Final Answer:

    User name with id 2 -> Option A
  4. Quick Check:

    SELECT name WHERE id=2 = User name [OK]
Hint: WHERE filters rows; SELECT picks columns [OK]
Common Mistakes:
  • Thinking it returns all names
  • Confusing id with name in output
  • Assuming syntax error without reason
4. Identify the error in this SQL statement:
SELEC * FROM Customers;
medium
A. Missing table name
B. Typo in SELECT keyword
C. Incorrect use of *
D. No error

Solution

  1. Step 1: Check the SQL keywords

    The keyword SELEC is misspelled; it should be SELECT.
  2. Step 2: Verify other parts

    The table name Customers is present and * is correctly used to select all columns.
  3. Final Answer:

    Typo in SELECT keyword -> Option B
  4. Quick Check:

    SELECT typo causes error [OK]
Hint: Check spelling of SQL keywords carefully [OK]
Common Mistakes:
  • Ignoring keyword typos
  • Thinking * is invalid
  • Assuming missing table name
5. You want to store information about books with columns id, title, and author. Which SQL command correctly creates this table?
hard
A. CREATE TABLE Books (id INT, title VARCHAR(100), author VARCHAR(100));
B. INSERT INTO Books (id, title, author);
C. SELECT id, title, author FROM Books;
D. UPDATE Books SET title = 'New Title';

Solution

  1. Step 1: Identify the command to create a table

    The CREATE TABLE command defines a new table with specified columns and types.
  2. Step 2: Check the syntax correctness

    CREATE TABLE Books (id INT, title VARCHAR(100), author VARCHAR(100)); correctly uses CREATE TABLE with column names and data types.
  3. Step 3: Understand other commands

    INSERT INTO adds data, SELECT retrieves data, and UPDATE modifies data, none create tables.
  4. Final Answer:

    CREATE TABLE Books (id INT, title VARCHAR(100), author VARCHAR(100)); -> Option A
  5. Quick Check:

    CREATE TABLE defines structure [OK]
Hint: CREATE TABLE defines columns and types [OK]
Common Mistakes:
  • Using INSERT to create tables
  • Confusing SELECT with CREATE
  • Trying to UPDATE before table exists
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard