MCQs on Primary Keys and Foreign Keys
- 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
- 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
- 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.
- Which constraint is used to link two tables together?
- a) UNIQUE
- b) CHECK
- c) FOREIGN KEY
- d) PRIMARY KEY
Answer: c) FOREIGN KEY
- 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.
- 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.
- 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.
- 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.
- Which SQL keyword is used to define a foreign key constraint?
- a) FOREIGN
- b) REFERENCES
- c) LINK
- d) JOIN
Answer: b) REFERENCES
- 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
- Database Models MCQs in DBMS
- Relational Database Model MCQs in DBMS
- SQL (Structured Query Language) MCQs in DBMS
- Database Design MCQs in DBMS
- Database Management System Architecture MCQs in DBMS
- Storage and File Structure MCQs in DBMS
- Query Processing and Optimization MCQs in DBMS
- Database Transaction Management MCQs in DBMS
- Database Security and Authorization MCQs in DBMS
- Backup and Recovery MCQs in DBMS
- Distributed Databases MCQs in DBMS
- SET 1: database design mcqs (database design mcqs )
- SET 2: database mcqs with answers pdf (database mcqs with answers pdf )
- SET 3: modern database management 12th edition mcqs (modern database management 12th edition mcqs)
- SET 4: database systems mcqs (database systems mcqs)
- SET 5: dbms mcqs (dbms mcqs )
- SET 6: dbms mcqs with answers (dbms mcqs with answers)
- SET 7: solved mcqs of dbms (solved mcqs of dbms)
- SET 8: dbms mcqs with answers pdf(dbms mcqs with answers pdf)
- SET 9: relational database management system mcqs(relational database management system mcqs)
- SET 10: solved mcqs of database management system(solved mcqs of database management system)
- SET 11: basic database mcqs pdf (basic database mcqs pdf)
- SET 12: relational database management system mcqs (relational database management system mcqs )
- SET 13: database mcqs online test (database mcqs online test)
- SET 14: database interview questions mcqs (database interview questions mcqs)
- SET 15: database developer mcqs (database developer mcqs)
- SET 16: database Repeated mcqs (database Repeated mcqs)
- SET 17: Database mcqs PPSC (Database mcqs PPSC)
- SET 18: Database mcqs FPSC (Database mcqs FPSC)
- SET 19: DBMS mcqs FPSC (DBMS mcqs FPSC)
New Arrival