1. Which of the following refers to a "self-join" in SQL?
A. Joining two tables with the same structure
B. Joining a table to itself
C. Joining tables with no common columns
D. Joining more than two tables simultaneously
Answer: B) Joining a table to itself
Rationale: A self-join is used to join a table to itself, typically using aliases to
distinguish the two instances of the table.
2. Which of the following is a feature of an "object-oriented database"?
A. Data is organized in tables and rows
B. It uses objects to represent data
C. It is primarily used for transactional systems
D. It stores data in a flat, unstructured format
Answer: B) It uses objects to represent data
,Rationale: Object-oriented databases use objects, which can contain both data and
methods, to represent real-world entities.
3. 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.
4. 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.
5. What is a "recursive query" in SQL?
A. A query that uses the GROUP BY clause to aggregate data
B. A query that calls itself to retrieve data from hierarchical structures
C. A query that deletes data from multiple tables
D. A query that modifies the structure of a table
Answer: B) A query that calls itself to retrieve data from hierarchical structures
Rationale: Recursive queries are used to retrieve hierarchical data, like
organizational charts or folder structures, where data refers to itself.
6. Which SQL command is used to modify the structure of an existing table?
A. SELECT
A. Joining two tables with the same structure
B. Joining a table to itself
C. Joining tables with no common columns
D. Joining more than two tables simultaneously
Answer: B) Joining a table to itself
Rationale: A self-join is used to join a table to itself, typically using aliases to
distinguish the two instances of the table.
2. Which of the following is a feature of an "object-oriented database"?
A. Data is organized in tables and rows
B. It uses objects to represent data
C. It is primarily used for transactional systems
D. It stores data in a flat, unstructured format
Answer: B) It uses objects to represent data
,Rationale: Object-oriented databases use objects, which can contain both data and
methods, to represent real-world entities.
3. 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.
4. 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.
5. What is a "recursive query" in SQL?
A. A query that uses the GROUP BY clause to aggregate data
B. A query that calls itself to retrieve data from hierarchical structures
C. A query that deletes data from multiple tables
D. A query that modifies the structure of a table
Answer: B) A query that calls itself to retrieve data from hierarchical structures
Rationale: Recursive queries are used to retrieve hierarchical data, like
organizational charts or folder structures, where data refers to itself.
6. Which SQL command is used to modify the structure of an existing table?
A. SELECT