Domain Consider a cinema database that stores ticket sales. Each Screening of a
ID: 3731945 • Letter: D
Question
Domain Consider a cinema database that stores ticket sales. Each Screening of a movie is stored in a relation with an id, the name of the movie, the time of the screening, and which screen it is shown on. An employee is stored with an id, the name, the address where the employee lives and the phone number. A ticket is stored with the id of the employee that sold the ticket, the id of the screening, the timestamp when it was sold, the price of the ticket and the discount type (if there was a discount). The database schema then is SCREENING sld, movie, time, screen) . EMPLOYee- feld, name, address,phone) TICKET - feld, sId, timestamp, price, discount This results in a database given by the following relations Ticket tId eld sld timestamp price discount 1 1 1 2018-03-23 3:14pm 10 none 2 3 4 2018-03-23 3:16pm 8 student 3 3 2 2018-03-23 3:16pm 8 student 4 1 4 2018-03-23 5:48pm 10 none 5 1 3 2018-03-23 5:48pm lecturer Employee eld ame address phone 1 Tyler Durden 537 Paper Street(288) 555-0153 2 Diane Selwyn 1612 Havenhurst Dr. (255) 555-7614 3 Tyler Durden 1612 Havenhurst Dr. (255) 555-7614 Screening sld movie time screen 2018-03-23 7pm Screen 1 2018-03-23 7pm Screen 2 1 Nosferatu 2 Head On 3 Bloody Pit of Horror 2018-03-23 9pm Screen 1 4 The Following 2018-03-23 9pm Screen 2Explanation / Answer
ANS:-
Given that
A cinema database that stores ticket sales. Each Scr,ning of a movie ia attired in relation with an id, the name of the movie, the time of the scriiesing. aml which }cron it is shown on. An employee is stored with en id, the name, the adilriks whim ilia employ, lives, and the phone numb,. A ticket is stored with the id of the employee hal sal the ticket, the id of the screening, the timestamp when it wee sold, the price of the ticket and the discount type (if there was a discount).
The database schema then is:
• SCREENING = { s1d, MOVie, time, screen} •
EMPLOYEE = {eld, name, address,phone4 •
TICKET = {del, sId, timestamp, price, discount}
Relational algebra To the above Question
SQL Query:-
Select Screening.time, Screening.movie from Screening where not exists(Select * from Ticket where Ticket.sId=Screening.sId)
Explanation:-
Take movie and it's time from Screening table where the Ticket Id and Screening Id are not same.
Relational algebra corresponding:
* Divide two selection seperate
Select * from Ticket where Ticket.sId=Screening.sId---->Ticket.sId=Screening.sId(TicketScreening)
Select Screening.time, Screening.movie from Screening---->Screening.time,Screening.movie(Screening)
* Combine together
Select Screening.time, Screening.movie from Screening where not exists(Select * from Ticket where Ticket.sId=Screening.sId)---->Screening.time,Screening.movie (PTicket.sId=Screening.sId)(TicketScreening)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.