Question
Read the question very carefully and answer it appropriately with the correct answer. Do not give wrong answers. Do not copy paste previous chegg answers
Read the question very carefully and answer it appropriately with the correct answer. Do not give wrong answers. Do not copy paste previous chegg answers as this is a new problem. A complete answer is expected for the problem. Follow the below-
Use the below sql statements to create and insert the tables. After doing this solve problem 1
create table park(pid int, pname varchar(50), primary key(pid));
insert into park values(1,'Magic Kingdom');
insert into park values(2,'Animal Kingdom');
insert into park values(3,'Hollywood Studios');
create table park_schedule (pid int, sdate date, open_time timestamp,close_time timestamp, primary key(pid, sdate),foreign key(pid) references park);
insert into park_schedule values(1,date '2021-10-1', timestamp '2021-10-1 09:00:00.00', timestamp '2021-10-1 21:00:00.00');
insert into park_schedule values(2,date '2021-10-1', timestamp '2021-10-1 08:00:00.00', timestamp '2021-10-1 18:00:00.00');
insert into park_schedule values(3,date '2021-10-1', timestamp '2021-10-1 09:00:00.00', timestamp '2021-10-1 19:00:00.00');
create table ride(rid int, rname varchar(50),pid int, min_height int, capacity int, ride_time int, wait_time int, return_time timestamp,primary key(rid), foreign key(pid) references park);
insert into ride values(1,'Space Mountain',1,40, 144, 30, 60, timestamp '2021-10-1 15:30:00.00');
insert into ride values(2,'Seven Dwarfs Mine Train',1,38, 80,20, 90, timestamp '2021-10-1 14:30:00.00');
insert into ride values(3,'The Twilight Zone Tower of Terror',3,40, 40,20,60, timestamp '2021-10-1 13:30:00.00');
insert into ride values(4,'Star Wars: Rise of the Resistance',3,40, 50,30,40, timestamp '2021-10-1 13:00:00.00');
create table customer(cid int, cname varchar(50),age int,height int, primary key(cid));
insert into customer values(1,'Alice',40,65);
insert into customer values(2,'Adam',42,70);
insert into customer values(3,'Ella',10,55);
insert into customer values(4,'Ethan',3,38);
insert into customer values(5,'Jason',25,69);
create table ticket(tid int,cid int,pid int, tdate date,price number, primary key(tid),foreign key(cid) references customer,foreign key(pid) references park);
insert into ticket values(1,1,1,date '2021-10-1',100);
insert into ticket values(2,2,1,date '2021-10-1',100);
insert into ticket values(3,3,1,date '2021-10-1',100);
insert into ticket values(4,4,1,date '2021-10-1',100);
create table reservation(rsid int, tid int, rid int, rtime timestamp, status int, utime timestamp, primary key(rsid), foreign key(tid) references ticket, foreign key(rid) references ride);
insert into reservation values(1,1,1,timestamp '2021-10-1 16:30:00.00',0,null);
insert into reservation values(2,2,1,timestamp '2021-10-1 16:00:00.00',0,null);
insert into reservation values(3,3,1,timestamp '2021-10-1 16:05:00.00',0,null);
insert into reservation values(4,1,2,timestamp '2021-10-1 15:00:00.00',1,null);
insert into reservation values(5,1,2,timestamp '2021-10-1 17:30:00.00',0,null);
insert into reservation values(6,2,2,timestamp '2021-10-1 20:30:00.00',0,null);
insert into reservation values(7,4,1,timestamp '2021-10-1 16:05:00.00',0,null);
commit;
Problem 1 : Please create a trigger on ride table when return time is changed to an earlier time. Please insert a message into park_message table for each customer who has unused reservation (status=0) for this ride. The message says
'The ride X's return time has been changed to Y' where X is the name of ride and Y is the new return time.' Use systimestamp for message time (mtime).
Please also test your trigger by updating return time of a ride.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started