1. A stored procedure in SQL is:
A. A precompiled set of SQL statements that can be executed.
B. A temporary table used to store query results.
C. A method for normalizing data.
D. A database function that returns a value.
Answer: A
Rationale: A stored procedure is a precompiled set of SQL statements that can be
executed repeatedly, which helps with code reuse and performance optimization.
2. Which of the following would be a composite attribute in an entity-relationship
diagram?
A. Name
B. Address
C. Phone number
D. Date of birth
Answer: B
,Rationale: An address is a composite attribute because it consists of multiple sub-
attributes such as street, city, state, and postal code.
3. Which SQL clause is used to filter records in a SELECT statement?
A. WHERE
B. GROUP BY
C. ORDER BY
D. HAVING
Answer: A
Rationale: The WHERE clause is used to filter records based on a specified
condition in a SELECT statement.
4. A trigger in a database is used to:
A. Automatically execute predefined actions in response to certain events.
B. Create a backup of the database.
C. Aggregate data from multiple tables.
D. Index a column for faster queries.
Answer: A
, Rationale: A trigger automatically executes a predefined action, such as inserting,
updating, or deleting data, in response to events like an INSERT or UPDATE.
5. What is an index used for in a database?
A. To store large amounts of data.
B. To increase query performance by allowing faster lookups.
C. To ensure referential integrity.
D. To group data together for backup purposes.
Answer: B
Rationale: An index is a database object that improves the speed of data retrieval
operations by allowing faster searches and lookups based on indexed columns.
6. What is the purpose of the SQL HAVING clause?
A. To filter records after aggregation.
B. To group data based on a column.
C. To create new views.
D. To define foreign keys.
Answer: A
A. A precompiled set of SQL statements that can be executed.
B. A temporary table used to store query results.
C. A method for normalizing data.
D. A database function that returns a value.
Answer: A
Rationale: A stored procedure is a precompiled set of SQL statements that can be
executed repeatedly, which helps with code reuse and performance optimization.
2. Which of the following would be a composite attribute in an entity-relationship
diagram?
A. Name
B. Address
C. Phone number
D. Date of birth
Answer: B
,Rationale: An address is a composite attribute because it consists of multiple sub-
attributes such as street, city, state, and postal code.
3. Which SQL clause is used to filter records in a SELECT statement?
A. WHERE
B. GROUP BY
C. ORDER BY
D. HAVING
Answer: A
Rationale: The WHERE clause is used to filter records based on a specified
condition in a SELECT statement.
4. A trigger in a database is used to:
A. Automatically execute predefined actions in response to certain events.
B. Create a backup of the database.
C. Aggregate data from multiple tables.
D. Index a column for faster queries.
Answer: A
, Rationale: A trigger automatically executes a predefined action, such as inserting,
updating, or deleting data, in response to events like an INSERT or UPDATE.
5. What is an index used for in a database?
A. To store large amounts of data.
B. To increase query performance by allowing faster lookups.
C. To ensure referential integrity.
D. To group data together for backup purposes.
Answer: B
Rationale: An index is a database object that improves the speed of data retrieval
operations by allowing faster searches and lookups based on indexed columns.
6. What is the purpose of the SQL HAVING clause?
A. To filter records after aggregation.
B. To group data based on a column.
C. To create new views.
D. To define foreign keys.
Answer: A