create.sql
CREATE TABLE IF NOT EXISTS THEATER (ID INTEGER not null primary key, CAPACITY INTEGER not null)
CREATE TABLE IF NOT EXISTS MOVIE(ID INTEGER not null primary key, NAME VARCHAR(50) not null, ACTORS VARCHAR(200) not null)
CREATE TABLE IF NOT EXISTS TIMESLOT(ID INTEGER not null primary key, START_TIME VARCHAR(5) not null, END_TIME VARCHAR(5) not null)
CREATE TABLE IF NOT EXISTS SHOW_TIMING(ID INTEGER not null primary key, DAY INTEGER not null, THEATER_ID INTEGER not null, MOVIE_ID INTEGER not null, TIMING_ID INTEGER not null)
CREATE TABLE IF NOT EXISTS SALES(ID INTEGER not null primary key, AMOUNT FLOAT not null)
CREATE TABLE IF NOT EXISTS POINTS(ID INTEGER not null primary key, POINTS INTEGER not null)
ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_THEATER_FK FOREIGN KEY (THEATER_ID) REFERENCES THEATER (ID)
ALTER TABLE SHOW_TIMING ADD CONSTRAINT SHOW_MOVIE_FK FOREIGN KEY (MOVIE_ID) REFERENCES MOVIE (ID)
ALTER TABLE SHOW_TIMING ADD CONSTRAINT TIMESLOT_FK FOREIGN KEY (TIMING_ID) REFERENCES TIMESLOT (ID)
ALTER TABLE SALES ADD CONSTRAINT SHOW_TIMING_ID_FK FOREIGN KEY (ID) REFERENCES SHOW_TIMING (ID)
drop.sql
DROP TABLE IF EXISTS SALES;
DROP TABLE IF EXISTS POINTS;
DROP TABLE IF EXISTS SHOW_TIMING;
DROP TABLE IF EXISTS MOVIE;
DROP TABLE IF EXISTS TIMESLOT;
DROP TABLE IF EXISTS THEATER;
load.sql
INSERT INTO THEATER(ID, CAPACITY) VALUES (1, 50) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (2, 70) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (3, 70) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (4, 60) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (5, 120) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (6, 100) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO THEATER(ID, CAPACITY) VALUES (7, 80) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (1, 'The Matrix', 'Keanu Reeves, Laurence Fishburne, Carrie-Ann Moss') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (2, 'The Lord of The Rings', 'Elijah Wood, Ian Mckellen, Viggo Mortensen') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (3, 'Inception', 'Leonardo DiCaprio') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (4, 'The Shining', 'Jack Nicholson, Shelley Duvall') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (5, 'Mission Impossible', 'Tom Cruise, Jeremy Renner') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (6, 'Terminator', 'Arnold Schwarzenegger, Linda Hamilton') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (7, 'Titanic', 'Leonardo DiCaprio, Kate Winslet') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (8, 'Iron Man', 'Robert Downey Jr, Gwyneth Paltrow, Terrence Howard') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (9, 'Inglorious Bastards', 'Brad Pitt, Diane Kruger') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (10, 'Million Dollar Baby', 'Hillary Swank, Client Eastwood') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (11, 'Kill Bill', 'Uma Thurman') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (12, 'The Hunger Games', 'Jennifer Lawrence') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (13, 'The Hangover', 'Bradley Cooper, Zach Galifianakis') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (14, 'Toy Story', 'Tom Hanks, Michael Keaton') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (15, 'Harry Potter', 'Daniel Radcliffe, Emma Watson') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (16, 'Avatar', 'Sam Worthington, Sigourney Weaver') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (17, 'Slumdog Millionaire', 'Anil Kapoor, Dev Patel, Freida Pinto') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (18, 'The Curious Case of Benjamin Button', 'Brad Pitt, Cate Blanchett') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (19, 'The Bourne Ultimatum', 'Matt Damon, Julia Stiles') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO MOVIE(ID, NAME, ACTORS) VALUES (20, 'The Pink Panther', 'Steve Martin, Kevin Kline') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO TIMESLOT(ID, START_TIME, END_TIME) VALUES (1, '10:00', '11:45') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO TIMESLOT(ID, START_TIME, END_TIME) VALUES (2, '12:00', '01:45') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO TIMESLOT(ID, START_TIME, END_TIME) VALUES (3, '02:00', '03:45') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO TIMESLOT(ID, START_TIME, END_TIME) VALUES (4, '04:00', '05:45') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO TIMESLOT(ID, START_TIME, END_TIME) VALUES (5, '06:00', '07:45') ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (1, 1, 1, 1, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (2, 1, 1, 2, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (3, 1, 1, 3, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (4, 1, 1, 4, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (5, 1, 1, 5, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (6, 1, 2, 6, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (7, 1, 2, 7, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (8, 1, 2, 8, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (9, 1, 2, 9, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (10, 1, 2, 10, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (11, 1, 3, 11, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (12, 1, 3, 12, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (13, 1, 3, 13, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (14, 1, 3, 14, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (15, 1, 3, 15, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (16, 1, 4, 16, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (17, 1, 4, 17, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (18, 1, 4, 18, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (19, 1, 4, 19, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (20, 1, 4, 20, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (21, 1, 5, 1, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (22, 1, 5, 2, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (23, 1, 5, 3, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (24, 1, 5, 4, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (25, 1, 5, 5, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (26, 1, 6, 6, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (27, 1, 6, 7, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (28, 1, 6, 8, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (29, 1, 6, 9, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (30, 1, 6, 10, 5) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (31, 1, 7, 11, 1) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (32, 1, 7, 12, 2) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (33, 1, 7, 13, 3) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (34, 1, 7, 14, 4) ON DUPLICATE KEY UPDATE ID=ID;
INSERT INTO SHOW_TIMING(ID, DAY, THEATER_ID, MOVIE_ID, TIMING_ID) VALUES (35, 1, 7, 15, 5) ON DUPLICATE KEY UPDATE ID=ID;