1. What is the difference between a JOIN and a UNION in SQL?
A. JOIN combines rows from two tables based on a related column; UNION
combines the result sets of two queries
B. JOIN combines columns from two tables; UNION combines rows from two
queries
C. JOIN creates a new table; UNION deletes duplicate rows
D. JOIN can only be used on primary keys; UNION can only be used on foreign
keys
Answer: A) JOIN combines rows from two tables based on a related column;
UNION combines the result sets of two queries
Rationale: A JOIN is used to combine rows from two or more tables based on a
related column, while UNION combines results from multiple queries into a single
result set.
2. What is a "trigger" in SQL?
A. A set of SQL statements that automatically execute when certain events occur
B. A command used to manipulate data in a table
,C. A way to enforce referential integrity
D. A command that imports data into the database
Answer: A) A set of SQL statements that automatically execute when certain
events occur
Rationale: A trigger is a stored procedure that automatically runs when certain
events (such as an INSERT, UPDATE, or DELETE) occur on a table.
3. What is the purpose of indexing in databases?
A. To make the database more secure
B. To speed up query processing
C. To normalize the database
D. To backup the database
Answer: B) To speed up query processing
Rationale: Indexing helps to speed up data retrieval operations by providing quick
access paths to data, reducing the time for query execution.
4. Which of the following best describes a relational database?
A. A database where data is stored in flat files
, B. A database that uses tables to store data and relationships between data
C. A database that does not support queries
D. A database that stores unstructured data
Answer: B) A database that uses tables to store data and relationships between data
Rationale: A relational database uses tables (relations) to organize data and
supports relationships between those tables.
5. What is the purpose of the GROUP BY clause in SQL?
A. To order the results of a query
B. To filter rows based on conditions
C. To combine multiple rows into a single summary row
D. To limit the number of rows returned
Answer: C) To combine multiple rows into a single summary row
Rationale: GROUP BY is used to group rows that have the same values in
specified columns into summary rows, often used with aggregate functions like
COUNT, SUM, or AVG.
6. What is a "recursive query" in SQL?
A. JOIN combines rows from two tables based on a related column; UNION
combines the result sets of two queries
B. JOIN combines columns from two tables; UNION combines rows from two
queries
C. JOIN creates a new table; UNION deletes duplicate rows
D. JOIN can only be used on primary keys; UNION can only be used on foreign
keys
Answer: A) JOIN combines rows from two tables based on a related column;
UNION combines the result sets of two queries
Rationale: A JOIN is used to combine rows from two or more tables based on a
related column, while UNION combines results from multiple queries into a single
result set.
2. What is a "trigger" in SQL?
A. A set of SQL statements that automatically execute when certain events occur
B. A command used to manipulate data in a table
,C. A way to enforce referential integrity
D. A command that imports data into the database
Answer: A) A set of SQL statements that automatically execute when certain
events occur
Rationale: A trigger is a stored procedure that automatically runs when certain
events (such as an INSERT, UPDATE, or DELETE) occur on a table.
3. What is the purpose of indexing in databases?
A. To make the database more secure
B. To speed up query processing
C. To normalize the database
D. To backup the database
Answer: B) To speed up query processing
Rationale: Indexing helps to speed up data retrieval operations by providing quick
access paths to data, reducing the time for query execution.
4. Which of the following best describes a relational database?
A. A database where data is stored in flat files
, B. A database that uses tables to store data and relationships between data
C. A database that does not support queries
D. A database that stores unstructured data
Answer: B) A database that uses tables to store data and relationships between data
Rationale: A relational database uses tables (relations) to organize data and
supports relationships between those tables.
5. What is the purpose of the GROUP BY clause in SQL?
A. To order the results of a query
B. To filter rows based on conditions
C. To combine multiple rows into a single summary row
D. To limit the number of rows returned
Answer: C) To combine multiple rows into a single summary row
Rationale: GROUP BY is used to group rows that have the same values in
specified columns into summary rows, often used with aggregate functions like
COUNT, SUM, or AVG.
6. What is a "recursive query" in SQL?