An employee table has two columns, employee_id and work_email, each guaranteed to be unique. If employee_id is selected as the primary key, how should the database enforce uniqueness of work_email?
2 Keys and Relationships Online Quiz Questions
Use this free practice quiz with 20 questions to review 2 Keys and Relationships, test your knowledge, and prepare for your next test or exam.
A shipment may be created before it is assigned to a warehouse. The shipment table stores the warehouse identifier in a foreign-key column. Which design allows a shipment to have no warehouse assignment yet?
- A
Leave the foreign-key column nullable.
- B
Add NOT NULL to the foreign-key column.
- C
Add UNIQUE to the foreign-key column.
- D
Make the foreign-key column a composite primary key.
The registration table has a foreign key to the vehicle table. Which additional constraint prevents two registration rows from referring to the same vehicle?
- A
Add CHECK to the foreign key.
- B
Add NOT NULL to the foreign key.
- C
Add UNIQUE to the foreign key.
- D
Add a second foreign key to the same parent.
Which two statements correctly describe a foreign key that references another table?
- A
A non-null foreign-key value must match an existing referenced value.
- B
A foreign key can refer to any column, even if that column is neither a primary key nor unique.
- C
The referencing and referenced columns must correspond in number and have compatible data types.
- D
A foreign key is valid only when it consists of a single column.
What SQL constraint would you add to a column when every row must contain a value in that column?
To require each row to satisfy a condition such as quantity > 0, use a constraint.
What is the database term for a minimal set of columns that uniquely identifies every row, such that removing any column would make it no longer unique?
A foreign key may be nullable when a relationship is optional. To require every row to be linked, add to the foreign-key column.
A student can enroll in many courses, and a course can have many students. Which two design choices represent this relationship and prevent the same student-course pairing from being recorded twice?
- A
Add a single nullable foreign key from students to courses.
- B
Create an enrollments table with foreign keys to students and courses.
- C
Give every course a UNIQUE student identifier.
- D
Use the student and course identifiers together as the enrollments table's primary key.
A training company needs to record which employees attend which workshops. Each employee may attend many workshops, and each workshop may have many employees. Which design best represents this relationship?
- A
Store every workshop identifier in a single column of each employee row.
- B
Create a junction table with foreign keys to both employees and workshops.
- C
Make each workshop identifier a foreign key to an employee identifier.
- D
Put all employee identifiers into a single column of each workshop row.
A library is adding a loans table that refers to members. Explain how to define the foreign-key relationship so that every loan must refer to an existing member, and state the column requirements for the reference.
An employee table guarantees that employee_id and work_email are each unique and non-null. Which statement about candidate keys is correct?
- A
Both
employee_idandwork_emailare candidate keys. - B
employee_idis a candidate key, butwork_emailcannot be one because it is an email address. - C
Only
work_emailis a candidate key because it is unique. - D
Neither is a candidate key unless both columns are combined.
A nullable foreign key can represent an optional relationship, while every non-null foreign-key value must match an existing referenced value.
- A
True
- B
False
A table uses (region_code, account_no) together as its main identifier. Which statement correctly describes this design?
- A
The table cannot use the pair as its primary key because a primary key must be one column.
- B
The table can use the pair as one composite primary key.
- C
The table must declare each column as a separate primary key.
- D
The table can use the pair only if neither column is unique by itself.
An order must always belong to a customer. Its customer_id column references customers.customer_id, but the foreign-key column is currently nullable. Which change enforces the requirement that every order be linked?
- A
Add
UNIQUEtocustomer_idso every order points to a customer. - B
Add
CHECK (customer_id > 0)so every order points to a customer. - C
Add
NOT NULLtocustomer_idso every order must be linked. - D
No additional rule is needed because a foreign key cannot be null.
In an employee table, employee_id is the primary key and work_email is another candidate key. Which SQL constraint keyword can enforce uniqueness of work_email?
A design requires that no two profile rows refer to the same user row. Which constraint on the profile table's foreign key enforces this one-to-one relationship?
- A
Add a
UNIQUEconstraint to the foreign-key column. - B
Allow the foreign-key column to be nullable.
- C
Use the foreign key as part of a junction table.
- D
Add a
CHECKconstraint requiring the foreign key to be positive.
An orders table uses a foreign key to reference customers, and the foreign key is configured with ON DELETE CASCADE. If a referenced customer is deleted, dependent order rows are deleted as well. True or false?
- A
True
- B
False
Once a row has been inserted, database constraints no longer apply when that row is changed. True or false?
- A
True
- B
False
A customer row is referenced by existing orders. The system must block deletion of that customer while those references remain. Which referential action should be used?
Related study packs and tools
2 Digital Logic
A 14-question medium-difficulty quiz on Boolean algebra, logic gates, truth tables, and combinational circuits.
03 — Python Programming Fundamentals
A focused set of flashcards covering Python variables, data types, expressions, control flow, functions, input, output, and common programming practices.
05 — Data Structures: Concepts, Operations, and Trade-Offs
A structured guide to the main data structures, their operations, efficiency trade-offs, representations, and practical selection criteria.
6 Computer Memory
Learn how computer memory stores and addresses information, how RAM and ROM differ, and how caches and the memory hierarchy balance speed, capacity, and cost.
07 Trees and Binary Search Trees
A progressive guide to tree structure, binary-tree traversals, binary search tree operations, deletion, balancing, and the way tree height determines time and space costs.
08 — Discrete Mathematics for Computer Science
A focused review of propositional logic, quantifiers, sets, relations, functions, and foundational proof methods in discrete mathematics for computer science.
Interrupts
Reviews how interrupts support event handling and multitasking, and how Linux system calls use the RISC-V `ecall` instruction and register conventions.
OS Processes
This quiz covers process management, context switching and scheduling, multitasking, traps and interrupts, and RISC-V privilege transitions.
Systemcalls
A quiz on operating-system system calls, including privileged-operation requests, process creation and execution with fork, exec, and waitpid, and signal handling.