HEC USAT-CS (Computer Science) computer science: Databases MCQs

Practice Databases MCQs for HEC USAT-CS (Computer Science) computer science — topic-wise sets with solved answers.

HEC USAT-CS (Computer Science) computer science: Databases MCQs — sample questions

  1. Question 1

    Q1. Which database model organizes data into tables with well-defined schemas?

    • A) Hierarchical
    • B) Relational
    • C) Network
    • D) Object-Oriented

    Answer: Relational

    Explanation: Relational databases organize data into tables with well-defined schemas, using primary and foreign keys to establish relationships.

  2. Question 2

    Q2. What is the purpose of indexing in databases?

    • A) To improve data integrity
    • B) To enhance query performance
    • C) To ensure data consistency
    • D) To reduce storage space

    Answer: To enhance query performance

    Explanation: Indexing improves query performance by allowing the database to quickly locate specific data.

  3. Question 3

    Q3. Which SQL clause is used to filter groups of rows?

    • A) WHERE
    • B) HAVING
    • C) GROUP BY
    • D) ORDER BY

    Answer: HAVING

    Explanation: The HAVING clause filters groups of rows based on conditions applied to grouped data.

  4. Question 4

    Q4. What is the result of a FULL OUTER JOIN operation?

    • A) Only matching rows from both tables
    • B) All rows from both tables, with NULLs in non-matching columns
    • C) Only rows from the left table
    • D) Only rows from the right table

    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.

  5. Question 5

    Q5. Which database concept ensures that the database remains in a consistent state?

    • A) Atomicity
    • B) Consistency
    • C) Isolation
    • D) Durability

    Answer: Consistency

    Explanation: Consistency ensures that the database remains in a valid state, even after multiple transactions.

  6. Question 6

    Q6. What is the purpose of a transaction log in a database?

    • A) To store database metadata
    • B) To record changes made to the database
    • C) To optimize query performance
    • D) To improve data security

    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.

  7. Question 7

    Q7. Which data modeling approach represents data as a collection of objects?

    • A) Relational
    • B) Object-Oriented
    • C) Entity-Relationship
    • D) Dimensional

    Answer: Object-Oriented

    Explanation: Object-Oriented data modeling represents data as a collection of objects, encapsulating data and behavior.

  8. Question 8

    Q8. What is the difference between a PRIMARY KEY and a UNIQUE constraint?

    • A) A PRIMARY KEY allows NULL values
    • B) A UNIQUE constraint allows duplicate values
    • C) A PRIMARY KEY is used for indexing
    • D) A PRIMARY KEY cannot be NULL, while a UNIQUE constraint can have one NULL value

    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.

  9. Question 9

    Q9. Which database normalization rule eliminates transitive dependencies?

    • A) 1NF
    • B) 2NF
    • C) 3NF
    • D) BCNF

    Answer: 3NF

    Explanation: 3NF eliminates transitive dependencies by ensuring that non-key attributes depend only on the primary key.

  10. Question 10

    Q10. What is the purpose of a database view?

    • A) To store data in a physical table
    • B) To simplify complex queries
    • C) To improve data security
    • D) To enhance data integrity

    Answer: To simplify complex queries

    Explanation: A database view simplifies complex queries by providing a virtual table based on a SELECT statement.

  11. Question 11

    Q11. Which SQL statement is used to modify the structure of a database table?

    • A) ALTER
    • B) CREATE
    • C) DROP
    • D) TRUNCATE

    Answer: ALTER

    Explanation: The ALTER statement modifies the structure of a database table, such as adding or dropping columns.

  12. Question 12

    Q12. What is the result of a LEFT JOIN operation?

    • A) Only matching rows from both tables
    • B) All rows from the left table, with NULLs in non-matching columns
    • C) Only rows from the right table
    • D) All rows from both tables

    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.

  13. Question 13

    Q13. Which database concept ensures that transactions are executed independently?

    • A) Atomicity
    • B) Consistency
    • C) Isolation
    • D) Durability

    Answer: Isolation

    Explanation: Isolation ensures that transactions are executed independently, without interference from other transactions.

  14. Question 14

    Q14. What is the purpose of a stored procedure?

    • A) To improve data security
    • B) To simplify complex queries
    • C) To encapsulate a set of SQL statements
    • D) To enhance data integrity

    Answer: To encapsulate a set of SQL statements

    Explanation: A stored procedure encapsulates a set of SQL statements, improving code reusability and maintainability.

  15. Question 15

    Q15. Which data type is used to store binary data in a database?

    • A) CHAR
    • B) VARCHAR
    • C) BLOB
    • D) TEXT

    Answer: BLOB

    Explanation: BLOB (Binary Large OBject) is used to store binary data, such as images or audio files.

  16. Question 16

    Q16. What is the purpose of a database trigger?

    • A) To improve data security
    • B) To simplify complex queries
    • C) To automate actions based on database events
    • D) To enhance data integrity

    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.

  17. Question 17

    Q17. Which database normalization rule eliminates repeating groups?

    • A) 1NF
    • B) 2NF
    • C) 3NF
    • D) BCNF

    Answer: 1NF

    Explanation: 1NF eliminates repeating groups by ensuring that each cell contains a single value.

  18. Question 18

    Q18. What is the result of an INNER JOIN operation?

    • A) Only matching rows from both tables
    • B) All rows from both tables
    • C) Only rows from the left table
    • D) Only rows from the right table

    Answer: Only matching rows from both tables

    Explanation: An INNER JOIN returns only the rows that have matches in both tables.

  19. Question 19

    Q19. Which SQL clause is used to sort the result set?

    • A) GROUP BY
    • B) HAVING
    • C) ORDER BY
    • D) WHERE

    Answer: ORDER BY

    Explanation: The ORDER BY clause sorts the result set in ascending or descending order based on one or more columns.

  20. Question 20

    Q20. What is the purpose of a database index?

    • A) To improve data integrity
    • B) To enhance query performance
    • C) To ensure data consistency
    • D) To reduce storage space

    Answer: To enhance query performance

    Explanation: A database index enhances query performance by allowing the database to quickly locate specific data.

Loading...