Question 1
Question 1
Object types:
Theatre_t (tno:integer, name:string, city:string, phone:string)
Star_t (name:string, gender:char(1), birthdate:date)
Stars_nt table of Star_t
Film_t (filmno:integer, title:string, language:string, director:string, budget:float, stars stars_nt)
Show_t (film ref film_t, theatre ref theatre_t, startdate:date, enddate:date)
Tables:
Theatres of theatre_t (tno primary key)
Films of film_t (filmno primary key) Nested table stars store as stars_ntb
Showing of show_t (film references films, theatre references theatres)
The Theatres table has attributes of theatre number (tno), name, city and phone. It contains tuples for all theatres.
Films table contain tuples for all films, and has the attributes film number (filmno), title, language of the film,
director’s name (director), budget in dollars (budget), and stars of the film. The stars nested table consists of the
attributes name, gender (M=male and F=female) and date of birth. The Showing table contains a tuple for each
theatre and a film it shows, along with the start date (startdate) and end date (enddate). The attribute types are
specified in the type descriptions above, as also are the primary keys and referential constraints in the table schema.
Write Oracle Object SQL for these questions.
(a) Write Oracle object SQL to insert an object to film table. Use appropriate sample data fit into data
types.
(b) Display the names of female stars who have acted in films that are currently successful. Assume that a
successful current film has an average show period of 100 days or more at each theatre where it is being screened
now (current screening is indicated by enddate value of null). Subtracting a date d1 from another date d2 (where
d1<d2) gives the duration between them in days as a positive integer. Use sysdate for current date.
(c) For each theatre, find the title of film(s) that played for the longest period (i.e. the longest unbroken
period). Display the theatre name, city and the title of the film. Subtracting a date d1 from another date d2 (where
d1<d2) gives the duration between them in days as a positive integer.
(d) Write Oracle SQL for implementing a member method on theatre_t that returns the number of films a
given theatre is currently showing. The films currently being shown at a theatre are indicated by an enddate of null
in the Showing table. (Remember that each method specification in the type body is a PL/SQL block and it can
contain select statements on other tables of the database.)
Answers:
Theater Table
CREATE TABLE theater OF theater_t (
tno PRIMARY KEY
);
Film Table
CREATE TABLE film OF film_t (
filmno PRIMARY KEY
)
NESTED TABLE stars STORE AS stars_nt;
Show Table
CREATE TABLE show of show_t(
film REFERENCE films,
theater REFERENCE theaters
);
b)