The document creates two tables, movielist and theatrelist, to store movie and theatre data. Indices and foreign keys are added to link the tables. A sequence and trigger are also created to automatically generate ids for the theatrelist table.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
18 views1 page
Skill 4
The document creates two tables, movielist and theatrelist, to store movie and theatre data. Indices and foreign keys are added to link the tables. A sequence and trigger are also created to automatically generate ids for the theatrelist table.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
-- SQLINES LICENSE FOR EVALUATION USE ONLY
CREATE TABLE movielist (
moviename varchar2(55) NOT NULL, cast varchar2(45) NOT NULL, releasedate varchar2(45) NOT NULL, theatrename varchar2(45) NOT NULL, screenno number(10) DEFAULT NULL, CONSTRAINT screeno FOREIGN KEY (screenno) REFERENCES screens (screenno) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT theatrename FOREIGN KEY (theatrename) REFERENCES theatreslist (name) );
CREATE INDEX theatrename_idx ON movielist (theatrename);
CREATE INDEX screeno_idx ON movielist (screenno); -- SQLINES LICENSE FOR EVALUATION USE ONLY CREATE TABLE theatrelist ( id number(10) NOT NULL, name varchar2(45) NOT NULL, screens number(10) NOT NULL, location varchar2(200) NOT NULL, rating number(10) DEFAULT NULL, PRIMARY KEY (id), CONSTRAINT id_UNIQUE UNIQUE (id), CONSTRAINT name_UNIQUE UNIQUE (name) ) ;
-- Generate ID using sequence and trigger
CREATE SEQUENCE theatreslist_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER theatreslist_seq_tr
BEFORE INSERT ON theatreslist FOR EACH ROW WHEN (NEW.id IS NULL) BEGIN SELECT theatreslist_seq.NEXTVAL INTO :NEW.id FROM DUAL; END; /