---
title: "SQL: Query Fundamentals & Database Concepts"
description: "Master the fundamentals of Relational Databases, from basic SELECT statements to complex JOIN operations and database normalization."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/sql-query-fundamentals-quiz
---

# SQL: Query Fundamentals & Database Concepts

Welcome to the SQL Basics Quiz! Relational databases are the bedrock of modern applications. Whether you're a developer writing queries or a DevOps engineer maintaining a production cluster, mastering SQL is essential for data integrity and system performance. This quiz will test your knowledge from basic selection to complex joins and database management. Good luck!

## Questions

### 1. What does "SQL" stand for?

- Simple Query Language
  - SQL is powerful and structured; "Simple" is a common misnomer.
- **Structured Query Language** ✅
  - SQL is the standard language for managing data in Relational Database Management Systems.
- System Query Logic
  - Logic refers to the internal processing, not the name of the language itself.
- Standard Queue List
  - A queue is a specific data structure, distinct from a database query language.

**Hint:** A language for structures.

### 2. Which SQL statement is used to extract data from a database?

- GET
  - GET is primarily used in HTTP requests for REST APIs, not SQL.
- **SELECT** ✅
  - The SELECT statement retrieves specific data from one or more database tables.
- EXTRACT
  - EXTRACT is typically a function used to pull date parts, not a top-level retrieval command.
- FETCH
  - While FETCH is used in cursors, SELECT is the standard command for data extraction.

**Hint:** Retrieves records.

### 3. Which clause is used to filter records based on a specific condition?

- IF
  - IF is used for procedural logic, while WHERE is used for set filtering.
- **WHERE** ✅
  - The WHERE clause limits query results to rows that meet a defined criteria.
- FILTER
  - FILTER is used in specific aggregate window functions, not general row selection.
- CONDITION
  - CONDITION is a descriptive term, not a valid SQL keyword for filtering rows.

**Hint:** Filters the rows.

### 4. What is the purpose of the "INNER JOIN" keyword?

- To merge only the primary keys of two unrelated tables
  - Joins rely on matching values, not just primary keys in isolation.
- **To return records that have matching values in both tables** ✅
  - INNER JOIN selects rows that have corresponding values in both the left and right tables.
- To combine all rows from all tables regardless of matches
  - This describes a FULL OUTER JOIN, which includes non-matching rows.
- To create a copy of a table within the same database schema
  - This describes a CLONE or SELECT INTO operation.

**Hint:** Matches both sides.

### 5. Which SQL command is used to update existing data in a table?

- MODIFY
  - MODIFY is used in ALTER TABLE to change column definitions, not row data.
- **UPDATE** ✅
  - The UPDATE command modifies existing records in a table based on a condition.
- REPLACE
  - REPLACE is a specific command that deletes and re-inserts, rather than updating.
- CHANGE
  - CHANGE is used in specific SQL dialects like MySQL to rename columns.

**Hint:** Modify values.

### 6. What is a "Primary Key"?

- The first column created during the table definition
  - Positioning does not determine the primary key; the constraint does.
- **A column that uniquely identifies each row in a table** ✅
  - A Primary Key must contain unique values and cannot contain NULLs.
- The encrypted password used to access the database server
  - This is an authentication credential, not a table-level key.
- A metadata tag that describes the purpose of the database
  - Metadata describes data, but it is not a primary key constraint.

**Hint:** Unique identifier.

### 7. What is a "Foreign Key"?

- **A column that establishes a relationship between two tables** ✅
  - Foreign keys reference the primary key of another table to maintain referential integrity.
- A secondary index used to speed up complex query joins
  - While they help joins, their primary purpose is relational integrity, not speed.
- A backup identifier used when the primary key is corrupted
  - Foreign keys are for relationships, not for data recovery.
- An external API key used to connect to third-party databases
  - This refers to an integration secret, not a database schema key.

**Hint:** Links to another table.

### 8. How do you sort the result set in SQL?

- SORT BY
  - While intuitive, SORT BY is not the standard SQL keyword for ordering.
- **ORDER BY** ✅
  - The ORDER BY clause sorts the result set in ascending or descending order.
- ARRANGE
  - ARRANGE is not a valid SQL command for data sorting.
- GROUP BY
  - GROUP BY is used for aggregation, not for simple row sorting.

**Hint:** Arrange the rows.

### 9. What is the "LEFT JOIN" keyword used for?

- **To return all records from the left table and matched records from the right** ✅
  - Rows from the left table are always included; right-side columns are NULL if no match exists.
- To return only the records that exist in the left table but not the right
  - This describes an Anti-Join, often achieved using a WHERE clause checking for NULL.
- To merge columns from two tables without checking for matching values
  - This describes a CROSS JOIN or Cartesian product.
- To remove the right-most columns from the final query result
  - Joins add data; they do not truncate columns based on position.

**Hint:** Keep everything from the left.

### 10. What is "Database Normalization"?

- The process of compressing data to save physical disk space
  - Normalization focuses on logic and redundancy, not file-level compression.
- **Organizing data to minimize redundancy and maximize data integrity** ✅
  - Normalization involves structuring tables to reduce dependency and duplication.
- Converting all non-standard data types into string formats
  - This is data casting or sanitization, not normalization.
- The automated process of fixing corrupted database indexes
  - This is database maintenance or repair.

**Hint:** Reducing redundancy.

### 11. Which SQL command is used to remove a table from a database?

- DELETE
  - DELETE removes rows but leaves the table and its columns intact.
- **DROP** ✅
  - DROP removes the entire table structure and all its data permanently.
- REMOVE
  - REMOVE is not a standard SQL command for dropping objects.
- TRUNCATE
  - TRUNCATE empties the data from a table but preserves its structure.

**Hint:** Deletes the structure.

### 12. What is the "GROUP BY" clause used for?

- To arrange the query results in alphabetical order
  - Use ORDER BY for alphabetical or numerical sorting.
- **To arrange rows with identical values into summary rows** ✅
  - GROUP BY is used with aggregate functions to provide summary statistics.
- To limit the number of users who can access a table
  - This describes access control or permissions management.
- To join multiple tables into a single virtual view
  - This describes a JOIN or the creation of a VIEW.

**Hint:** Used with COUNT, SUM, or AVG.

### 13. Which aggregate function finds the number of rows in a table?

- SUM()
  - SUM() adds the numeric values of a specific column.
- **COUNT()** ✅
  - COUNT() returns the number of rows that match a specific criteria.
- TOTAL()
  - TOTAL is not a standard SQL aggregate; SUM or COUNT are used instead.
- ADD()
  - ADD is not a valid SQL aggregate function for counting records.

**Hint:** Total amount.

### 14. What is the "HAVING" clause used for?

- To filter rows before they are processed by a join
  - Filtering before processing is the role of the WHERE clause.
- **To filter groups based on a condition after aggregation** ✅
  - HAVING is used to filter the results of a GROUP BY operation.
- To define a primary key on a newly created table
  - Primary keys are defined using CONSTRAINT keywords.
- To check if a subquery returns any valid results
  - This describes the EXISTS operator.

**Hint:** Filter for groups.

### 15. What does "NULL" represent in SQL?

- A value of zero for numerical columns
  - Zero is a definite value; NULL represents the absence of a value.
- **The state of a value being missing or unknown** ✅
  - NULL signifies that no value is stored for a particular record.
- An empty string within a character column
  - An empty string ("") is a value; NULL is not.
- A boolean value indicating a false condition
  - False is a defined boolean state; NULL is unknown.

**Hint:** Empty vs Unknown.

### 16. Which keyword is used to return only unique values?

- UNIQUE
  - UNIQUE is a table constraint, not a query retrieval keyword.
- **DISTINCT** ✅
  - DISTINCT removes duplicate rows from the query result set.
- DIFFERENT
  - DIFFERENT is not a valid SQL command for unique selection.
- SINGLE
  - SINGLE is not used in SQL to filter duplicate records.

**Hint:** No duplicates.

### 17. What is the purpose of the "LIKE" operator?

- To verify that two tables have identical column names
  - This describes a schema comparison, not a data operator.
- **To search for a specified pattern within a string column** ✅
  - LIKE uses wildcards like % and \_ to find partial string matches.
- To join tables that have similar data structures
  - Joins rely on equality or logic, not "likeness" patterns.
- To sort data based on the similarity of text values
  - Sorting uses ORDER BY; LIKE is for filtering.

**Hint:** Pattern matching.

### 18. What is a "Transaction" in SQL?

- A single data transfer between two different servers
  - This describes a migration or replication task.
- **A unit of work that succeeds or fails as a complete set** ✅
  - Transactions ensure atomicity, keeping data consistent during multiple steps.
- The history of all changes made to a specific record
  - This is an audit log or version history.
- An individual row within a financial ledger table
  - While financial, a "transaction" in SQL is a structural unit of operations.

**Hint:** All or nothing.

### 19. What is an "Index" used for?

- To define the order in which columns appear in a query
  - Column order is defined in the SELECT statement, not by an index.
- **To provide a faster lookup path for retrieving data rows** ✅
  - Indexes improve search performance at the cost of slower writes.
- To map the physical location of the database on the disk
  - This is handled by the database engine’s storage manager.
- To count the total number of tables in a database schema
  - This is performed via metadata queries to information_schema.

**Hint:** Speeding up reads.

### 20. Which SQL command is used to add new rows to a table?

- ADD DATA
  - ADD is used to modify schemas, not to insert record data.
- **INSERT INTO** ✅
  - INSERT INTO adds new records to an existing table structure.
- PUSH
  - PUSH is a command for arrays or git, not standard SQL.
- CREATE ROW
  - CREATE is for objects like tables; INSERT is for the rows inside.

**Hint:** Put data in.

### 21. What is a "View" in SQL?

- A graphical user interface for browsing database tables
  - This describes a GUI client like pgAdmin or MySQL Workbench.
- **A virtual table based on the results of a stored query** ✅
  - Views provide a simplified, pre-defined look at data without storing it.
- A snapshot of the database used for backup and recovery
  - This describes a Database Snapshot or Backup.
- A read-only permission level assigned to guest users
  - This describes an Access Control List (ACL) or Role.

**Hint:** A virtual table.

### 22. What does the "AS" keyword do?

- It permanentely renames a column in the database schema
  - Renaming the schema requires ALTER TABLE, not the AS keyword.
- **It creates a temporary alias for a column or table in a query** ✅
  - AS makes output column names or joined table names more readable.
- It assigns a specific data type to a new table column
  - Data types are assigned during table creation or alteration.
- It encrypts the results of a SELECT statement
  - Encryption is handled via functions or transport layers, not AS.

**Hint:** Nicknaming.

### 23. What is a "Constraint" in SQL?

- A physical limitation on the size of the database file
  - Storage limits are handled by OS or hardware constraints.
- **A rule enforced on columns to ensure data accuracy and reliability** ✅
  - Constraints like NOT NULL and UNIQUE prevent invalid data entry.
- A performance bottleneck caused by too many concurrent users
  - This is a resource bottleneck, not a database constraint.
- A piece of code that prevents a table from being deleted
  - Table protection is handled by permissions and roles.

**Hint:** Rules for data.

### 24. Which command changes the structure of an existing table?

- UPDATE TABLE
  - UPDATE changes row data, not the table structure.
- **ALTER TABLE** ✅
  - ALTER TABLE is used to add, delete, or modify columns in a table.
- RESTRUCTURE
  - RESTRUCTURE is not a standard SQL keyword for schema changes.
- MODIFY SCHEMA
  - The standard command for modifying existing objects is ALTER.

**Hint:** Modify columns.

### 25. What is "Referential Integrity"?

- The guarantee that every query will return at least one row
  - Queries can validly return empty sets; this is not related to integrity.
- **The consistency between tables maintained via foreign key constraints** ✅
  - It ensures that relationships between rows in different tables remain valid.
- The encryption level applied to data while it is in transit
  - This is data-in-transit security, not referential integrity.
- The speed at which a primary key can be looked up in a query
  - This is index performance, not data integrity.

**Hint:** Relationships must be valid.

### 26. What does the "UNION" operator do?

- It multiplies the numeric values of two distinct result sets
  - Mathematical operations are done with operators like \* or SUM.
- **It combines the results of two SELECT statements into one set** ✅
  - UNION stacks results from multiple queries, removing duplicates by default.
- It joins two tables based on a common identifier
  - This describes a JOIN operation, not a UNION.
- It creates a link between a primary and secondary database
  - This describes database federation or linking.

**Hint:** Stacks results.

### 27. What is a "Stored Procedure"?

- A hardware configuration used to store large database files
  - Stored procedures are software logic, not hardware.
- **A group of SQL statements that can be saved and reused** ✅
  - Procedures encapsulate logic on the database server for efficiency.
- A log of all actions taken by a database administrator
  - This is an administrative audit trail.
- An automated backup routine scheduled by the system
  - This is a database job or maintenance task.

**Hint:** Saved SQL code.

### 28. What is the "TRUNCATE" command?

- It deletes the table structure and its associated permissions
  - This is the role of the DROP command.
- **It removes all records from a table while keeping the structure** ✅
  - TRUNCATE is a fast way to empty a table without logging individual row deletions.
- It limits the number of characters allowed in a string column
  - This is a data type constraint (e.g., VARCHAR(50)).
- It hides specific rows from users without deleting them
  - This describes row-level security or a filtered view.

**Hint:** Fast delete all rows.

### 29. What does "ACID" stand for in database terms?

- Automated, Clean, Integrated, Distributed
  - While positive traits, these are not the ACID properties.
- **Atomicity, Consistency, Isolation, Durability** ✅
  - These properties guarantee that database transactions are processed reliably.
- Access, Control, Integrity, Data
  - These are general security terms, not the transaction properties.
- Allocate, Commit, Initialize, Deploy
  - These are deployment or programming steps, not database properties.

**Hint:** Reliability properties.

### 30. What is the difference between "DELETE" and "TRUNCATE"?

- **DELETE can remove specific rows, whereas TRUNCATE empties the whole table** ✅
  - DELETE uses a WHERE clause for selection; TRUNCATE is an all-or-nothing DDL operation.
- DELETE is used for NoSQL databases, while TRUNCATE is for SQL only
  - Both are standard SQL commands for relational databases.
- TRUNCATE can be rolled back in all databases, but DELETE cannot
  - DELETE is always rollback-safe; TRUNCATE behavior varies by database engine.
- DELETE removes the table structure, but TRUNCATE keeps it
  - Both keep the structure; DROP is required to remove the structure.

**Hint:** Logging and speed.
