CCP Relational & NoSQL Database Design 2 — Questions and Answers
Question 1: Which normal form eliminates transitive dependencies among non-key attributes?
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF) (Correct answer)
- Boyce-Codd Normal Form (BCNF)
Correct answer: Third Normal Form (3NF)
3NF removes transitive dependencies where a non-key column depends on another non-key column rather than directly on the primary key.
Question 2: In a relational schema, a foreign key constraint ensures which property?
- Entity integrity
- Referential integrity (Correct answer)
- Domain integrity
- User-defined integrity
Correct answer: Referential integrity
A foreign key constraint enforces referential integrity by ensuring that a value in one table corresponds to an existing value in the referenced table.
Question 3: Which NoSQL data model stores data as key-value pairs with no fixed schema?
- Document store
- Column-family store
- Key-value store (Correct answer)
- Graph database
Correct answer: Key-value store
Key-value stores use a simple hash-map structure where each unique key maps to a value, requiring no predefined schema.
Question 4: What does the CAP theorem state about distributed databases?
- A system can guarantee Consistency, Availability, and Partition tolerance simultaneously
- A system can guarantee at most two of Consistency, Availability, and Partition tolerance (Correct answer)
- Partition tolerance is optional in well-designed systems
- Consistency and Availability are mutually exclusive in all systems
Correct answer: A system can guarantee at most two of Consistency, Availability, and Partition tolerance
The CAP theorem states that a distributed system can only guarantee two of the three properties: Consistency, Availability, and Partition tolerance.
Question 5: Which join type returns all rows from both tables, filling NULL where no match exists?
- INNER JOIN
- LEFT OUTER JOIN
- RIGHT OUTER JOIN
- FULL OUTER JOIN (Correct answer)
Correct answer: FULL OUTER JOIN
A FULL OUTER JOIN returns all rows from both tables, placing NULL in columns where a matching row from the other table does not exist.
Question 6: In MongoDB, which operation is used to update only specific fields in a document without replacing the entire document?
- replaceOne()
- updateOne() with $set (Correct answer)
- insertOne()
- findOneAndReplace()
Correct answer: updateOne() with $set
updateOne() with the $set operator modifies only the specified fields of a document, leaving the rest of the document unchanged.
Question 7: Which property of relational databases ensures that a committed transaction remains persistent even after a system failure?
- Atomicity
- Consistency
- Isolation
- Durability (Correct answer)
Correct answer: Durability
Durability, the 'D' in ACID, guarantees that once a transaction is committed, its effects are permanently recorded even in the event of a crash.
Which normal form eliminates transitive dependencies among non-key attributes?