Foreign Key in SQL – Quiz

For each question below, select the best answer. To select the best answer, click on the circle located on the left of this answer. When all questions are answered, click on the Submit button

Question 1

The foreign key is located in:
the child table.
the parent table.
either the parent or the child table.
both the parent and the child table.

Question 2

What is the correct syntax to add a foreign key on column salesperson_id of table clients?:
ALTER TABLE salespersons ADD FOREIGN KEY (salesperson_id) REFERENCES clients(id)
ALTER TABLE clients FOREIGN KEY (salesperson_id) REFERENCES salespersons(id)
ALTER TABLE clients FOREIGN KEY (salesperson_id) WITH salespersons(id)
ALTER TABLE clients ADD FOREIGN KEY (salesperson_id) REFERENCES salespersons(id)

Question 3

Which of the following actions is allowed when a foreign key is added?:
inserting a row in the child table with a value in the foreign key not corresponding to any value in the parent key.
inserting a row in the parent table not corresponding to any row in the child table.
deleting a row in the parent table matching at least one row in the child table.

 

 

This is the last lesson’s quiz. You can learn more by reading graspsql’s blog.
 
Share on:

Something not clear? Ask your question here:

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
 

Author:
Last udpated: September 10, 2017
Created: November 11, 2014