Given the following three tables:
Customer(CustId, CustName, PhoneNum)
Customer:
CustId |
CustName |
PhoneNum |
1 |
Ahmad Ali |
0555555555 |
2 |
Sara Ahmad |
0544444444 |
3 |
Mona Saad |
0533333333 |
Tabless(TableNum, NumOfSeats)
Tabless:
TableNum |
NumOfSeats |
1 |
4 |
2 |
4 |
3 |
2 |
4 |
6 |
Bookings(BookingNum, CustId, BDay, BMonth, BYear, BHour, NumOfPeople, TableNum)
Bookings:
BookingNum |
CustId |
BDay |
BMonth |
BYear |
BHour |
NumOfPeople |
TableNum |
1 |
2 |
10 |
12 |
2019 |
7 |
2 |
3 |
2 |
3 |
30 |
12 |
2019 |
10 |
4 |
2 |
3 |
1 |
1 |
1 |
2020 |
11 |
5 |
4 |
4 |
3 |
10 |
12 |
2019 |
5 |
2 |
3 |
Hint:
For example: Booking number 1 start at 7:00 pm.
For example: Booking number 1 start at 7:00 pm and end at 9:00 pm.
Write SQL queries using SQL developer to do the following:
Customer Table -
Tabless Table -
Bookings Table -
Create a trigger that does not allow updating number of people reserved to more than the number of seats in the selected table.
Trigger Query -
CREATE TRIGGER TriggerBooking
ON Bookings
AFTER UPDATE
AS
DECLARE @nrOfViolations int
SELECT @nrOfViolations = COUNT(*) FROM deleted d
JOIN Bookings t ON d.BookingNum = t.BookingNum
JOIN Tabless tt ON t.tablenum = tt.TableNum
WHERE t.NumOfPeople > tt.NumOfSeats
IF @nrOfViolations > 0
BEGIN
RAISERROR('Number of people should be less than number of seat',
16, 1);
ROLLBACK TRANSACTION
END
RUN TO TEST :
UPDATE Bookings SET NumOfPeople=7 WHERE BookingNum=1
RESULT :
------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------
Update one of the bookings to number of people more than the number of seats for that table.
Trigger will not allow update query for people more than number of seats, we have to disable the trigger on Booking table and then have to run update query.
ALTER TABLE Bookings DISABLE TRIGGER TriggerBooking
UPDATE Bookings SET NumOfPeople=7 WHERE BookingNum=1
RESULT :
Thank you.
Given the following three tables: Customer(CustId, CustName, PhoneNum) Customer: CustId CustName PhoneNum 1 Ahmad Ali 0555555555...
SECTION B: SQL Data Manipulation Language 1. The following are parts of tables from customer sales databases schema at the AWIE Sdn. Bhd. Company SALES CustID Date SaleAmount 2. Jun 2014 100.22 CUSTOMER CustID FirstName LastName DOB Phone 1 July 2014 909.95 어 1 John Smith 2/4/1968 012 222-2222 3 July 2014 522.95 2 Steven Goldfish 4/4/1974 013 455-4545 3 Dec 2014 100.00 3 Paula Brown 5/24/1978 017 323-3232 4 Smith 4 James 20/10/1980 010 323-8888 Dec 2014 555.55 a)...
This is about database system. Thank you. Question A1 You are given with three Oracle tables, namely, Program, Channel and Booking, as shown in Tables 1 to 3. PROGRAM_ID PROGRAM_NAME DURATION 2012022 Dragon Dance 2014063 Haunted House 2016005 CID 2017172 Kung Fu Master 2018322 Family Affair 2019006 Hong Kong Sites 2019113 2019 Singing Contest 25 58 45 28 68 120 75 Table 1: Program CHANNEL_NO CHANNEL_NAME TVR-1 Rediffusion Channel 1 TV-P Television Pearl Channel TV-G Television Gold Channel Table 2:...
Perform a PERT analysis. For all high-level activities in this project, calculate the following: 1. Optimistic time 2. Most likely time 3. Pessimistic time 4. Expected activity time 5. Standard deviation 6. Variance 7. For one date ahead of most likely completion date, calculate Z and hence the probability of completion by that date. 8. For one date behind the most likely completion date, calculate Z and hence the probability of completion by that date. The data Project Mile Stone...
This is about database system. Thank you. Question B1 Create a Crow's Foot ERD with the business rules described below. Write all appropriate connectivities and cardinalities in the ERD. A music store would like to develop a database to manage information about the CDs, or vinyl collection, the customers and transactions information. It stores the relationships between artists, albums, tracks, customers and transactions. Here is the list of requirements for the database: The collection consists of albums. An album is...
QUESTION 1 The following tables form part of a database held in a relational DBMS for storing the information of Customer, Item, Transaction, and temSale A transaction can contain multiple items and an item can be in multiple transactions as depicted in the following sample data Item(itemid, name, category, price Itemid pk) name category price Iteml Pencil Stationery $30 paperStationery Item2 $25 $15 Item3 Cards Stationery S40 Item4 Ink Stationery S13 Item5 Sprite Itemo Food S4 Milk Food Transaction ctransid,...
use workbench please Task 1: Create a database and name it practical2DB. (2 marks) Task 2: Create all the four tables according to the relational scheme in Figure 1. (8 marks) Task 3: Insert 5 records to into each table. (5 marks) Task 4: Write a query to list alphabetically ordered names, addresses, and IDs of all the customers whose postcode is in (40150, 40400, 47500). (10 marks) Task 5: Delete 1 record from Products table using their primary keys....
Create sql query command for the following. Modify your query and produce the following results. Customer #000000001 1 1428873.61 9 Customer #000000002 2 1156504.92 10 Customer #000000004 4 4134567.39 31 Customer#000000005 5 1084042.74 9 Customer #000000007 7 3922020.98 24 Column 1 is the customer Name, Column 2, is the customer key, column 3 is the total of the customer orders ($$) and column 4 is the number of orders.
oliò Description and Requirements Computer Lab Assignment #9 1. Use Excel and the "Restaurant" data set file located in D2L for this assignment 2. For each class (Class 1 to 14), consider the number of customers for day 7. Call this new variable, day data, as X1. Consider the number of waiters/waitresses as variable X2.Consider the customer satisfaction as vanable Y In another word, create a table for variables Y, X.X2 Dependent Variable: Y Independent Variables: X,X2 3. Find a...
We will use a simple database composed of the following tables: CUSTOMER, INVOICE, LINE, PRODUCT, and VENDOR. This database model is shown in Figure 1. The database model in Figure 1 reflects the following business rules: - A customer may generate many invoices. Each invoice is generated by one customer. - An invoice contains one or more invoice lines. Each invoice line is associated with one invoice. - Each invoice line references one product. A product may be found in...
The following time series represents the hourly customer volume for a small dining establishment. Hour Customer volume 7:00 a.m. 5 8:00 a.m. 5 9:00 a.m. 15 10:00 a.m. 20 11:00 a.m. 30 12:00 noon 50 1:00 p.m. 45 2:00 p.m. 30 3:00 p.m. 40 4:00 p.m. 20 5:00 p.m. 10 Use an exponential smoothing model with α = 0.50 to produce forecasts for this time series. Assume that the forecast for the 7:00 a.m. time slot is 5 customers. What recommendations...