Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CREATE TABLE ACTOR ( ID NUMBER(9,0) NOT NULL, NAME VARCHAR2(100) NOT NULL, CONSTRAINT ACTOR_PK PRIMARY KEY (ID)); CREATE TABLE MOVIE (

CREATE TABLE "ACTOR" ( "ID" NUMBER(9,0) NOT NULL,

"NAME" VARCHAR2(100) NOT NULL,

CONSTRAINT ACTOR_PK PRIMARY KEY (ID));

CREATE TABLE "MOVIE" ( "ID" NUMBER(9,0) NOT NULL,

"TITLE" VARCHAR2(100) NOT NULL "YR" NUMBER(4,0), "SCORE" NUMBER(3,1), "VOTES" NUMBER(9,0), "DIRECTOR" VARCHAR2(100),

CONSTRAINT MOVIE_PK PRIMARY KEY (ID));

CREATE TABLE "CASTING" (

"MOVIE_ID" NUMBER(9,0) NOT NULL

"ACTOR_ID" NUMBER(9,0) NOT NULL

"ORD" CONSTRAINT CASTING_PK Primary Key (Movie_ID, ACTOR_ID), CONSTRAINT CASTING_FK1 FOREIGN KEY (MOVIE_ID) REFERENCES MOVIE(ID),

CONSTRAINT CASTING_FK2 FOREIGN KEY (ACTOR_ID) REFERENCES ACTOR(ID)) ;

Using Pl/Sql

Use two environment variables to prompt the user to input the first name and the last name of a director, respectively. Then show on the screen the number of movies () directed by that director, and the average score () of those movies that he/she directed. Your output should contain one line had directed movies with an average score of , where is the full name of the director in the form of FirstName LastName. For example, if the input director is Cameron, James, you should display on the screen that --

James Cameron had directed 4 movies with an average score of 7.85

In case the name of the director (given by the user) does not exist in the movie table, you should catch the runtime error (NO_DATA_FOUND) in your exception-handling section. For example, if the input director is Cameron, James, you should display on the screen that --

Director James Cameron does not exist in the movie table!. Test your code with at least two directors (one exists in the movie table and the other does not).

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

Students also viewed these Databases questions