The Van Transportationinc. Scholar Design
The Van Transportationinc.
Scholar Design
The van is a transportation service that assists students from Bloomsburg University Campus to Philadelphia.
The transportation vehicle is a 15-plassenger van that charges students 25 dollars for a ride to Philadelphia.
Company Overview
There are three drop-off points once the bus reaches its destination.
Students may call in to reserve a seat or they can be at the pick-up point located on campus.
There is a one suitcase maximum, if student has additional luggage there will be a $10.00 cost for each extra bag.
Company Overview
“Our mission at THE VAN Transportation is to provide students and visitors with quality and affordable service to and from the Philadelphia area. Our goal is to make every trip you take with our company as swift and reliable as possible. We ensure that our passenger’s safety is the top priority to our well trained drivers.We charge less, we are faster than the rest, and our customer service is the best.”
The Van Mission Statement
The van is a transportation service that assists students from Bloomsburg University Campus to Philadelphia.
The transportation vehicle is a 15-plassenger van that charges students 25 dollars for a ride to Philadelphia.
Company Overview
Each passenger must be at least seventeen years of age, unless accompanied by an adult.
Business Rules
No smoking in the vehicle
Drivers must have a valid license
No alcoholic beverages in vehicle
Business Rules
One luggage per passenger, an addition $10.00 charge applies per each extra luggage.
Business Rules
Round trip tickets come with a 10% discount
Business Rules
All passengers over the age of fifty earn an automatic 10% discount.
Business Rules
Identification must be displayed upon entering the vehicle, to verify age
Business Rules
All drivers must pass on the spot random drug testing.
Business Rules
Drivers must be at least 21 years of age
Business Rules
All new drivers will be place on a 60-day probationary time frame
Business Rules
Students Who attend Bloomsburg University receive a 20% discount
Business Rules
Expenses over $250 are subject to an inspection.
Business Rules
After a customer makes 10 trips he/she earns a free trip.
Business Rules
The Van Database
Customers Table
CREATE TABLE Customers( Cust_id int Primary key auto_increment, Cust_fname varchar(50), Cust_lname varchar(50), Cust_luggage varchar(20), Cust_DOB date not null, Cust_charge double, Student varchar(20) Senior_citizen varchar(20)) Auto_increment=100 Engine=INNODB;
Creating the Tables
Creating the Tables
Employee Table
CREATE TABLE Employee( Emp_id int primary key auto_increment, Emp_fname varchar(50), Emp_lname varchar(50), Emp_DOB date, Emp_address varchar(50), Emp_phonenum varchar(10) not null, HireDate date, Drugscreen timestamp not null) Auto_increment=100 Engine=INNODB;
Creating the Tables
Creating the Tables
Vehicles Table
CREATE TABLE Vehicles( Vehicle_id int primary key auto_increment, Vehicle_vin varchar(50), InspectionDate date, Insurance date) Auto_increment=50 Engine=INNODB;
Creating the Tables
Creating the Tables
Expenses Table
CREATE TABLE Expenses( Transaction_id int primary key auto_increment, Vehicle_id int not null, Parts varchar(50), Parts_cost double, Gas_rt double, Tolls_rt double, Foreign key (Vehicle_id) References Vehicles(Vehicle_id)) Auto_increment=50 Engine=INNODB;
Creating the Tables
Creating the Tables
Employee Driving Offenses Table
CREATE TABLE Employee Driving Offenses( Offense_id int primary key auto_increment, Emp_id int not null, Tickets varchar(20), Tickets_amount double, Accident varchar(20), Cust_complaints varchar(50), Foreign key (Emp_id) References Employee(Emp_id)) Auto_increment=100 Engine=INNODB;
Creating the Tables
Creating the Tables
Customer Trips Table
CREATE TABLE Customer Trips( Cust_id int, Trip_id int primary key auto_increment, Passenger_pickup varchar(50), Passenger_dropoff varchar(50), Foreign key (Cust_id) References Customer(Cust_id), Foreign key (Trip_id) References Trips(Trip_id)) Engine=INNODB;
Creating the Tables
Creating the Tables
Trips Table
CREATE TABLE Trips( Trip_id int primary key(Trip_id) auto_increment, Vehicle_id int not null, Emp_id int not null, Trip_departure timestamp, Trip_arrival timestamp, Vehicle_check timestamp, foreign key (Vehicle_id) References VehicleS(Vehicle_id), foreign key (Emp_id) References Employee(Emp_id)) Engine=INNODB;
Creating the Tables
Creating the Tables
Ticket_Pricing Table CREATE TABLE Ticket_Pricing(Ticket_sticker varchar(50) unique key,Students varchar(50),Non_student varchar(50),Senior_citizen varchar(50),One_way double,Round_trip double,Total double) Engine=INNODB
Creating the Tables
Creating the Tables
INSERT INTO Customers VALUES(null, 'David', 'Goliath', 'Yes', 'No', '1992-10-25');
Inserts For Customers
INSERT INTO Employee VALUES(null, ‘Mark’, ‘Martin’, ‘1959-01-09’, ‘4400 Papa Joe Hendrick Blvd.Charlotte, PA 28262’, ‘7044553400’, ‘2006-05-06’, ‘2012-12-11’);
Inserts For Employee
INSERT INTO Vehicles VALUES(null, '1GBFG154123456789', '2014-10-09', '2014-05-13');
Inserts For Vehicles
INSERT INTO Expenses VALUES(null,54,null,’86.68’,’14.50’);
Inserts For Expenses
INSERT INTO Employee Driving Offenses VALUES(null, 105, null, ‘Running Stop Sign’, ‘119.00’, 0, null);
Inserts For Employee Driving Offenses
INSERT INTO Customer_Trips VALUES(151, 16, 'Bloomsburg', 'Philadelphia', 1, 'Purple');
Inserts For Customer Trips
INSERT INTO Trips VALUES(null, 62, 107, '2013-03-05 011:30:00.0', '2013-03-05 15:32:50.0', '2013-03-05 15:32:50.0');
Inserts For Trips
INSERT INTO Ticket_Pricing(Ticket_sticker,Students,Non_student,Senior_citizen,One_way,Round_trip) VALUES('Purple','Yes','null','null','20.00','null'),('Blue','Yes','null','null','null','36.00'),('White','null','Yes','null','25.00','null'),('Black','null','Yes','Yes','22.50','null'),('Yellow','null','Yes','null','null','45.00'),('Green','null','Yes','Yes','null','40.00'),('Red','Yes','null','Yes','18.00','null'),('Orange','Yes','null','Yes','null','32.00')
Inserts For Prices
Simple Queries This query is used to find out who was on a particular trip SELECT * FROM Customer_Trips WHERE Trip_id = 12;
This query is used to see how many offenses the drivers have:
SELECT Emp_id, COUNT(*) FROM Employee_Driving_Offenses GROUP BY Emp_id;
This query is used to see who was hired between specific dates. SELECT * FROM Employee WHERE hiredate BETWEEN '20060101' AND '20120101';
This query tells us which customers are senior citizens. SELECT Cust_id, cust_fname, cust_lname FROM Customers WHERE
Senior_citizen='Yes';
Simple Queries
This query will tell us which trips a specefic vehicle took
SELECT Trip_id, vehicle_id FROM Trips WHERE vehicle_id = 60;
Simple Queries
This query selects customers who rode in a specific time.
SELECT Customers.Cust_id,Customers.Cust_lname,Trips.Trip_departure FROM Customers,Trips, Customer_Trips WHERE CAST(Trips.Trip_departure AS date) BETWEEN '2013-03-02' AND '2013-03-05' AND Customers.Cust_id=Customer_Trips.Cust_id AND
Customer_Trips.Trip_id=Trips.Trip_id;
Complex Queries
This is used to make sure we have insurance on vehicles that were in accidents
SELECT Expenses.Transaction_id, Expenses.Vehicle_id, Expenses.Parts, Expenses.Parts_cost, Vehicles.Insurance
FROM Expenses RIGHT JOIN Vehicles ON Expenses.Vehicle_id = Vehicles.Vehicle_id WHERE Parts <> 'null' AND Vehicles.Insurance BETWEEN '2013-05-02' AND '2015-01-01';
Complex Queries
Gets all senior citizen customers and there trips counts as well as there age
SELECT DISTINCT Customers.Cust_id, Customers.Cust_fname, Customers.Cust_lname, EXTRACT(year FROM Customers.Cust_DOB) AS Year_born, FLOOR((to_days(CURDATE())-to_days(Cust_DOB))/365.25) AS age , COUNT(Customer_Trips.Cust_id) AS trip_cnt FROM Customers LEFT JOIN Customer_Trips on Customer_Trips.Cust_id=Customers.Cust_id WHERE Senior_citizen='Yes' GROUP by Customer_Trips.Cust_id
Complex Queries
Gives the number of trips Taken by an Employee in the date range
SELECT Employee.Emp_lname, Employee.Emp_id, count(Trips.Emp_id) as trip_count
from Employee left join Trips on Trips.Emp_id=Employee.Emp_id where cast(Trip_departure as date) between '2013-03-01' and '2013-03-02' group by Employee.Emp_lname order by Employee.Emp_lname;
Complex Queries
SELECT Customer_Trips.trip_id, Customer_Trips.cust_id, Ticket_Pricing.one_way, Ticket_Pricing.round_trip,
Customer_Trips.Cust_luggage, ((Customer_Trips.Cust_luggage *10)-10) AS "Luggage_Price",((Ticket_Pricing.one_way)+(Ticket_Pricing.round_trip))+
(Customer_Trips.Cust_luggage *10)-10 AS "Total" FROM Customer_Trips, Ticket_Pricing WHERE Customer_Trips.Ticket_sticker = Ticket_Pricing.Ticket_sticker;
Customer Invoice
This pulls the employee who had the most trips
SELECT a.Emp_id, max(a.ctr) as num_of_trips from (select Emp_id, count(Emp_id) as ctr from Trips group by Emp_id) as a;
Sub Query Queries
This pulls the number of Employees that had offenses with both complaints and tickets on the same day
SELECT a.ctr as num_emps FROM (SELECT count(emp_id) as ctr from Employee_Driving_Offenses where Tickets is not null and Cust_complaints is not null) as a
Sub Query Queries
This query gets all passengers and the driver from a specific trip and vehicle that was in an accident.
SELECT DISTINCT C.Cust_lname, E.Emp_lname FROM Employee as E, Customers as C, Trips as T, Customer_Trips as CT,
Vehicles V Where T.Emp_id=E.Emp_id and CT.Cust_id=C.Cust_id and CT.Trip_id=T.Trip_id and T.Trip_id='16' and V.Vehicle_id=T.Vehicle_id and V.Vehicle_id='60' and cast(T.Trip_departure as date)='2013-03-04‘;
Sub Query Queries
This query gets the number of expenses for each vehicle SELECT DISTINCT a.Vehicle_id, max(a.ctr) AS count from(select Vehicle_id,
count(Vehicle_id) AS ctr from Expenses GROUP by Vehicle_id) AS a GROUP by a.Vehicle_id;
Sub Query Queries
This pulls the customer who took the most trips SELECT a.Cust_id, max(a.ctr) AS number_of_trips FROM (select Customer_Trips.Cust_id, COUNT(Customer_Trips.Cust_id) AS
ctr FROM Customer_Trips GROUP by Customer_Trips.Cust_id) AS a;
Sub Query Queries
Shows which trips the employee has driven on.
SELECT Employee.Emp_id, Employee.Emp_lname, Trips.Trip_id FROM Employee RIGHT JOIN Trips ON Employee.Emp_id = Trips.Emp_id;
Join Queries
Shows the employee's information along with their driving offenses.
SELECT * from Employee INNER JOIN Employee_Driving_Offenses ON
Employee.Emp_id=Employee_Driving_Offenses.Emp_id;
Join Queries
Gets all employees and there trips as well as the vehicle SELECT Employee.Emp_fname, Employee.Emp_lname,
Employee.Emp_phonenum, Trips.Trip_id, Vehicles.Vehicle_id FROM Employee INNER JOIN Trips on Trips.Emp_id=Employee.Emp_id INNER JOIN Vehicles on Vehicles.Vehicle_id=Trips.Vehicle_id;
Join Queries
Lists all the customers trips SELECT Customers.Cust_fname, Customers.Cust_lname,
Customer_Trips.Trip_id FROM Customers INNER JOIN Customer_Trips on Customer_Trips.Cust_id=Customers.Cust_id;
Join Queries
This query pulls the employees who have gotten a ticket SELECT Employee.Emp_id, Employee.Emp_lname,
COUNT(Employee_Driving_Offenses.Emp_id) AS offenses FROM Employee LEFT JOIN Employee_Driving_Offenses ON
Employee_Driving_Offenses.Emp_id=Employee.Emp_id WHERE Accident_date is not null GROUP by Employee.Emp_id ORDER by Employee.Emp_id;
Join Queries
SELECT Emp_lname, Emp_idFROM
(SELECT * FROM Employee WHERE HireDate BETWEEN '20060101' AND '20120101') AS
EmployeeDerivedTableWHERE Drugscreen BETWEEN '2012-12-11 00:00:00.0' AND '2013-05-04 00:00:00.0' ORDER BY Emp_lname
Derived Table
SELECT Transaction_id, Parts_costFROM
(SELECT * FROM ExpensesWHERE Parts_cost > '250') AS ExpenseDerivedTable
WHERE Parts <> 'null';
Derived Table