Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1. (80 points) Consider the relational database defined below: create table passenger ( passenger_ID varchar (10). passenger_nane varchar(30), passenger_city varchar (30), primary key (passenger_ID));

image text in transcribed
image text in transcribed
Problem 1. (80 points) Consider the relational database defined below: create table passenger ( passenger_ID varchar (10). passenger_nane varchar(30), passenger_city varchar (30), primary key (passenger_ID)); create table seat ( train_number varchar (10), seat_number varchar(10), primary key (train_number, seat_number)); create table reservation reservation_number varchar(10). passenger_ID varchar (10) train_number varchar (10), seat number varchar(10) departure_station varchar (10). departure_time timestamp arrival_station varchar (10), arrival time timestamp. fare numeric(8, 2). primary key (reservation_number) foreign key (passenger_ID) references passenger, foreign key (train_number, seat number) references seat); Express in SQL each of the following queries: (a) (10 points) Shows the number of passengers living in (i.e., whose passenger_city is) 'Albany (b) (10 points) Show the train number of each train that has more than 1000 seats. () (10 points) Find the ID of every passenger who lives in (ie, whose passenger_city is) Albany' and has never reserved a trip arriving at 'ALB'. For this query, use either an in clause or a not in clause, (d) (10 points) Find the ID of every passenger who lives in (ie., whose passenger_city is) 'Albany' and has never reserved a trip arriving at 'ALB. For this query, use a set oper- ation (e) (10 points) Find the ID of every passenger who lives in (i.e., whose passenger_city is) 'Albany' and has never reserved any trip. For this query, use a left outer join. (f) (10 points) For each reservation whose departure time is between 2021-04-01 00:00:00' and 2021-04-02 23:59:59' (inclusive), update the fare as follows: If the current fare is greater than $100, decrease the fare by 5 percent. Otherwise, decrease the fare by 3 percent. (g) (10 points) Find the train(s) with the largest number of seats (i.e., trains with more seats or the same number of seats compared to every other train). For each of these trains, show the train number. (h) (10 points) Find all of the trains whose scats were all reserved at least once on "2019-04-01 For each of these trains, show the train number. Problem 2. (20 points) Consider the relational datalpose defined in Problem 1. Express in rela- tional algebra each of the following queries: (a) (10 points) Show the train number of each train that has more than 1000 seats. (b) (10 points) Find the train(s) with the largest number of seats (i.e., trains with more seats or the same number of seats compared to every other train). For each of these trains, show the train number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago