Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

use SQL Commands to write your queries for the following questions (Use Oracle Apex) 1. Eastwood has become known as a producer, composer, director, and

use SQL Commands to write your queries for the following questions (Use Oracle Apex)

1. Eastwood has become known as a producer, composer, director, and actor. Write a join query that returns the total number of major award nominations, and total awards wins for Eastwood for each of these roles. (Assume that Clint Eastwood is the only person named Clint Eastwood in the database). Sort the results in descending order by total awards. Make sure to rename any calculated fields that appear in the results.

2. Eastwood has collaborated with many actors, directors, producers, etc. over the course of his career. Write a join query that lists the full name (first, middle, and last combined as one field), role, and total number of times they have worked with Eastwood. Sort the results in descending order by total number of collaborations and limit results to his 10 most frequent collaborators (using FETCH). Make sure to rename any calculated fields that appear in the results.

CREATE TABLE MOVIE ( MovieID VARCHAR2(10) NOT NULL, Title VARCHAR2(50) NOT NULL, ReleaseYear NUMBER(4,0), Runtime NUMBER(3,0), Score NUMBER(3,1), Votes NUMBER(7,0), Studio VARCHAR2(25) NOT NULL, Budget NUMBER(10,0), BoxOffice NUMBER(10,0), CONSTRAINT MOVIE_PK PRIMARY KEY (MovieID));

CREATE TABLE PERSON ( PersonID VARCHAR2(10) NOT NULL, PersonFirst VARCHAR2(25) NOT NULL, PersonMiddle VARCHAR2(25), PersonLast VARCHAR2(25) NOT NULL, BirthYear NUMBER(4,0), DeathYear NUMBER(4,0), CONSTRAINT PERSON_PK PRIMARY KEY (PersonID));

CREATE TABLE GENRE ( MovieID VARCHAR2(10) NOT NULL, Genre VARCHAR2(25) NOT NULL, CONSTRAINT MOVIE_GENRE_PK PRIMARY KEY (MovieID, Genre), CONSTRAINT MOVIE_GENRE_FK1 FOREIGN KEY (MovieID) REFERENCES MOVIE (MovieID));

CREATE TABLE PRINCIPAL ( MovieID VARCHAR2(10) NOT NULL, PersonID VARCHAR2(10) NOT NULL, Role VARCHAR2(25) NOT NULL, CharacterName VARCHAR(50), CONSTRAINT PRINCIPAL_PK PRIMARY KEY (MovieID, PersonID, Role), CONSTRAINT PRINCIPAL_FK1 FOREIGN KEY (MovieID) REFERENCES MOVIE (MovieID), CONSTRAINT PRINCIPAL_FK2 FOREIGN KEY (PersonID) REFERENCES PERSON (PersonID));

CREATE TABLE AWARD ( MovieID VARCHAR2(10) NOT NULL, PersonID VARCHAR2(10) NOT NULL, Role VARCHAR2(25) NOT NULL, Award VARCHAR2(50) NOT NULL, Won NUMBER(1,0) NOT NULL, CONSTRAINT AWARD_PK PRIMARY KEY (MovieID, PersonID, Role, Award), CONSTRAINT AWARD_FK1 FOREIGN KEY (MovieID) REFERENCES MOVIE (MovieID), CONSTRAINT AWARD_FK2 FOREIGN KEY (PersonID) REFERENCES PERSON (PersonID), CONSTRAINT AWARD_FK3 FOREIGN KEY (MovieID, PersonID, Role) REFERENCES PRINCIPAL (MovieID, PersonID, Role));

--INSERT DATA --MOVIE INSERT INTO MOVIE (MovieID, Title, ReleaseYear, Runtime, Score, Votes, Studio, BoxOffice) VALUES ('tt0066819', 'The Beguiled', 1971, 105, 7.2, 13512, 'Universal', 1100000); INSERT INTO MOVIE (MovieID, Title, ReleaseYear, Runtime, Score, Votes, Studio, BoxOffice) VALUES ('tt0068768', 'Joe Kidd', 1972, 88, 6.5, 14476, 'Universal', 6330000); INSERT INTO MOVIE (MovieID, Title, ReleaseYear, Runtime, Score, Votes, Studio, Budget) VALUES ('tt0069822', 'Breezy', 1973, 106, 7, 3678, 'Universal', 750000); INSERT INTO MOVIE (MovieID, Title, ReleaseYear, Runtime, Score, Votes, Studio) VALUES ('tt0051349', 'Ambush at Cimarron Pass', 1958, 73, 5.4, 476, '20th Century Fox'); INSERT INTO MOVIE (MovieID, Title, ReleaseYear, Runtime, Score, Votes, Studio) VALUES ('tt0051840', 'Lafayette Escadrille', 1958, 93, 5.8, 552, 'Warner Bros.');

--GENRE INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0062824', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0065207', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0066999', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0070355', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0072926', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0074483', 'Action'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0065134', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0065207', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0065938', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0080472', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0083943', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0100928', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0186566', 'Adventure'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0079116', 'Biography'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0094747', 'Biography'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0824747', 'Biography'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt1057500', 'Biography'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0062824', 'Comedy'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0064782', 'Comedy'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0088272', 'Crime'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0094963', 'Crime'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0098097', 'Crime'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0100514', 'Crime'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0107206', 'Crime'); INSERT INTO GENRE (MovieID, Genre) VALUES ('tt0105695', 'Western');

--PERSON INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear, DeathYear) VALUES ('nm0578876', 'Herbert', 'E.', 'Mendelson', 1912, 1962); INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear) VALUES ('nm0002717', 'Robert', 'C.', 'Jones', 1937); INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear) VALUES ('nm0453447', 'Evan', 'C.', 'Kim', 1953); INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear) VALUES ('nm0115310', 'William', 'Broyles', 'Jr.', 1944); INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear) VALUES ('nm0364860', 'Jo', 'Ann', 'Harris', 1949); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm2362326', 'Tadamichi', 'Kuribayashi', 1891, 1945); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm0548929', 'Owen', 'Marks', 1899, 1960); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm0656183', 'Geraldine', 'Page', 1924, 1987); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm0366946', 'Elizabeth', 'Hartman', 1943, 1987); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm0002147', 'Tab', 'Hunter', 1931, 2018); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear, DeathYear) VALUES ('nm0000608', 'Burt', 'Reynolds', 1936, 2018); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear) VALUES ('nm0212869', 'Margia', 'Dean', 1922); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear) VALUES ('nm0001358', 'Hal', 'Holbrook', 1925); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast) VALUES ('nm9422035', 'John', 'Truscott'); INSERT INTO PERSON (PersonID, PersonFirst, PersonLast, BirthYear) VALUES ('nm0000229', 'Steven', 'Spielberg', 1946); INSERT INTO PERSON (PersonID, PersonFirst, PersonMiddle, PersonLast, BirthYear) VALUES ('nm0001315', 'Marcia', 'Gay', 'Harden', 1959);

--PRINCIPAL INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0087062', 'nm0000737', 'actor', 'Addy'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0091187', 'nm0556850', 'actor', 'Aggie'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0107206', 'nm0001518', 'actor', 'Al D''Andrea'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0076070', 'nm0697733', 'actor', 'Blakelock'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0327056', 'nm0000102', 'actor', 'Sean Devine'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0060196', 'nm0001812', 'actor', 'Sentenza'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0118548', 'nm0000438', 'actor', 'Seth Frank'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0051349', 'nm0103722', 'actor', 'Sgt. Matt Blake'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0067588', 'nm0488024', 'actor', 'Sgt. McCallum'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0091187', 'nm0348214', 'actor', 'Sgt. Webster'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0498380', 'nm1076976', 'actor', 'Shimizu'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0119668', 'nm0860233', 'actor', 'Sonny Seiler'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt6802308', 'nm7052140', 'actor', 'Spencer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0139668', 'nm0000142', 'actor', 'Steve Everett'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0100514', 'nm0000471', 'actor', 'Strom'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt1205489', 'nm3115704', 'actor', 'Sue'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0186566', 'nm0001258', 'actor', 'Tank Sullivan'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt2179136', 'nm1092227', 'actor', 'Taya'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0051349', 'nm0212869', 'actor', 'Teresa Santos'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0075029', 'nm0571853', 'actor', 'Terrill'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0309377', 'nm0000142', 'actor', 'Terry McCaleb'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0088272', 'nm0000142', 'actor', 'Wes Block'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt0084088', 'nm0247762', 'actor', 'Whit'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role, CharacterName) VALUES ('tt2179136', 'nm6518675', 'actor', 'Young Chris Kyle'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt0051349', 'nm0124987', 'writer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1057500', 'nm0626883', 'producer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1057500', 'nm0669756', 'writer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1057500', 'nm1985343', 'writer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0000142', 'director'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0000142', 'producer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0247762', 'composer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0314088', 'producer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0520749', 'producer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm0828630', 'composer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1205489', 'nm1010405', 'writer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1212419', 'nm0604948', 'writer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1212419', 'nm0827869', 'cinematographer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1616195', 'nm0000142', 'composer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1616195', 'nm0000142', 'director'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt1616195', 'nm0000142', 'producer'); INSERT INTO PRINCIPAL (MovieID, PersonID, Role) VALUES ('tt2179136', 'nm0177896', 'producer');

--AWARD INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0910055', 'tt0067588', 'actor', 'Golden Globe', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000313', 'tt0072288', 'actor', 'Oscar', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000142', 'tt0105695', 'actor', 'Oscar', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000432', 'tt0105695', 'actor', 'Oscar', 1); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000432', 'tt0105695', 'actor', 'BAFTA', 1); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000432', 'tt0105695', 'actor', 'Golden Globe', 1); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000518', 'tt0107206', 'actor', 'Oscar', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000518', 'tt0107206', 'actor', 'BAFTA', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000518', 'tt0107206', 'actor', 'Golden Globe', 0); INSERT INTO AWARD (PersonID, MovieID, Role, Award, Won) VALUES ('nm0000658', 'tt0112579', 'actor', 'Oscar', 0);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions