Loading

Quipoin Menu

Learn • Practice • Grow

sql / Foreign Keys
mcq
Direction: Choose the correct option

Q1.

What is the purpose of a foreign key?
A. Group data
B. Link two tables together
C. Sort data
D. Create index
Direction: Choose the correct option

Q2.

CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(id)
);
What does customer_id reference?
A. customers table id column
B. customer_id column
C. customers table
D. orders table
Direction: Choose the correct option

Q3.

What happens if you try to insert a foreign key value that doesn't exist in parent table?
A. Insert fails with error
B. Default value used
C. NULL is inserted
D. Insert succeeds
Direction: Choose the correct option

Q4.

What does ON DELETE CASCADE do?
A. Prevents parent deletion
B. Deletes child rows when parent deleted
C. Sets child to NULL
D. Updates child rows
Direction: Choose the correct option

Q5.

What does ON DELETE SET NULL do?
A. Sets foreign key to NULL when parent deleted
B. Sets parent to NULL
C. Deletes parent only
D. Prevents deletion