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

Exercise 7.3.1: Show how to alter your relation schemas for the movie exam- ple:

ID: 3732728 • Letter: E

Question

Exercise 7.3.1: Show how to alter your relation schemas for the movie exam- ple: Movie(title, year, length, genre, studio ane, producerC#) StarsIn (movieTitle, movieYear, starName) MovieStar (name, address, gender, birthdate) MovieExec (name, address, cert#, netWorth) Studio(name, address, presC#) in the following ways. a) Make title and year the key for Movie. b) Require the referential integrity constraint that the producer of every movie appear in MovieExec. c) Require that no movie length be less than 60 nor greater than 250.

Explanation / Answer

a)ALTER TABLE Movie ADD PRIMARY KEY(TITLE,YEAR);//(title,year) makes a composite primary key here it is denoted as primarykey(col1,col2...)

b) ALTER TABLE Movie ADD FOREIGN KEY(ProducerC#) REFERENCES MovieExec(name);//using alter allows us to modify column of table like adding primary keys ,changing datatypes etc.

c)ALTER TABLE Movie ADD CHECK (length>60 AND length<250);//check constraint is used to limit the value for length column

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