Jallow_Report

22
MIS 02336: Advanced Database Management; Assignment 2 (SQL) Kieran Crean 916069627 Alex Dickinson 916069420 Jimmy Hiltwine 916072712 Joe Miller 916078856 Alex Pileggi 916105398 4/30/2015

Transcript of Jallow_Report

Page 1: Jallow_Report

MIS 02336: Advanced Database Management; Assignment 2 (SQL)

Kieran Crean 916069627

Alex Dickinson 916069420

Jimmy Hiltwine 916072712

Joe Miller 916078856

Alex Pileggi 916105398

4/30/2015

Page 2: Jallow_Report

Table of Contents

1.1 Summary

1.2 Introduction

1.3 Business / Enterprise Rules

1.4 ERD Diagram

1.5 Relations

1.6 Implementation Details

1.7 Database Manipulation & Control

1.8 Notation of E-R Diagrams

1.9 Conclusion

1.10 Recommendations

1.11 End Matter

Page 3: Jallow_Report

1.1 Summary

This database is to review the effectiveness of the newly hired general manager. This manager was hired on January 1st and all of the information presented will be in relation to his managerial review in response to his first six months of employment. Prior to his employment, our new manager said he wanted to fix a list of things about this park and they were as follows: standardize prices to find the most profitable, create a customer loyalty and retention program, efficiently log all maintenance performed on every attraction, and above all else create the best experience possible at an amusement park.

His first order of business was to standardize all prices to know exactly what rides were most profitable and what he could possibly charge more or less for in the future depending on the attraction’s popularity. Secondly, our general manager created a customer incentive program through running queries to see if our visitors haven’t traveled to Adventure Place in a certain amount of time. With this information he can see the last date a customer had visited the park and add them to a personalized email blast that makes the customer feel they are valued by our company. The maintenance schedule had originally been a problem for Adventure Place because before the new year, employees were not required to log their maintenance performances and there was no official way to check that these rides were checked before the start of every day. Before our new general manager, rides would shut down throughout the day and would not be operational until the next business day; but now that we know all rides are being serviced, we are confident there will not be any down-time throughout our business day. 1.2 Introduction

We are experiencing a rotation of managerial staff. The new general manager has been hired from an investment firm and has no previous amusement park experience but is very interested to learn. Adventure Place has been losing a lot of money recently because the customers do not feel they are valued by us and rides have been breaking down constantly. He has created a checklist of things he wants to have accomplished before his six-month review that will take place on June 1st. These will include: flattened prices, a customer rewards program, and a full revamp of our maintenance on all of our attractions. He guarantees this will fix all of the problems Adventure Place has been experiencing.

1.3 Business / Enterprise Rules

Page 4: Jallow_Report

1. Each Visitor that comes to Adventure Place must purchase at least one ticket through the

Ticket Booth.

2. Each Visitor will be asked to supply their Zip Code and Email address.

3. The Ticket Booth will sell the tickets to each Visitor. An ID number will be generated for

each new visitor that comes. An OrderID will hold all of the information pertaining to the one specific attraction transaction. An OrderID must have at least one AttractionID, but can have more, and also only one VisitorID can be associated with an OrderID.

4. Each Attraction requires the Visitor to have at least one ticket to ride one time.

5. At least one Maintenance Staff member must be on the Maintenance Schedule for each

day, but each Maintenance Staff member may only service one ride per day.

6. Each entry in the Maintenance Schedule will contain: its own Maintenance ID, the

Maintenance Staff member working on the attraction, the ID number of the attraction, the starting and ending time of the maintenance and a description of the job being done.

7. Each entry in the Attraction Schedule will contain: its own Shift ID, the Attraction Staff

member working on the attraction, the ID number of the attraction and the starting and ending time of the shift.

8. Every attraction must be serviced and inspected each day by at least one member of the

Maintenance Staff, but could be serviced by more than one member of the Maintenance Staff.

Page 5: Jallow_Report

1.4 Entity – Relationship Diagram

1.5 Relations

● Visitor - Ticket Booth (One to Many)

● Ticket Booth - Attraction (One to One)

● Attraction - Maintenance Schedule (One to Many)

Page 6: Jallow_Report

● Attraction - Attraction Schedule (One to Many)

● Attraction Schedule - Attraction Staff(One to Many)

● Maintenance Schedule - Maintenance Staff (One to Many)

1.6 Implementation Details

1.6.1 Visitor Table

CREATE TABLE `Visitor` ( `VisitorID` int(11) NOT NULL, `LastName` varchar(25) NOT NULL, `FirstName` varchar(25) NOT NULL, `ZIP` char(5) DEFAULT NULL,

Page 7: Jallow_Report

`Email` varchar(100) DEFAULT NULL, `Date_Last_Visited` date NOT NULL, PRIMARY KEY (`VisitorID`));

1.6.2 TicketBooth Table

CREATE TABLE `TicketBooth` (

Page 8: Jallow_Report

`OrderID` int(11) NOT NULL, `VisitorID` int(11) NOT NULL, `AttractionID` varchar(5) NOT NULL, `PurchaseDate` date NOT NULL, `Quantity` int(10) DEFAULT NULL, `Total` decimal(10,2) DEFAULT NULL, PRIMARY KEY (`OrderID`,`AttractionID`,`VisitorID`), KEY `TicketBooth_Visitor_FK` (`VisitorID`), KEY `TicketBooth_Attraction_FK` (`AttractionID`), CONSTRAINT `TicketBooth_Attraction_FK` FOREIGN KEY (`AttractionID`) REFERENCES `Attraction` (`AttractionID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `TicketBooth_Visitor_FK` FOREIGN KEY (`VisitorID`) REFERENCES `Visitor` (`VisitorID`) ON DELETE NO ACTION);

1.6.3 Attraction Table

CREATE TABLE `Attraction` ( `AttractionID` varchar(5) NOT NULL, `Name` varchar(15) NOT NULL, `Description` varchar(150) NOT NULL, `Price` decimal(12,2) NOT NULL, PRIMARY KEY (`AttractionID`));

Page 9: Jallow_Report

1.6.4 AttractionSchedule Table

CREATE TABLE `AttractionSchedule` ( `ShiftID` varchar(5) NOT NULL, `AttractionID` varchar(5) NOT NULL, `StaffID` int(11) NOT NULL, `Time_Start` datetime DEFAULT NULL, `Time_End` datetime DEFAULT NULL, PRIMARY KEY (`ShiftID`), KEY `AttractionSchedule_MaintenanceStaff_FK` (`StaffID`), KEY `AttractionSchedule_Attraction_FK` (`AttractionID`), CONSTRAINT `AttractionSchedule_Attraction_FK` FOREIGN KEY (`AttractionID`) REFERENCES `Attraction` (`AttractionID`) ON DELETE CASCADE ON UPDATE CASCADE,

Page 10: Jallow_Report

CONSTRAINT `AttractionSchedule_MaintenanceStaff_FK` FOREIGN KEY (`StaffID`) REFERENCES `AttractionStaff` (`StaffID`) ON DELETE CASCADE ON UPDATE CASCADE);

1.6.5 AttractionStaff Table

CREATE TABLE `AttractionStaff` ( `StaffID` int(11) NOT NULL, `LastName` varchar(25) NOT NULL, `FirstName` varchar(25) NOT NULL, `YearOfHire` int(4) NOT NULL, PRIMARY KEY (`StaffID`));

Page 11: Jallow_Report

1.6.6 MaintenanceSchedule Table

CREATE TABLE `MaintenanceSchedule` ( `MaintenanceID` int(11) NOT NULL, `AttractionID` varchar(5) NOT NULL, `MaintenanceStaffID` int(11) NOT NULL, `Time_Start` datetime DEFAULT NULL, `Time_End` datetime DEFAULT NULL, `Description` varchar(200) DEFAULT NULL, PRIMARY KEY (`MaintenanceID`), KEY `MaintenanceSchedule_MaintenanceStaff_FK` (`MaintenanceStaffID`), KEY `MaintenanceSchedule_Attraction_FK` (`AttractionID`), CONSTRAINT `MaintenanceSchedule_Attraction_FK` FOREIGN KEY (`AttractionID`) REFERENCES `Attraction` (`AttractionID`) ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT `MaintenanceSchedule_MaintenanceStaff_FK` FOREIGN KEY (`MaintenanceStaffID`) REFERENCES `MaintenanceStaff` (`MaintenanceStaffID`) ON DELETE CASCADE ON UPDATE CASCADE);

Page 12: Jallow_Report

1.6.7 MaintenanceStaff Table

CREATE TABLE `MaintenanceStaff` ( `MaintenanceStaffID` int(11) NOT NULL, `LastName` varchar(25) NOT NULL, `FirstName` varchar(25) NOT NULL, `YearOfHire` int(4) NOT NULL, PRIMARY KEY (`MaintenanceStaffID`));

Page 13: Jallow_Report

1.7 Database Manipulation and Control1.7.1 Customer Loyalty System

SELECT Email, FirstName, LastName, Date_Last_VisitedFROM VisitorWHERE Date_Last_Visited <'2015-01-31'ORDER BY Date_Last_Visited;

Page 14: Jallow_Report

1.7.2 Revenues

SELECT TB.AttractionID, Name, Sum(Total) AS AttractionRevenueFROM TicketBooth TBINNER JOIN Attraction A ON TB.AttractionID=A.AttractionIDWHERE PurchaseDate BETWEEN ‘2015-01-01’ AND ‘2015-03-31’GROUP BY AttractionID ORDER BY AttractionRevenue DESC;

1.7.3 Maintenance

SELECT A.AttractionID, MS.MaintenanceStaffID, MS.FirstName, MS.LastName, M.Description, M.Time_Start, M.Time_End

FROM MaintenanceStaff MS

INNER JOIN MaintenanceSchedule M ON MS.MaintenanceStaffID=M.MaintenanceStaffID

INNER JOIN Attraction A ON M.AttractionID=A.AttractionID

WHERE A.AttractionID='RC01';

Page 15: Jallow_Report

SELECT FirstName, LastName, YearOfHireFROM MaintenanceStaffWHERE EXISTS(SELECT MaintenanceStaffID,AttractionID FROM MaintenanceSchedule WHERE MaintenanceSchedule.MaintenanceStaffID=MaintenanceStaff.MaintenanceStaffID AND AttractionID='RC01');

1.7.4 Visitor Preference

SELECT COUNT(DISTINCT(VisitorID)) AS UniqueVisitors, AVG(Quantity) AS AverageQuantity

FROM TicketBooth;

SELECT TB.AttractionID,A.Name,COUNT(DISTINCT VisitorID) AS UniqueVisitors, AVG(Quantity) AS AverageTicketsPurchased FROM TicketBooth TB INNER JOIN Attraction A ON TB.AttractionID=A.AttractionIDWHERE PurchaseDate BETWEEN '2015-01-01' AND '2015-03-31'GROUP BY AttractionIDORDER BY UniqueVisitors DESC;

1.7.5 Customer Rewards

Page 16: Jallow_Report

SELECT DISTINCT TB.VisitorID, V.FirstName, V.LastName, V.Zip, SUM(Quantity) AS Quantity, SUM(Total) AS Total

FROM TicketBooth TB

INNER JOIN Visitor V ON TB.VisitorID=V.VisitorID

GROUP BY TB.OrderID

ORDER BY Total DESC

LIMIT 10;

1.7.6 Employee Schedule

Page 17: Jallow_Report

CREATE VIEW Attraction_Schedule_4_27 AS

SELECT AT.AttractionID,Name, AT.StaffID, FirstName, LastName, Time_Start, Time_End

FROM AttractionSchedule AT INNER JOIN AttractionStaff ATS ON AT.StaffID=ATS.StaffID INNER JOIN Attraction A WHERE AT.AttractionID=A.AttractionID

AND Time_Start LIKE '2015-04-27%'

ORDER BY AttractionID, Time_End;

1.8 Notation of E-R Diagrams

Each visitor has to buy at least one ticket to enter the park, but one ticket can be bought by one or many customers. The ticket booths relate to one specific attraction and one attraction can only be associated with one specific admission with a single ticket. Rides must be serviced once a day by one or more maintenance workers, and attractions must also be manned by one or more attraction staff. The schedule of attraction staff is determined by a specific identifier to their shift number and each staff member can only have one specific number for a specific task. 1.9 Conclusion

The implementation of this database was very important to effectively grade the performance of our new general manager. The information he presented us told us exactly what we needed to know in reference to what attractions our visitors were most interested in and how

Page 18: Jallow_Report

we can better plan for the future. His customer loyalty program was a great success and we are seeing more repeat customers than ever before, according to the data we were provided. Finally, we have not had more than a few hours that an attraction has been down and we could not say that before our current general manager. The maintenance schedule that was created has solved so many problems we were having and we will no longer lose money because a ride has to be shut down for the day. It is our pleasure to say that we have extended the employment of our general manager and we have many plans for our future. With his help, we want to expand Adventure Place by adding more attractions and doubling our staff within the next five years. We have made a lot of progress in the past six months and we have nothing but confidence for the future as our business has been completely turned around.

1.10 Recommendations

We have few recommendations to make since the database project clearly outlined many of the problems Adventure Place was having. First of all, we will change the price of the general admission depending on the attraction our visitors will want to use. The prices will have separate variations of dollars or cents to either make more profit on some attractions or create more interest for other rides because of their discounted prices. We plan to keep up with, and constantly try and improve our customer loyalty program because we wouldn’t be as successful as we are today without our loyal visitors. Our plan is to revamp the maintenance schedule for the future and make it more detailed so anyone can read it and possibly understand how to maintenance our rides. This may be a concern for future employees who are not experienced as our current workers, but we would like to have documentation related to certain maintenance routines so anyone can search for the type of maintenance they are trying to perform and will be able to teach themselves. Finally, we will constantly be monitoring the amount of visitors we have and the tickets we sell through our new database system. We owe all of our success to our general manager and will build upon the foundation he has provided us.