Question

The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName,...

The following tables form part of a database held in a relational DBMS:

Hotel (hotelNo, hotelName, city)

Room (roomNo, hotelNo, type, price)

Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)

Guest (guestNo, guestName, guestAddress)

where Hotel contains hotel details and hotelNo is the primary key;

Room contains room details for each hotel and (roomNo, hoteINo) forms the primary key;

Booking contains details of bookings and (hoteINo, guestNo, dateFrom) forms the primary key;

Guest contains guest details and guestNo is the primary key. Note: Hotel, Room, and Guest are relatively self explanatory.

Each row in the Booking tabledescribes a single booking for a guest at a hotel (past, present, and future).Assumptions:price is some type of a number field.type is a VARCHAR field with one of the following values: {“double”,”king”,”suite”}dateTo and dateFrom are both DATE fieldsAdditionally, in SQL Server the ​getDate()​ function will return the current date/time. You canuse this within a query, even something as simple as ​SELECT getDate()You can also use this in comparison to dateFields using normal mathematical comparisons:...WHERE dateFrom <= getDate()

Question1​. Write a single SQL query that calculates the average price of a room across all hotels.

Question2​. Write a single SQL query that determines the list of all guests staying at the HyattRegency today.

Question3​. Write a single SQL query that, with the current bookings, shows how much moneyis each hotel making today

Question4​. Write one insert statement for each table. Thus, there should be four separatestatements. You may make up data as you wish but it should adhere to the schema and ourassumptions so far.

Question5​. Write a single SQL query that will increase the price of all rooms at the HyattRegency by 6%.

Question6​. Write a single SQL query that lists all rooms that are currently unoccupied.

Question7​. Write a single SQL query that, for the Hyatt Regency hotel, list all rooms and ifthere is a person occupying the room also list the guest’s name.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question1​. Write a single SQL query that calculates the average price of a room across all hotels.

Answer) SELECT AVG(R.PRICE),H.HOTELNAME FROM ROOM R, HOTEL H WHERE R.HOTELNO=H.HOTELNO ;

Question2​. Write a single SQL query that determines the list of all guests staying at the HyattRegency today.

ANSWER) SELECT G.GUESTNAME FROM GUESTS G,BOOKING B WHERE B.GUESTNO=G.GUESTNO AND B.DATEFROM= GETDATE() AND B.DATETO=GETDATE();

Question3​. Write a single SQL query that, with the current bookings, shows how much moneyis each hotel making today

ANSWER)SELECT H.HOTELNAME,TOTAL(R.PRICE) FROM ROOM R, HOTEL H, BOOKING B WHERE B.DATEFROM= GETDATE() AND B.DATETO=GETDATE() AND H.HOTELNO=R.HOTELNO AND H.HOTELNO=B.HOTELNO;

Question4​. Write one insert statement for each table. Thus, there should be four separatestatements. You may make up data as you wish but it should adhere to the schema and ourassumptions so far.

ANSWER) INSERT STATEMENT FOR THE HOTELTABLE:

INSERT INTO HOTEL VALUES('OP512', 'TAJ', 'KOLKATA')

INSERT STATEMENT FOR ROOM TABLE

INSERT INTO ROOM VALUES('A1','OP512','DOUBLE BED',4652.15)

INSERT STATEMENT FOR BOOKING TABLE

INSERT STATEMENT BOOKING VALUES( 'OP512', '45', '2008-11-11', '2008-11-14, 'A1')

INSERT STATEMENT FOR GUEST TABLE

INSERT INTO GUEST VALUES('45', 'JOHN', 'HYDERABAD')

Question5​. Write a single SQL query that will increase the price of all rooms at the HyattRegency by 6%

ANSWER ) UPDATE ROOMS SET PRICE= PRICE+(6/100)*PRICE FROM HOTEL H, ROOM R WHERE H.HOTELID=R.HOTELID AND H.HOTELNAME='HYATT REGACY';

Question6​. Write a single SQL query that lists all rooms that are currently unoccupied.

ANSWER) SELECT R.ROOMNO AS ROOM FROM ROOM R, BOOKING B WHERE R.HOTELNO=B.HOTELNO AND R.ROOMNO<>B.ROOMNO;

Question7​. Write a single SQL query that, for the Hyatt Regency hotel, list all rooms and ifthere is a person occupying the room also list the guest’s name.

ANSWER)SELECT B.ROOMNO AS ROOMS FROM HOTEL H,BOOKING B, GUEST G WHERE G.GUESTNO=B.GUESTNO AND H.ROOMNO=B.ROOMNO AND H.HOTELNAME='HYATT REGACY'

  

Add a comment
Know the answer?
Add Answer to:
The following tables form part of a database held in a relational DBMS: Hotel (hotelNo, hotelName,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create the following tables as part of a Hotel Business database: 1. Hotel (hotelNo, hotelName, city)...

    Create the following tables as part of a Hotel Business database: 1. Hotel (hotelNo, hotelName, city) where Hotel contains hotel details and hotelNo is the primary key 2. Room (roomNo, hotelNo, type, price) Room contains room details for each hotel and (roomNo, hotelNo) forms the primary key 3. Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Booking contains details of bookings and (hotelNo, guestNo, dateFrom) forms the primary key 4. Guest (guestNo, guestName, guestAddress) Guest contains guest details and guestNo is the...

  • HOW TO DO THIS DATABASE QUESTION USING ORACLE? Hotel (hotelNo, hotelName, hotelAddress, country) Room (roomNo, hotelNo,...

    HOW TO DO THIS DATABASE QUESTION USING ORACLE? Hotel (hotelNo, hotelName, hotelAddress, country) Room (roomNo, hotelNo, type, price) Guest (guestNo, guestName, guestAddress, country) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) (a).List all guests currently staying at the Grosvenor Hotel. Include the roomNo in the output. Use 2019-01-21 as the current date.            (b) What is the total income from bookings for the Grosvenor Hotel today? Do this question for each of the hotels with 'Grosvenor' in name. Use 2019-01-21 as the...

  • Q) Integrity Constraints question. Consider following tables (bold are Primary Keys) •Hotel (hotelNo, hotelName, city) •Room...

    Q) Integrity Constraints question. Consider following tables (bold are Primary Keys) •Hotel (hotelNo, hotelName, city) •Room (roomNo, hotelNo, type, price) •Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) •Guest (guestNo, guestName, guestAddress) Identify the foreign keys in this schema, Explain how the entity and referential integrity rules apply to these relations.

  • ** Please use elational algebra expressions ** HOTEL (hotelNo, hotelName, city) ROOM (roomNo, hotelNo, type, price)...

    ** Please use elational algebra expressions ** HOTEL (hotelNo, hotelName, city) ROOM (roomNo, hotelNo, type, price) RESERVATION (hotelNo, guestNo, dateFrom, dateTo, roomNo) GUEST (guestNo, guestName, guestAddress) Consider the same schema from question 1 and express the following queries using relational algebra expressions: i) List the price and type of all rooms at the “Governor Hotel”. ii) List all guests who stayed at the “Governor Hotel” between 31st December 2018 (check-in) and 1stJanuary 2019 (check-out). iii) List all room numbers and...

  • 2. The following tables form part of a database hield in a relatioual DBMS: (10 Points)...

    2. The following tables form part of a database hield in a relatioual DBMS: (10 Points) Hotel Room Booking Guest hotelNo, hotelName, city {room No. hotelNo. Type.price) booking No, hotelNo, guestNo, date from date To roomNo) (guestNo. guestName. guestAddress) A. List the price and type of all rooms at the Shangri-La Hotel B. Listall guests staying at Shangri-La Hotel berween Jimmy I and January 31, 2020 Liste details of all rooms at the Shangri-La llore, including the name of the...

  • **************PLEASE COMPLETE PART F) ONLY************** Consider the following relational database schema (primary keys are underlined) and...

    **************PLEASE COMPLETE PART F) ONLY************** Consider the following relational database schema (primary keys are underlined) and SQL query: Hotel (hotelNo, hotelName, city) Room (roomNo, hotelNo, type, price) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Guest (guestNo, guestName, guestAddress) SELECT g.guestNo, g.guestName FROM Room r, Booking b, Hotel h, Guest g WHERE h.hotelNo = b.hotelNo AND g.guestNo = b.guestNo AND h.hotelNo = r.hotelNo AND h.hotelName = "Ritz" AND dateFrom >= "Jan 01, 2001" AND dateTo <= "Dec 31, 2001"; (A) state what...

  • **************PLEASE COMPLETE PART E) ONLY************** Consider the following relational database schema (primary keys are underlined) and...

    **************PLEASE COMPLETE PART E) ONLY************** Consider the following relational database schema (primary keys are underlined) and SQL query: Hotel (hotelNo, hotelName, city) Room (roomNo, hotelNo, type, price) Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo) Guest (guestNo, guestName, guestAddress) SELECT g.guestNo, g.guestName FROM Room r, Booking b, Hotel h, Guest g WHERE h.hotelNo = b.hotelNo AND g.guestNo = b.guestNo AND h.hotelNo = r.hotelNo AND h.hotelName = "Ritz" AND dateFrom >= "Jan 01, 2001" AND dateTo <= "Dec 31, 2001"; (A) state what...

  • Language SQL Need help with SQL Question Create a view vHW1_8_xxxx listing the guest name, number...

    Language SQL Need help with SQL Question Create a view vHW1_8_xxxx listing the guest name, number of days and the amount each guest needs to pay to the hotels for their stays. Your result should not include any unknown value in the dateto. Your result should include guest name, hotel name, number of days, and amount to pay. Here is my code: select guestname, hotelname, datediff(dateto,datefrom), sum(datediff(dateto,datefrom)*price) from Guest g, Hotel h, Room r, Booking b where h.hotelno=b.hotelno and r.roomno=b.roomno...

  • Need SQL form Thanks a lot EIERCISES lowing tables form part of a database held in...

    Need SQL form Thanks a lot EIERCISES lowing tables form part of a database held in a relational DBMS: Hote (Hotel_No, Name, Address) Roo (Room No, Hotel No. Tvpe. Price) Guest (Guest No, Name, Address) Room contains room details for each hotel and (Hotel_No, Room No) Boong Hotel No Ges, No, Date Fiom, Daie,To, RomNe) OOm where Hotel contains hotel details and Hotel No is the pri mary key forms the primary key -93

  • The following tables form part of a database held in a relational DBMS for University campuses:...

    The following tables form part of a database held in a relational DBMS for University campuses: -  Building (buildingNo , area)  ClassRoom (roomNo , buildingNo , capacity)  Reserving ( buildingNo , courseNo , timeFrom , day, roomNo)  Course (courseNo , courseName) Generate the tuple relational calculus, and domain relational calculus expressions for the following queries: 1. List all buildings. 2. List all class rooms in building 14Kh with capacity >30 students 3. List all course names,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT