Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.3) Create a trigger, trg_customer_invoice, that increments num_invoices of the corresponding customer whenever a new invoice is added. 1.4) Create a trigger, trg_new_line, that is

1.3) Create a trigger, trg_customer_invoice, that increments num_invoices of the corresponding customer whenever a new invoice is added. 1.4) Create a trigger, trg_new_line, that is fired when a new row is inserted in line table. The trigger does the following two actions: a. increments num_products of the corresponding customer b. updates invoice_total of the corresponding invoice to include the cost of the added products. 1.5) Create a stored procedure, prc_customer_discount, that takes two inputs, customer code and discount amount. The procedure then applies the discount to all invoices of the given customer by updating invoice_total values. Question 2: Group by and Aggregates: Consider the following Hotel database: Hotel (hotelNum, hotelName, city) Room (roomNum, hotelNum, type, price) foreign key hotelNum references Hotel (hotelNum) Booking (roomNum, guestNum, dateFrom, dateTo) foreign key roomNum references Room (roomNum) foreign key guestNum references Guest (g

uestNum) Guest (guestNum, guestName, guestCity)

Write SQL statements to answer the following: 2.1) How many hotels are there in the city of Minneapolis. 2.2) What is the average price for a room in the city of Edina. 2.3) For each guest, list guest number, guest name, and the number of bookings that are made by that guest. 2.4) How many different guests have made bookings that started in August of 2010? 2.5) Find the total number of bookings made by guests who live in London. 2.6) How many rooms of type Family are there in the Minneapolis branch of Holiday INN? Question 3: ERD design Although you always wanted to be an artist, you ended up being an expert on databases because you love to cook data and you somehow confused database with data paste. Your old love is still there, however, so you set up a database company, ArtBase, that builds a product for art galleries. The core of this product is a database with a schema that captures all the information that galleries need to maintain. Galleries keep information about artists, their names (which are unique), birthplaces, age, and style of art. For each piece of artwork, the artist, the year it was made, its unique title, its type of art (e.g., painting, lithograph, sculpture, photograph), and its price must be stored. Pieces of artwork are also classified into groups of various kinds, for example, portraits, still lifes, works by Picasso, or works of the 19th century; a given piece may belong to more than one group. Each group is identified by a name (like those just given) that describes the group. Finally, galleries keep information about customers. For each customer, galleries keep that persons unique name, address, total amount of dollars spent in the gallery, and the artists and groups of art that the customer tends to like. 3.1) Draw the ER diagram for the database. 3.2) Identify the relational schema for the database. Make sure to clearly indicate primary keys and foreign keys.

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions

Question

What is the IUPAC name for the compound shown

Answered: 1 week ago

Question

Presentations Approaches to Conveying Information

Answered: 1 week ago

Question

=+ Who do you think is right? Why?

Answered: 1 week ago