Practice Databases MCQs for HEC USAT-CS (Computer Science) computer science — topic-wise sets with solved answers.
Q1. Which database model organizes data into tables with well-defined schemas?
Answer: Relational
Explanation: Relational databases organize data into tables with well-defined schemas, using primary and foreign keys to establish relationships.
Q2. What is the purpose of indexing in databases?
Answer: To enhance query performance
Explanation: Indexing improves query performance by allowing the database to quickly locate specific data.
Q3. Which SQL clause is used to filter groups of rows?
Answer: HAVING
Explanation: The HAVING clause filters groups of rows based on conditions applied to grouped data.
Q4. What is the result of a FULL OUTER JOIN operation?
Answer: All rows from both tables, with NULLs in non-matching columns
Explanation: A FULL OUTER JOIN returns all rows from both tables, with NULLs in columns where there are no matches.
Q5. Which database concept ensures that the database remains in a consistent state?
Answer: Consistency
Explanation: Consistency ensures that the database remains in a valid state, even after multiple transactions.
Q6. What is the purpose of a transaction log in a database?
Answer: To record changes made to the database
Explanation: A transaction log records changes made to the database, allowing for recovery in case of failures.
Q7. Which data modeling approach represents data as a collection of objects?
Answer: Object-Oriented
Explanation: Object-Oriented data modeling represents data as a collection of objects, encapsulating data and behavior.
Q8. What is the difference between a PRIMARY KEY and a UNIQUE constraint?
Answer: A PRIMARY KEY cannot be NULL, while a UNIQUE constraint can have one NULL value
Explanation: A PRIMARY KEY uniquely identifies each row and cannot be NULL, while a UNIQUE constraint ensures uniqueness but allows one NULL value.
Q9. Which database normalization rule eliminates transitive dependencies?
Answer: 3NF
Explanation: 3NF eliminates transitive dependencies by ensuring that non-key attributes depend only on the primary key.
Q10. What is the purpose of a database view?
Answer: To simplify complex queries
Explanation: A database view simplifies complex queries by providing a virtual table based on a SELECT statement.
Q11. Which SQL statement is used to modify the structure of a database table?
Answer: ALTER
Explanation: The ALTER statement modifies the structure of a database table, such as adding or dropping columns.
Q12. What is the result of a LEFT JOIN operation?
Answer: All rows from the left table, with NULLs in non-matching columns
Explanation: A LEFT JOIN returns all rows from the left table, with NULLs in columns where there are no matches in the right table.
Q13. Which database concept ensures that transactions are executed independently?
Answer: Isolation
Explanation: Isolation ensures that transactions are executed independently, without interference from other transactions.
Q14. What is the purpose of a stored procedure?
Answer: To encapsulate a set of SQL statements
Explanation: A stored procedure encapsulates a set of SQL statements, improving code reusability and maintainability.
Q15. Which data type is used to store binary data in a database?
Answer: BLOB
Explanation: BLOB (Binary Large OBject) is used to store binary data, such as images or audio files.
Q16. What is the purpose of a database trigger?
Answer: To automate actions based on database events
Explanation: A database trigger automates actions based on database events, such as insert, update, or delete operations.
Q17. Which database normalization rule eliminates repeating groups?
Answer: 1NF
Explanation: 1NF eliminates repeating groups by ensuring that each cell contains a single value.
Q18. What is the result of an INNER JOIN operation?
Answer: Only matching rows from both tables
Explanation: An INNER JOIN returns only the rows that have matches in both tables.
Q19. Which SQL clause is used to sort the result set?
Answer: ORDER BY
Explanation: The ORDER BY clause sorts the result set in ascending or descending order based on one or more columns.
Q20. What is the purpose of a database index?
Answer: To enhance query performance
Explanation: A database index enhances query performance by allowing the database to quickly locate specific data.
Loading...