Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE TABLE Director ( dirID INT NOT NULL, dirName VARCHAR(255) NOT NULL, CONSTRAINT pk_Director PRIMARY KEY (dirID), CONSTRAINT ck_Director UNIQUE (dirName) ): CREATE TABLE Movie

image text in transcribed

image text in transcribed

CREATE TABLE Director ( dirID INT NOT NULL, dirName VARCHAR(255) NOT NULL, CONSTRAINT pk_Director PRIMARY KEY (dirID), CONSTRAINT ck_Director UNIQUE (dirName) ): CREATE TABLE Movie ( movieID INT, dirID INT, movieTitle VARCHAR(255) NOT NULL, movieGenre VARCHAR(255) NOT NULL, movielength INT NOT NULL, CONSTRAINT pk_movie PRIMARY KEY (movieID), CONSTRAINT fk_movie_dir FOREIGN KEY (dirID) REFERENCES Director (dirID) ); INSERT INTO Director (dirID, dirName) VALUES (1, 'Hitchcock'); INSERT INTO Director (dirID, dirName) VALUES (2, 'Kubrick'); INSERT INTO Director (dirID, dirName) VALUES (3, 'Scorsese'); INSERT INTO Director (dirID, dirName) VALUES (4, 'Kurosawa'); INSERT INTO Director (dirID, dirName) VALUES (5, 'Wilder'); INSERT INTO Director (dirID, dirName) VALUES (6, 'Speilberg'); INSERT INTO Director (dirID, dirName) VALUES (7, 'Welles'); INSERT INTO Movie VALUES (1, 1, 'Psycho', 'Suspense', 108); INSERT INTO Movie VALUES ( 2,1 , 'The Birds', 'Suspense', 120); INSERT INTO Movie VALUES (3, 3, 'Raging Bull', 'Drama',129); INSERT INTO Movie VALUES (4, 3, 'Mean Streets', 'Drama', 107); INSERT INTO Movie VALUES (5, 3, 'Goodfellas', 'Drama', 146 ); INSERT INTO Movie VALUES (6, 4, 'Seven Samurai', 'Samurai', 207); INSERT INTO Movie VALUES (7, 4, 'Throne of Blood', 'Horror', 109); INSERT INTO Movie VALUES ( 8,5 , 'Sunset Boulevard', 'Film Noir', 110); INSERT INTO Movie VALUES (9, 5, 'Some Like It Hot', 'Comedy', 132); INSERT INTO Movie VALUES (10, 6, 'Schindler"s List', 'Drama', 195); INSERT INTO Movie VALUES (11, 6, 'Jaws', 'Horror', 124); INSERT INTO Movie VALUES (12, 2, 'Dr Strangelove', 'Drama', 93); INSERT INTO Movie VALUES (13, 2, 'Clockwork Orange', 'Drama', 136); INSERT INTO Movie VALUES (14, 2, 'Full Metal Jacket', 'Drama', 116); INSERT INTO Movie VALUES (15, 7, 'Citizen Kane', 'Film Noir', 119); SELECT * FROM Director; DIRID DIRNAME 1 | Hitchcock 2 | Kubrick 4 Kurosawa 6 Speilberg 7 Welles 5 | Wilder SELECT * FROM Movie; MOVIEID DIRID MOVIETITLE MOVIEGENRE MOVIELENGTH 1 | 1 | Psycho | Suspense | 108 2 | 1 | The Birds | Suspense | 120 3 | 3 | Raging Bull | Drama | 129 4 |3 | Mean Streets | Drama | 107 5 | 3 Goodfellas | Drama | 146 64 Seven Samurai | Samurai | 207 74 Throne of Blood | Horror | 109 85 | Sunset Boulevard | Film Noir | 110 9 | 5 | Some Like It Hot | Comedy | 132 10 | 6 | Schindler's List | Drama | 195 11 | 6 | Jaws | Horror | 124 12 | 2 | Dr Strangelove | Drama | 93 132 | Clockwork Orange | Drama | 136 14 | 2 | Full Metal Jacket | Drama | 116 15 | 7 | Citizen Kane | Film Noir | 119 Question 2) Write queries to do the following: a) Find a list of directors, the number of Movies by that director, and the average length for their Movies, but only including directors that have more than 1 Movie, but not including Suspense movies (use a WHERE and a HAVING clause) [output ] DIRID TOTAL_MOVIES AVG_LENGTH 23115.000033127.333342158.000052121.000062159.5000

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions