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

The CTO wishes to modify the original schema to accommodate a new feature. As th

ID: 3842015 • Letter: T

Question

The CTO wishes to modify the original schema to accommodate a new feature. As the database already has valuable information that we need to retain, we just want to alter one of the existing tables to fulfill the CTO's request. The new feature is to force a poster's Poster data to be removed when his or her Publisher is deleted - which means that they will not be a poster anymore, but will still be a user. Recall that the current Poster table definition is as follows: Write and execute the ALTER TABLE statement(s) needed to modify the Poster table so that whenever the Publisher associated with the poster is deleted then the Poster data is deleted too.

Explanation / Answer

Note:If you want to update constraint .you have to remove it and then crate again there is no direct way to alter it.

/* Droping foregin key */

ALTER TABLE Poster DROP FOREIGN KEY poster_ibfk_2;

/* Adding foregin key with on delete cascade */

ALTER TABLE Poster
ADD CONSTRAINT poster_ibfk_2
FOREIGN KEY (publisherid )
REFERENCES PUBLISHER (publisherid )
ON DELETE CASCADE;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote