Primary keys and foreign keys MCQs in DBMS

By: Prof. Dr. Fazal Rehman Shamil | Last updated: September 23, 2024

MCQs on Primary Keys and Foreign Keys

  1. What is a primary key?
    • a) A field in a table which uniquely identifies each row/record in that table
    • b) A field in a table which holds the unique value for another table
    • c) A field in a table which can have null values
    • d) A field in a table which can have duplicate values

    Answer: a) A field in a table which uniquely identifies each row/record in that table

  2. What is a foreign key?
    • a) A field in a table which uniquely identifies each row/record in that table
    • b) A field in a table which is a primary key in another table
    • c) A field in a table which holds the unique value for another table
    • d) A field in a table which can have duplicate values

    Answer: b) A field in a table which is a primary key in another table

  3. Which of the following is true about primary keys?
    • a) They can contain null values.
    • b) They must contain unique values.
    • c) They can contain duplicate values.
    • d) They are optional in a table.

    Answer: b) They must contain unique values.

  4. Which constraint is used to link two tables together?
    • a) UNIQUE
    • b) CHECK
    • c) FOREIGN KEY
    • d) PRIMARY KEY

    Answer: c) FOREIGN KEY

  5. What happens if a foreign key constraint is violated?
    • a) The transaction is rolled back.
    • b) The constraint is ignored.
    • c) A warning is generated.
    • d) The row is still inserted/updated.

    Answer: a) The transaction is rolled back.

  6. In the context of database relationships, what does referential integrity ensure?
    • a) All foreign key values point to existing primary key values.
    • b) All primary key values are unique.
    • c) All tables are properly indexed.
    • d) All columns have unique names.

    Answer: a) All foreign key values point to existing primary key values.

  7. Which of the following statements about composite primary keys is true?
    • a) They can consist of one or more columns.
    • b) They can consist of two or more columns.
    • c) They must consist of exactly two columns.
    • d) They can consist of only one column.

    Answer: b) They can consist of two or more columns.

  8. What is the purpose of a primary key in a table?
    • a) To ensure that no two rows have the same value in this column.
    • b) To link two tables together.
    • c) To enforce domain integrity.
    • d) To allow null values in this column.

    Answer: a) To ensure that no two rows have the same value in this column.

  9. Which SQL keyword is used to define a foreign key constraint?
    • a) FOREIGN
    • b) REFERENCES
    • c) LINK
    • d) JOIN

    Answer: b) REFERENCES

  10. What is the main difference between a primary key and a foreign key?
    • a) A primary key ensures referential integrity; a foreign key ensures entity integrity.
    • b) A primary key uniquely identifies a record in its own table; a foreign key identifies a record in another table.
    • c) A primary key allows null values; a foreign key does not.
    • d) A primary key can have duplicate values; a foreign key cannot.

    Answer: b) A primary key uniquely identifies a record in its own table; a foreign key identifies a record in another table.

 

More MCQs Of Database Systems

  1. Database Models MCQs in DBMS
    1. Hierarchical model MCQs in DBMS
    2. Network model MCQs in DBMS
    3. Relational model MCQs in DBMS
    4. Object-oriented model MCQs in DBMS
    5. NoSQL databases MCQs in DBMS
  2. Relational Database Model MCQs in DBMS
    1. tables, attributes, tuples, and relations MCQs in DBMS
    2. Primary keys and foreign keys MCQs in DBMS
    3. Integrity constraints MCQs in DBMS
  3. SQL (Structured Query Language) MCQs in DBMS
    1. Data Definition Language (DDL) MCQs in DBMS
    2. Data Manipulation Language (DML) MCQs in DBMS
    3. Data Control Language (DCL) MCQs in DBMS
    4. Transaction Control Language (TCL) MCQs in DBMS
    5. Advanced SQL queries and functions MCQs in DBMS
  4. Database Design MCQs in DBMS
    1. Entity-Relationship (ER) modeling MCQs in DBMS
    2. Extended ER modeling MCQs in DBMS
    3. Normalization and normal forms (1NF, 2NF, 3NF, BCNF) MCQs in DBMS
    4. Denormalization MCQs in DBMS
  5. Database Management System Architecture MCQs in DBMS
    1. Three-schema architecture (external, conceptual, internal) MCQs in DBMS
    2. Data independence MCQs in DBMS
    3. DBMS components and functions MCQs in DBMS
  6. Storage and File Structure MCQs in DBMS
    1. Data storage on physical media MCQs in DBMS
    2. File organization and access methods MCQs
    3. Indexing (B-trees, hash indexing) MCQs in DBMS
    4. RAID technology MCQs in DBMS
  7. Query Processing and Optimization MCQs in DBMS
  8. Database Transaction Management MCQs in DBMS
    1. ACID properties (Atomicity, Consistency, Isolation, Durability) MCQs in DBMS
    2. Transaction states and lifecycle MCQs in DBMS
    3. Concurrency control techniques (locking, timestamping, multiversion) MCQs in DBMS
    4. Deadlock detection and resolution MCQs in DBMS
  9. Database Security and Authorization MCQs in DBMS
    1. Authentication and authorization mechanisms MCQs in DBMS
    2. Data encryption techniques MCQs in DBMS
    3. Role-based access control MCQs in DBMS
    4. SQL injection prevention MCQs in DBMS
  10. Backup and Recovery MCQs in DBMS
    1. Backup types and strategies MCQs in DBMS
    2. Recovery techniques (log-based, shadow paging) MCQs in DBMS
    3. Disaster recovery planning MCQs in DBMS
  11. Distributed Databases MCQs in DBMS
    1. Distributed database architecture MCQs MCQs in DBMS
    2. Data fragmentation, replication, and allocation in DBMS
    3. Distributed query processing MCQs in DBMS
    4. Consistency models and protocols MCQs in DBMS
  1. SET 1: database design mcqs (database design mcqs )
  2. SET 2: database mcqs with answers pdf (database mcqs with answers pdf )
  3. SET 3: modern database management 12th edition mcqs (modern database management 12th edition mcqs)
  4. SET 4: database systems mcqs (database systems mcqs)
  5. SET 5: dbms mcqs (dbms mcqs )
  6. SET 6: dbms mcqs with answers (dbms mcqs with answers)
  7. SET 7: solved mcqs of dbms (solved mcqs of dbms)
  8. SET 8: dbms mcqs with answers pdf(dbms mcqs with answers pdf)
  9. SET 9: relational database management system mcqs(relational database management system mcqs)
  10. SET 10: solved mcqs of database management system(solved mcqs of database management system)
  11. SET 11: basic database mcqs pdf (basic database mcqs pdf)
  12. SET 12: relational database management system mcqs (relational database management system mcqs )
  13. SET 13: database mcqs online test (database mcqs online test)
  14. SET 14: database interview questions mcqs (database interview questions mcqs)
  15. SET 15: database developer mcqs (database developer mcqs)
  16. SET 16: database Repeated mcqs (database Repeated mcqs)
  17. SET 17: Database mcqs PPSC (Database mcqs PPSC)
  18. SET 18: Database mcqs FPSC (Database mcqs FPSC)
  19. SET 19: DBMS mcqs FPSC (DBMS mcqs FPSC)

New Arrival

Database interview questions