Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

DATABASE DESIGN PROBLEMS. READ AND ANSWER ALL PLEASE. THANKS. ========= Which of

ID: 3728394 • Letter: D

Question

DATABASE DESIGN PROBLEMS. READ AND ANSWER ALL PLEASE. THANKS.

=========

Which of the following code will create a foreign key named fk honnors on the column honors_subject of table students? The constraint is that the values need to reference the values of table HonnorsSubjects, column honors_subject_id. A It's not possible to create a foreign key after you have created a table. B ALTER TABLE Students ADD CONSTRAINT k_honnors FOREIGN KEY (honors_subject) REFERENCES HonnorsSubjects (honors_subject_id); C ALTER TABLE ADD CONSTRAINT Students.fk honnors (honors_subject) FOREIGN KEY REFERENCES HonnorsSubjects (honors_subject); D ALTER TABLE FOREIGN KEY REFERENCES Students (honors_ subject) E None of the above HonnorsSubjects ADD CONSTRAINT ik_honnors (honors_subject_id)

Explanation / Answer

The syntax for adding a foreign key constraint on column C in a table T referencing column C' on table T' is:

ALTER TABLE T ADD CONSTRAINT constraint_name FOREIGN KEY(C) REFERENCES T'(C');

From this, it is clear that option B is the right way to add a foreign key constraint on an already created table T.