Lakeshore Auto Database System Project                         Sunny Okoro                          DBST651, Spring 2011  ...
Table of Contents       Deliverable 1 – Statement of Work (SOW)..............................................................
Deliverable 1 – Statement of Work (SOW)Overview:I will create a database for Lakeshore car dealership as part of their web...
Composition SoftwareNotepad +++ for writing and editing SQL commandsHardware and SoftwareMicrosoft Windows 7 Professional ...
4
ERD DescriptionCustomer TableA customer can be associated with one or more repair record(s).A customer should place one or...
Repair RecordA car must be associated with one or more repair record(s)One or more repair records must be associated with ...
City    VARCHAR2(30), Cust_State VARCHAR2(3), Zip_Code NUMBER, Phone_1 NUMBER, Phone_2 NUMBER, Email VARCHAR2(30));/* Crea...
/* Creates table agent to hold all information relating to an agent beginning with drop statement to check if a table has ...
Alter table "agent"modify (First_Name constraint aget_first_name_nn not null)modify (Middle_Name constraint aget_middle_na...
Alter table "car"modify (Brand_Name constraint car_Brand_Name_nn not null)modify (Model constraint car_Model_nn not null)m...
Create table CarSales( Transaction_ID Number constraint carsales_transaction_id_pk primary key, Agent_Id Number, Car_Id Nu...
Alter table CarSalesmodify (agent_id constraint csale_agent_id_nn not null)modify (car_id constraint csale_car_id_nn not n...
***** Reservation Table Begins *****/* Creates table reservations beginning with drop statement to check if a table has be...
/*Adds the foreign key constraint to link customer and reservation tables*/Alter table "reservations" add constraint reser...
/*Drop the column notes since it has Binary large Object data type meant for media files*/Alter table "reservations" Drop ...
Phone Number,  Phone_2 Number,  Email VARCHAR2(30));/*Add the primary key constraint to the mechanic table*/ALTER TABLE "m...
modify (Last_Name constraint meach_last_name_nn not null)modify(Address constraint meach_address_nn not null)modify(city c...
/* creates the not null constraints to make sure each column contains data*/ Alter table RepairRecord Modify (amount_charg...
Alter table RepairRecordAdd constraint repair_car_id_fk foreign key(car_ID)   References "car"(car_id) ON DELETE CASCADE;/...
insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, emai...
values (customer_cust_id_seq.nextval, tyra, nancy,cdale, 809 W.highway drive, Niles, IL,64560,8475678907,trya.cdale@bbb.ed...
insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, emai...
insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, emai...
insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, emai...
insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, emai...
values (agent_agent_id_seq.nextval, celin, whitney, Doveward, 870 jackson street,Gary, IN,46401,2195612505,celin@lakeshore...
values (agent_agent_id_seq.nextval, maryanne, linda, stephine, 89 churchhill ,lake, in, 46408, 00000, na);/* inserts data ...
Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservat...
(select customer_id from "customer" where customer_id = 90730));   Insert into "reservations"(request_id, request_date, re...
Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_...
values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1405, service,oil change,(select customer_i...
Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_...
values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 1045, service,repair,        (select custom...
values (car_car_id_seq.nextval, ford focus, 2008, 2007, ford);   Insert into "car" (car_id, brand_name, model, year_made, ...
Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2002, 2004, toyota)...
Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, Fit, 2011, 2010, honda);   ...
values (car_car_id_seq.nextval, Genesis, 2010, 2009, hyndai);       Insert into "car" (car_id, brand_name, model, year_mad...
insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)val...
Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tir...
Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy),  ( Select mechanic_id from "mechan...
( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2058),90730,35000,...
290.99, 90.99, fixed the front bumper, repair both front and back bumpers due to car accident);  Insert into RepairRecord(...
Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire...
values (repair_id_seq.nextval, to_date(01-FEB-11, dd-mon-yyyy),  ( Select mechanic_id from "mechanic" where mechanic_id = ...
( Select mechanic_id from "mechanic" where mechanic_id = 7120), (select car_id from "car" where car_id =2038), 90770,55000...
50, 50); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_serv...
Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire...
values (repair_id_seq.nextval, to_date(04-FEB-11, dd-mon-yyyy),  ( Select mechanic_id from "mechanic" where mechanic_id = ...
(select car_id from "car" where car_id = 2012),to_date (31-jan-2011, dd-mon-yyyy),              19000, 0,19000,0, 90810); ...
14000, 0, 14000 ,0, 0, 0, 91170 ); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check,...
insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMAN...
Reports./* manager wants to know which clients came in for car loan or car browsing*/select customer_id, to_char(request_d...
/*Manager wants to know which clients came in for car sale*/select customer_id, to_char(request_date) as Request__Date, re...
/*manager wants to know which client received which service for service option */                                         ...
CUSTOMER_ID   REQUEST_DATE   REQUEST_TIME   SERVICE_OPTION90570         31-Jan-11      935            Tire Change         ...
/*Manger wants to know which clients don’t have any phone number listed */select initcap (first_name)||,||initcap(last_nam...
update "customer"set Phone_1 = 2192248902where customer_id = 90930;update "customer"set Phone_1 = 8159091450where customer...
update "customer"set Phone_1 = 31989081234where customer_id = 91410;update "customer"set Phone_1 = 2198800903select custom...
update "customer"set city =indiana citywhere customer_id = 90530;update "customer"set address = 9090 michigan avewhere cus...
set zip_code=41909where customer_id = 90810;update "customer"set city =indiana citywhere customer_id =90890;update "custom...
CUSTOMER_ID   MECHANIC_ID   REPAIR_DATE   REPAIR_NOTES90650         7000          31-Jan-1190690         7120          31-...
/* Manager wants to know the name of clients who made request */  select c.customer_id, first_name||,|| last_name as clien...
select m.mechanic_id, m.first_name||,||m.last_name as Mechnaic, c.model, c.car_Id, r.repair_id from "mechanic" m inner joi...
justice                 2010            2036           6160            $50.00                    $50.00/* Manager wants to...
3872   1-Feb-11    $70.99    $70.99    293.964912   2-Feb-11    $490.99   $490.99   851.974704   2-Feb-11    $100.99   $10...
/* Manager want to know the amount paid total by check without renaming balance*/select to_char(sum(amount_paid_check), $9...
------------ $114,060.00/* Manager want to know which agent sold a car */ select a.agent_id,a.car_id, c.model, initcap (c....
select a.agent_id,a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,|...
from CarSales a inner join "car" c on a.car_id = c.car_id inner join "agent" b on b.agent_id = a.agent_id order by maker;s...
on          a.car_id = c.car_id          where city =blueisland or city = East ChicagoCUSTOMER_ID CITY                 CAR...
a.car_id = c.car_id           where CUST_STATE in (‘IL’, ‘il’,’Il’)CUSTOMER_ID CITY                CAR_ID          TRANSAC...
a.car_id = c.car_id         where CUST_STATE in (IN, in, In);CUSTOMER_ID   CITY                CAR_ID           TRANSACTIO...
REQUEST_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION790177    31-Jan-11     935          tire change790266    31-Jan-11    ...
792135     2-Feb-11    1045   repair792224     2-Feb-11    1125   battery change792313     2-Feb-11    945792402     2-Feb...
Upcoming SlideShare
Loading in …5
×

Database Design Project-Oracle 11g

813 views

Published on

0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
813
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Database Design Project-Oracle 11g

  1. 1. Lakeshore Auto Database System Project Sunny Okoro DBST651, Spring 2011 Graduate School University of Maryland University College
  2. 2. Table of Contents Deliverable 1 – Statement of Work (SOW).........................................................................................................................................................................2 Overview: ............................................................................................................................................................................................................................2 Purpose and Objective: ........................................................................................................................................................................................................2 Diagram Tool .......................................................................................................................................................................................................................2 Database...............................................................................................................................................................................................................................2 Composition Software .........................................................................................................................................................................................................3 Hardware and Software .......................................................................................................................................................................................................3 DDL, TCL and DML ...........................................................................................................................................................................................................3 Deliverable 2 – ERD............................................................................................................................................................................................................3 Deliverable 3 – DDL (Data Definition Language) ..............................................................................................................................................................6 Deliverable 4 – DML (Data Manipulation Language) ............................................................................................................................................................19 Insert Statements ..................................................................................................................................................................................................................19Reports. .....................................................................................................................................................................................................................................52 1
  3. 3. Deliverable 1 – Statement of Work (SOW)Overview:I will create a database for Lakeshore car dealership as part of their web system. This database would keep track for number of cars sold and number ofcars that are repaired at their shop.Purpose and Objective:This database will enable clients to buy their car or service their car without filling the paper works. New clients can have their information enteredinto the system enabling a speedy service next time they return for a new car or repair service. The web service would allow clients to make appointmentfor car repair service or for a new car sale which are sent directly to the shop or sales associates housed in Oracle DB. The DB can also be used bymanagers to produce monthly and weekly statistical reports.Diagram ToolOracle SQL Developer Data MolderDatabaseOracle 11g 2
  4. 4. Composition SoftwareNotepad +++ for writing and editing SQL commandsHardware and SoftwareMicrosoft Windows 7 Professional x64DDL, TCL and DMLOracle SQL would be used for the Data Definition, Data Manipulation and Transaction Control languages of to build the database. I would also useDatabase objects including constraints, views, index and sequences to generate unique values for Primary Key. Deliverable 2 – ERD 3
  5. 5. 4
  6. 6. ERD DescriptionCustomer TableA customer can be associated with one or more repair record(s).A customer should place one or more reservation(s).A customer can be associated with one or more car sale(s).Car Sales TableA Car sale must be associated with one agentOne or more car sales must be associated with a carAgent TableAn agent must be associated with one or more car salesMechanic TableA mechanic must be associated with one or more repair record(s)Reservations TableOne or more reservations must be associated to a customer.Car TableA car must be associated with one or more car sale(s) 5
  7. 7. Repair RecordA car must be associated with one or more repair record(s)One or more repair records must be associated with a mechanic. Deliverable 3 – DDL (Data Definition Language) I grouped all the DDL for a particular table in one area to make it easier to read. I did not use the drop statement because there were no needs for me touse them since I have not created any of these objects before even though I included them on this document. ***** Customer Table *****/* creates the car sales table but first I had to check if a table has the same name with a drop statement */Drop table "customer";Create table "customer"(Customer_id Number constraint customer_cust_id_pk primary key, First_Name VARCHAR2(35), Middle_Name VARCHAR2(35), Last_Name VARCHAR2(35), Address VARCHAR2(30), Address_2 VARCHAR2(25), 6
  8. 8. City VARCHAR2(30), Cust_State VARCHAR2(3), Zip_Code NUMBER, Phone_1 NUMBER, Phone_2 NUMBER, Email VARCHAR2(30));/* Creates a sequence to hold PK for customer table. I used the drop statement to check if any sequence has been created before with the same name */Drop Sequence customer_cust_id_seq;CREATE SEQUENCE customer_cust_id_seqStart with 090090Increment by 40nocycle;/*Adds the not null constraints to allows each columns with this constraint to have value*/Alter table "customer"modify (First_Name constraint cust_first_name_nn not null)modify (Middle_Name constraint cust_middle_name_nn not null)modify (Last_Name constraint cust_last_name_nn not null)modify(Address constraint cust_address_nn not null)modify(city constraint cust_city_nn not null)modify(cust_state constraint cust_state_nn not null)modify(phone_1 constraint cust_phone_1_nn not null); ***** Agent Table Begins ***** 7
  9. 9. /* Creates table agent to hold all information relating to an agent beginning with drop statement to check if a table has been created before with samename.*/Drop table "agent";Create table "agent"( Agent_ID Number constraint agennt_agent_id_pk primary key, First_Name VARCHAR2(35), Middle_Name VARCHAR2(35), Last_Name VARCHAR2(35), Address VARCHAR2(50), City VARCHAR2(30), Agent_State VARCHAR2(3), Zip_Code NUMBER, Phone Number, Phone_2 Number, Email VARCHAR2(30));/* Creates sequence to generate unique id for agent table request id. Used the drop statement to check if a sequence with same name has been createdbefore.*/Drop sequence agent_agent_id_seq;CREATE SEQUENCE agent_agent_id_seqstart with 008000increment by 079nocycle;/* Adds the not null constraint to make sure each column has a value specified by upon input.*/ 8
  10. 10. Alter table "agent"modify (First_Name constraint aget_first_name_nn not null)modify (Middle_Name constraint aget_middle_name_nn not null)modify (Last_Name constraint aget_last_name_nn not null)modify(Address constraint aget_address_nn not null)modify(city constraint aget_city_nn not null)modify(agent_state constraint aget_state_nn not null)modify(phone constraint aget_phone_1_nn not null); ***** Car Table Begins*****/* Creates the table repair record but first I have to check if any table has been created before using the same name with the drop statement.*//*creates the car table to hold data related to cars*/Drop table "car";Create table "car"( Car_Id NUMBER constraint car_car_id_pk primary key, Brand_Name VARCHAR2(30), Model Number, Year_Made NUMBER, Notes blob);/* Creates the not null constraints to make sure each column contains data*/ 9
  11. 11. Alter table "car"modify (Brand_Name constraint car_Brand_Name_nn not null)modify (Model constraint car_Model_nn not null)modify (Year_Made constraint car_Year_Made_nn not null);/* Adds the column marker to the car table.*/Alter table "car" add maker varchar2(34);/* Creates the not null constraints to make sure each column contains data*/ Alter table "car" modify (maker constraint car_maker_nn not null);/* Creates the sequence to produce the car_id PK value but first I have to check if any sequence has been created before using the same name with thedrop statement.*/Drop sequence car_car_id_seq;CREATE SEQUENCE car_car_id_seqstart with 2000increment by 02nocycle; ***** Car Sales Table Begins *****/*Creates the car sales table but first I had to check if a table has the same name with a drop statement.*/Drop table CarSales; 10
  12. 12. Create table CarSales( Transaction_ID Number constraint carsales_transaction_id_pk primary key, Agent_Id Number, Car_Id Number, Sales_Date NUMBER, Amount_Paid_Cash NUMBER, Amount_Paid_check NUMBER, Amount_Paid_Loan NUMBER, Total_Paid NUMBER, Remaning_Amoount NUMBER, Payment_Plan NUMBER, Number_Months NUMBER, Number_Days NUMBER);/*Creates a sequence to hold PK for car sales table. I used the drop statement to check if any sequence has been created before with the same name. */Drop Sequence carsales_trans_id_seq;CREATE SEQUENCE carsales_trans_id_seqstart with 0899999increment by 089nocycle;/*Change the sales_date column data type to date*/Alter table CarSales modify sales_date date default sysdate;/* Adds the null constraint meaning that each column specified won’t contain null data */ 11
  13. 13. Alter table CarSalesmodify (agent_id constraint csale_agent_id_nn not null)modify (car_id constraint csale_car_id_nn not null)modify (sales_date constraint csale_sales_date_nn not null)modify(total_paid constraint csale_total_paid_nn not null);/* Adds the customer_id column to hold the FK value to link customer table and car sales table */Alter table CarSales Add customer_id number;/*Adds the foreign keys needed to link car sales table with agent, car and customer tables */Alter table CarSales Add constraint csale_car_id_fk foreign key (car_id) References "car"(Car_id) on delete cascade;Alter table CarSalesAdd constraint csale_agent_id_fk foreign key(agent_id) references "agent"(agent_id)on delete cascade;Alter table CarSalesAdd constraint csale_customer_id_fk foreign key(customer_id)references "customer"(customer_id) on delete cascade;Alter table CarSales MODIFY(Customer_id constraint csale_customer_id_nn not null);Alter table CarSales rename column remaning_amoount to remaning_amount; 12
  14. 14. ***** Reservation Table Begins *****/* Creates table reservations beginning with drop statement to check if a table has been created before with same name. */Drop table "reservations";Create table "reservations"( Request_Id Number constraint reservation_request_id_pk primary key, Request_Date Number, Request_Time Number, Request_Type VARCHAR2(15), Service_Option VARCHAR2(15), Customer_Id NUMBER, Notes BLOB);/*Adds the not null constraint to make sure each column has a value specified by an input */Alter table "reservations"modify (Request_Date constraint resv_request_Date_nn not null)modify (Request_Time constraint resv_request_Time_nn not null)modify (Request_Type constraint resv_request_Type_nn not null);Alter table "reservations"Modify (Customer_Id constraint resrvation_customer_id_nn not null); 13
  15. 15. /*Adds the foreign key constraint to link customer and reservation tables*/Alter table "reservations" add constraint reserv_customer_id_fk foreign key (customer_id) references "customer" (customer_id) on delete cascade;/* Creates sequence to generate unique id for reservation table request id. Used the drop statement to check if a sequence with same name has beencreated before.*/Drop sequence reservation_request_id_seq;CREATE SEQUENCE reservation_request_id_seqstart with 0789999increment by 089nocycle;/*These check constraints make sure that user selected a particular service when making reservations*/Alter table "reservations"Add constraint resvs_request_type_ck check ( Request_Type in (car sale, car loan, car browsing,service));Alter table "reservations"Add constraint resv_service_option_ck check(service_option in (oil change, battery change, tire change, repair, other));/* Change the request_date column data type to date*/Alter table "reservations" Modify request_date date default sysdate; 14
  16. 16. /*Drop the column notes since it has Binary large Object data type meant for media files*/Alter table "reservations" Drop column notes;/* Adds the notes column with the right data type character large object to hold text*/Alter table "reservations" Add Notes clob; ***** Mechanic Table Begins*****/*Creates table to hold mechanic contact information beginning with drop statement to check if a table has been created before with same name. */Drop table "mechanic"; Create table "mechanic"(Mechanic_ID Number , First_Name VARCHAR2(35), Middle_Name VARCHAR2(35), Last_Name VARCHAR2(35), Address VARCHAR2(50), City VARCHAR2(30), Agent_State VARCHAR2(3), Zip_Code NUMBER, 15
  17. 17. Phone Number, Phone_2 Number, Email VARCHAR2(30));/*Add the primary key constraint to the mechanic table*/ALTER TABLE "mechanic"add constraint mechanic_mechanic_id_pk primary key(Mechanic_ID);/*change the name of the column which happened due to a copy and paste error*/ALTER TABLE "mechanic" Rename column Agent_State to mechanic_State;/*Creates sequence to generate unique id for mechanic table request id. Used the drop statement to check if a sequence with same name has been createdbefore.*/Drop sequence meach_meachinic_id_seq;CREATE SEQUENCE meach_meachinic_id_seqstart with 007000increment by 030nocycle;/*Adds the not null constraint to make sure each column has a value specified by an input.*/Alter table "mechanic"modify (First_Name constraint meach_first_name_nn not null)modify (Middle_Name constraint meach_middle_name_nn not null) 16
  18. 18. modify (Last_Name constraint meach_last_name_nn not null)modify(Address constraint meach_address_nn not null)modify(city constraint meach_city_nn not null)modify(mechanic_State constraint meach_state_nn not null)modify(phone constraint meach_phone_1_nn not null ***** Repair Record Table Begins*****/* Creates the table repair record but first I have to check if any table has been created before using the same name with the drop statement.*/Drop table RepairRecord;Create table RepairRecord(Repair_Id NUMBER Constraint repair_repair_id_pk primary key, Repair_Date DATE DEFAULT SYSDATE, Mechanic_ID Number, Car_Id Number, Customer_id Number, Mileage Number, Oil_Change VARCHAR2(3), Battery_Change VARCHAR2(3), Tire_Change VARCHAR2(3), Repair_Services VARCHAR2(3), Repair_Notes BLOB, Body_Paint VARCHAR2(15), Mechanic_Notes CLOB, Amount_Charged NUMBER, Credit_Card_Number NUMBER, EXP_DATE DATE DEFAULT SYSDATE, CASH NUMBER ); 17
  19. 19. /* creates the not null constraints to make sure each column contains data*/ Alter table RepairRecord Modify (amount_charged constraint repair_amount_charged_nn not null) Modify (mechanic_id constraint repair_mechanic_id_nn not null);/* These constraints make sure that particular repair service or services are performed. */Alter table RepairRecordAdd constraint repair_oil_change check (Oil_Change in (yes, no));Alter table RepairRecordAdd constraint repair_Battery_change check (Battery_change in (yes, no));Alter table RepairRecordAdd constraint repair_tire_change check (tire_change in (yes, no));Alter table RepairRecordAdd constraint repair_repair_service check (repair_services in (yes, no));/* Adds the foreign key constraint linking the repair record tables with the mechanic, car, and customer tables. */Alter table RepairRecordAdd constraint repair_mechanic_id_fk foreign key(Mechanic_ID) References "mechanic"(Mechanic_ID) ON DELETE CASCADE;Alter table RepairRecordAdd constraint repair_customer_id_fk foreign key(customer_ID) References "customer"(customer_ID) ON DELETE CASCADE; 18
  20. 20. Alter table RepairRecordAdd constraint repair_car_id_fk foreign key(car_ID) References "car"(car_id) ON DELETE CASCADE;/* Drop the column repair notes */Alter table RepairRecord DROP COLUMN Repair_Notes;/* Adds the repair_notes with character large objects to hold mechanic notes which may be text format with multiple sentences*/Alter table RepairRecordAdd repair_notes clob;/* Creates the sequence to create the repair_id values for the repair record table. I have to check to see if any sequence has been created using the samename with the drop statement. */Drop sequence repair_id_seq;CREATE SEQUENCE repair_id_seqstart with 2000increment by 0208nocycle; Deliverable 4 – DML (Data Manipulation Language) Insert Statements/*The following commands inserts data into table customer */ 19
  21. 21. insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Michael, Brown,Kevin, 5909 N.Paulina Apt 2b, chicago,IL,60660,3124562502,michael.kevin@bsn.edu);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Lioneal, jones,donel, 645 W.Sheridan Apt 4c, chicago,IL,60621,7734562508,lionel.jones@bcg.com);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Tyson, Bedford,Haywood, 645 E.lakeshore Apt 18g, chicago,IL,60632,3124092502,tyson.haywood@bcg.com);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Rosemary, liz,will, 14300 N.chicago rd Apt 22d, Evaston, IL,62450,8472308422,rose.wills@abc.org);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email) 20
  22. 22. values (customer_cust_id_seq.nextval, tyra, nancy,cdale, 809 W.highway drive, Niles, IL,64560,8475678907,trya.cdale@bbb.edu);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, trisha, barbra,steven, 456 N.maddison Apt 2b, chicago,IL,60660,3124562502,michael.kevin@bsn.edu);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, adia, brenda,ugonna, 85 lake drive , woodlawn, IL,62045,7734568230,adie.ugo@gwc.edu);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Lisle, mary,richard, 45 church drive Apt 22d, chicago,IL,60660,3128900897,Lisle@bsn.edu);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, Latifah, ShaTanya,msxwall, 40 washington drive Apt 52c, chicago,IL,60660,3128900897,Latifah@bsn.edu); 21
  23. 23. insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, susan, jenifer, Robert, 8181 ravenswood apt 40b , chicago, il, 602014, 7732898765,na);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, abel, aaron, adan, 90 west 95th street, evergreen park,IL, 623986, 000, na);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, alethia , debi, deborah, na, na,na, 000, 000, na);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, abel, aaron, adan, 90 west 95th street, evergreen park,IL, 623986, 000, na);insert into "customer"(customer_id, first_name, middle_name, last_name, address, city, cust_state, zip_code, phone_1, email)values (customer_cust_id_seq.nextval, McNile, jefferson, Winworth, 4101 saints blvd apt 34 c, chicago, il, 604523,6302309456,na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Nnneka, Okolo, young,345 citylane, riverdale, in, 46401, 00, na ); 22
  24. 24. insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, shu, chin, young,345 citylane, riverdale, in, 46401, 00, na );insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, ernest, jackson, young,345 citylane, riverdale, in, 46401, 00, na );insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Miksovsky, joe, peter,3409 jefferson place, riverdale, in, 46401, 00, na );insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval,Joshua, Randall, bill, na, na, na, 000, 000, na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Johnathan , Perrera, michaels, 9295 petterson ave apt 2c, west chicago, il,603421,7088472501,na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval,Kathryn, Wilson, white, na,na,na,000,000,na); 23
  25. 25. insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Keith, Harris, hammond, 23 west grove lane apt 4b, st john, in , 45903, 00, na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Joseph, Matthews, joci, 2534 cidder lane apt 9h, st john, in , 45903, 7088412020,jmathews@bcd.com);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Linda, Kobara,vicky, 3738 west akeshore, east chicago, in, 40923, 00, na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval,Eric , Miller, vendross, 89 wesr 87th place,hammond, in, 40432, 2195618184, na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Eric, lang, lee, 2240 mall drive, addison, il, 65209, 7089012457, na); 24
  26. 26. insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval,Salman, Mughal, cooper, 6542 west state line apt 4g,gary, IN, 42409, 2194245678,na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval,Paul, Born, sheridan, 8922 clark street,university park, IL, 60342, 8154243456,na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, city, cust_state, zip_code, phone_1, email) values (customer_cust_id_seq.nextval, Richard, Lum, benson, 908 court drive apt 3, east chicago, in, 42029,2190986785,na);insert into "customer"(customer_id, first_name, last_name, middle_name, address, address_2, city, cust_state, zip_code, phone_1,email) values (customer_cust_id_seq.nextval,Tim ,O-Brien, Ted, 9428 stevenson highway, apt 405d, blueisland, il, 602198,70809820145,na);/*insets data into agent table*/insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) 25
  27. 27. values (agent_agent_id_seq.nextval, celin, whitney, Doveward, 870 jackson street,Gary, IN,46401,2195612505,celin@lakeshore.com);insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) values (agent_agent_id_seq.nextval, dOlly, diane, chris, 560 maddison drive, gary, IN,46401, 2198674560,dollyc@lakeshore.com);insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) values (agent_agent_id_seq.nextval, chris, jordan,paul, 78 state drive, riverdale,IL, 605678,7089097896,chrisjord@lakeshore.com);insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) values (agent_agent_id_seq.nextval, melisa, lisa, henwood, 560 lakeshore drive apt 3, east chicago, in, 46404,2198092436, meliisa@lakeshore.com);insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) values (agent_agent_id_seq.nextval, chioce, nelly, westt, 89 S.78th street, East chicaago, IN,46409,2198890987, NA)insert into "agent"(agent_id, first_name, middle_name, last_name, address, city, agent_state, zip_code, phone, email) 26
  28. 28. values (agent_agent_id_seq.nextval, maryanne, linda, stephine, 89 churchhill ,lake, in, 46408, 00000, na);/* inserts data into reservations*/Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, TO_DATE(31-Jan-2011,DD-MON-YYYY),1500,service,oil change, (select customer_id from "customer" where customer_id = 90490 ) );Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id, notes)values (reservation_request_id_seq.nextval, TO_DATE(31-jan-2011,DD-MON-YYYY),1500,service,battery change, (select customer_id from "customer" where customer_id = 90530 ), My car has not be starting well. It ptoduce a Squish sound each time. );Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 0935, service,tire change, (select customer_id from "customer" where customer_id = 90570)); 27
  29. 29. Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 0930, service,tire change, (select customer_id from "customer" where customer_id = 90610));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id, notes)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 1045, service,oil change, (select customer_id from "customer" where customer_id = 90650), i had been having problem with the two front tires);Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY),1125,service,battery change, (select customer_id from "customer" where customer_id = 90690));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY),1125,service,repair, (select customer_id from "customer" where customer_id = 90650)); Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY),1125,service,repair, 28
  30. 30. (select customer_id from "customer" where customer_id = 90730)); Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY),1125,service,repair, (select customer_id from "customer" where customer_id = 90770)); Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 0945, car sale,(select customer_id from "customer" where customer_id = 90810 ));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 0900, car sale,(select customer_id from "customer" where customer_id = 91010 ));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(31-jan-2011, DD-MON-YYYY), 1045, car sale,(select customer_id from "customer" where customer_id = 91130 )); 29
  31. 31. Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011,DD-MON-YYYY), 1025, car loan,(select customer_id from "customer" where customer_id = 91210 ));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011,DD-MON-YYYY), 1345,car loan,(select customer_id from "customer" where customer_id = 91250 ));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY),1200,service,repair,(select customer_id from "customer" where customer_id = 90090));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1345, service,oil change,(select customer_id from "customer" where customer_id = 90090 ));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id) 30
  32. 32. values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1405, service,oil change,(select customer_id from "customer" where customer_id = 90170 ));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1120, car sale,(select customer_id from "customer" where customer_id = 90170 )); Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1045,car sale,(select customer_id from "customer" where customer_id = 90410 )); Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(01-feb-2011, DD-MON-YYYY), 1505, service, repair,(select customer_id from "customer" where customer_id = 91090 )); 31
  33. 33. Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 1520, car browsing,(select customer_id from "customer" where customer_id = 90810 )); Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 1100, car browsing,(select customer_id from "customer" where customer_id = 90890 ));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 0935, service,repair, (select customer_id from "customer" where customer_id = 90570));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id, notes)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 0930, service,repair, (select customer_id from "customer" where customer_id = 90770), I had a car accident with a truck on my way to work);Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id) 32
  34. 34. values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 1045, service,repair, (select customer_id from "customer" where customer_id = 90650));Insert into "reservations"(request_id, request_date, request_time,request_type,service_option,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY),1125,service,battery change, (select customer_id from "customer" where customer_id = 91130));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 0945, car sale,(select customer_id from "customer" where customer_id = 91170 ));Insert into "reservations"(request_id, request_date, request_time,request_type,customer_id)values (reservation_request_id_seq.nextval, To_Date(02-feb_2011, DD-MON-YYYY), 0900, car sale,(select customer_id from "customer" where customer_id = 90970 ));/* insert data into car */Insert into "car" (car_id, brand_name, model, year_made, maker) 33
  35. 35. values (car_car_id_seq.nextval, ford focus, 2008, 2007, ford); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, ford focus, 2009, 2007, ford); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, ford focus, 2010, 2007, ford); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, ford focus, 2008, 2007, ford);Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2005, 2004, toyota); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2004, 2004, toyota);Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2003, 2004, toyota); 34
  36. 36. Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2002, 2004, toyota);Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, camry, 2011, 2004, toyota);Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval , Accord Coupe,2011, 2010, Honda); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, Accord sedan, 2011, 2010, Honda); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, civic hybrod, 2011 ,2010, honda);Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, civic hybrod, 2010 ,2009, honda); 35
  37. 37. Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, Fit, 2011, 2010, honda); Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, santa fe, 2011, 2010, hyndai); Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, santa fe, 2010, 2009, hyndai); Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, santa fe, 2009, 2008, hyndai); Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, Tucson, 2011, 2010, honda); Insert into "car" (car_id, brand_name, model, year_made, maker)values (car_car_id_seq.nextval, Tucson, 2010, 2009, hyndai); Insert into "car" (car_id, brand_name, model, year_made, maker) 36
  38. 38. values (car_car_id_seq.nextval, Genesis, 2010, 2009, hyndai); Insert into "car" (car_id, brand_name, model, year_made, maker) values (car_car_id_seq.nextval, Genesis, 2011, 2010, hyndai);/* insert data into mechanic table */insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, Johnnattan, Winewood, Bryon, 6308977465, 5261 County Blvd,West Chicago, IL,60426);insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, Johnson, Mark, Luther, 8158979465, 4235 Justice Blvd Apt 2b,homewood, IL,60345); insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, Greg, Cliffton, Luther, 8152306824, 4235 Justice Blvd Apt 2b,homewood, IL,60345); 37
  39. 39. insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, Drew, thomas, Luther, 8152306824, 4235 Justice Blvd Apt 2b,homewood, IL,60345); insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, Hendron, washington, D.Mario, 7734123456, 6503 Chicago Rd ,doltin, IL, 60145);insert into "mechanic"(mechanic_id, first_name, middle_name, last_name, phone, address, city, mechanic_state, zip_code)values(meach_meachinic_id_seq.nextval, justice, brown, mario, 8476899876, 606 highway 23 apt3c ,doltin, IL, 60145);/* insert data into repair record */Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2048), 90610 ,55000,no, no,yes, 69.99, 69.99); 38
  40. 40. Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2046),90570,55000,no, no,yes, 69.99, 69.99);Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2036), 90650,45000,yes, no,no, 70.99, 70.99);Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change, 39
  41. 41. Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7120), (select car_id from "car" where car_id =2040), 90690 ,45000,no, no,no, yes, 90.99, 90.99); Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7120), (select car_id from "car" where car_id =2066),90530 ,45000,no, no,no, yes, 90.99, 90.99);Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes, mechanic_notes) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), 40
  42. 42. ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2058),90730,35000,yes, no,no, no, 290.99, 90.99, fixed the transmission system and the right window frame, right door main frame had to be repaced);Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes, mechanic_notes) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7120), (select car_id from "car" where car_id =2044),90770,35000,yes, no,no, no, 190.99, 90.99, fixed the oil tank, discoverd a hole during inspection.showed it to customer agreed for change); Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes, mechanic_notes) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2070),90650,55000,yes, no,no, no, 41
  43. 43. 290.99, 90.99, fixed the front bumper, repair both front and back bumpers due to car accident); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(31-jan-2011, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7000), (select car_id from "car" where car_id =2036), 90490,45000,yes, no,no, 70.99, 70.99); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(01-FEB-11 , dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7030), (select car_id from "car" where car_id =2066), 90410 ,45000,yes, no,no, 70.99, 70.99); 42
  44. 44. Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(01-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7030), (select car_id from "car" where car_id =2042),91050 ,45000,yes, no,no, 70.99, 70.99); Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes, mechanic_notes) values (repair_id_seq.nextval, to_date(01-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7030), (select car_id from "car" where car_id =2068),90090,5000,no, yes,no, no, 40.99, 40.99, fixed the cup holder, the holder won’t close); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes, mechanic_notes) 43
  45. 45. values (repair_id_seq.nextval, to_date(01-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7030), (select car_id from "car" where car_id =2070),91250,15000,no, yes,no, no, 110.99, 110.99, fixed the driver passanger chair, the chair wont move forward); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(02-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7090), (select car_id from "car" where car_id =2074),90570,5000,no, yes,no, no, 100.99, 100.99, installed new tv set); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(02-FEB-11, dd-mon-yyyy), 44
  46. 46. ( Select mechanic_id from "mechanic" where mechanic_id = 7120), (select car_id from "car" where car_id =2038), 90770,55000,no, yes,no, no, 490.99, 490.99, body paint); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(02-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2066), 90650,5000,no, yes,no, no,209, 209.99, air system replaced); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash) values (repair_id_seq.nextval, to_date(02-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2066), 91130,5000,no, no,no, yes, 45
  47. 47. 50, 50); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(03-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2048), 90330,5000,no, yes,no, no,60, 60, replace the front lights); Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(03-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2074), 91010,2000,no, yes,no, no,60, 60, replace the break lights); 46
  48. 48. Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(03-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2074),91210,2000,no, no,no, yes,50, 50, na); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(03-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2036 ), 90770,89000,no, yes,no, no,50, 50, fixed the horn system); Insert into RepairRecord(repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) 47
  49. 49. values (repair_id_seq.nextval, to_date(04-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2056 ), 90450,1000,no, yes,no, no,150, 150, fixed the break system);Insert into RepairRecord (repair_id, repair_date, mechanic_id, car_id, customer_id, mileage,oil_change,repair_services,tire_change,battery_change,Amount_charged, cash, repair_notes) values (repair_id_seq.nextval, to_date(04-FEB-11, dd-mon-yyyy), ( Select mechanic_id from "mechanic" where mechanic_id = 7150), (select car_id from "car" where car_id = 2056 ), 90970,2000,no, no,yes, no, 80, 80, na);/* insert data into the car sales. */insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT , customer_id) values (carsales_trans_id_seq.nextval, 8079, 48
  50. 50. (select car_id from "car" where car_id = 2012),to_date (31-jan-2011, dd-mon-yyyy), 19000, 0,19000,0, 90810); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8158), (select car_id from "car" wherecar_id = 2022), to_date (31-jan-2011, dd-mon-yyyy), 0, 20890,0 ,20890, 12, 24, 91010); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8079), (select car_id from "car" wherecar_id = 2030), to_date (31-jan-2011, dd-mon-yyyy), 14000, 6500, 14000 ,6500, 12, 12, 91130);insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8316), (select car_id from "car" wherecar_id = 2006), to_date (01-FEB-11, dd-mon-yyyy), 49
  51. 51. 14000, 0, 14000 ,0, 0, 0, 91170 ); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8316), (select car_id from "car" wherecar_id = 2034), to_date (01-FEB-11, dd-mon-yyyy), 12000, 0, 12000 ,0, 0, 0, 91250);insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8237), (select car_id from "car" wherecar_id = 2040), to_date (02-FEB-11, dd-mon-yyyy), 10000, 0, 10000 ,0, 0, 0, 91250); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8316), (select car_id from "car" wherecar_id = 2032), to_date (02-FEB-11, dd-mon-yyyy), 0, 21000, 0 ,21000, 12, 38, 91170); 50
  52. 52. insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8000), (select car_id from "car" wherecar_id = 2010), to_date (03-FEB-11, dd-mon-yyyy), 0, 21890, 0 ,21890, 12, 38, 90970); insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8158), (select car_id from "car" wherecar_id = 2002), to_date (03-FEB-11, dd-mon-yyyy), 0, 21890, 0 ,21890, 12, 38, 90890);insert into CarSales ( transaction_id, agent_id, car_id, sales_date, amount_paid_check, amount_paid_loan, total_paid,REMANING_AMOUNT, payment_plan, number_months , customer_id) values (carsales_trans_id_seq.nextval, (select agent_id from "agent" where agent_id = 8158), (select car_id from "car" wherecar_id = 2028 ), to_date (04-FEB-11, dd-mon-yyyy), 0, 21890, 0 ,21890, 12, 38, 91010); 51
  53. 53. Reports./* manager wants to know which clients came in for car loan or car browsing*/select customer_id, to_char(request_date , dd-mon-yyyy) as Request_Date, request_time, initcap(request_type) as Request_Typefrom "reservations" where request_type =car loan or request_type =car browsing; CUSTOMER_ID REQUEST_DATE REQUEST_TIME REQUEST_TYPE 91210 1-Feb-11 1025 Car Loan 91250 1-Feb-11 1345 Car Loan 90810 2-Feb-11 1520 Car Browsing 90890 2-Feb-11 1100 Car Browsing 52
  54. 54. /*Manager wants to know which clients came in for car sale*/select customer_id, to_char(request_date) as Request__Date, request_time, initcap(request_type) as Request_Type from"reservations" where request_type =car sale ; CUSTOMER_ID REQUEST__DATE REQUEST_TIM REQUEST_TYPE 90810 31-Jan-11 945 Car Sale 91010 31-Jan-11 900 Car Sale 91130 31-Jan-11 1045 Car Sale 90170 1-Feb-11 1120 Car Sale 90410 1-Feb-11 1045 Car Sale 91170 2-Feb-11 945 Car Sale 90970 2-Feb-11 900 Car Sale 53
  55. 55. /*manager wants to know which client received which service for service option */ 54
  56. 56. CUSTOMER_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION90570 31-Jan-11 935 Tire Change /90530 31-Jan-11 1500 Battery Change90650 31-Jan-11 1045 Oil Change90690 31-Jan-11 1125 Battery Change90650 31-Jan-11 1125 Repair90730 31-Jan-11 1125 Repair90770 31-Jan-11 1125 Repair90610 31-Jan-11 930 Tire Change90490 31-Jan-11 1500 Oil Change90170 1-Feb-11 1405 Oil Change91090 1-Feb-11 1505 Repair90090 1-Feb-11 1345 Oil Change90090 1-Feb-11 1200 Repair90570 2-Feb-11 935 Repair90770 2-Feb-11 930 Repair90650 2-Feb-11 1045 Repair91130 2-Feb-11 1125 Battery Change 55
  57. 57. /*Manger wants to know which clients don’t have any phone number listed */select initcap (first_name)||,||initcap(last_name) as Client_Name, customer_id, phone_1 from "customer" where phone_1 = 0; CLIENT_NAME CUSTOMER_ID PHONE_1 Abel,Adan 90490 0 Alethia,Deborah 90530 0 Abel,Adan 90570 0 Nnneka,Okolo 90650 0 Shu,Chin 90690 0 Ernest,Jackson 90730 0 Miksovsky,Joe 90770 0 Joshua,Randall 90810 0 Kathryn,Wilson 90890 0 Keith,Harris 90930 0 Linda,Kobara 91010 0/* updates the phone to have a value */update "customer"set phone_1 = 31234590904where customer_id = 90890; 56
  58. 58. update "customer"set Phone_1 = 2192248902where customer_id = 90930;update "customer"set Phone_1 = 8159091450where customer_id = 91130;update "customer"set Phone_1 = 6304408903where customer_id = 91170;update "customer"set Phone_1 = 8154408903where customer_id = 91210;update "customer"set Phone_1 = 7737338470where customer_id = 91250;update "customer"set Phone_1 = 7097338470where customer_id = 91290;update "customer"set Phone_1 = 31293484567where customer_id = 91330; 57
  59. 59. update "customer"set Phone_1 = 31989081234where customer_id = 91410;update "customer"set Phone_1 = 2198800903select customer_id, city, address, cust_state, phone_1 from "customer" where phone_1 = 0;no rows selected/* manager wants to update clients with missing contacts */select customer_id, city, address, cust_state from "customer" where address = na;CUSTOMER_ID CITY ADDRESS CUST_STATE90530 na na na90810 na na na90890 na na na/* update the customer table to fill in the missing values*/ 58
  60. 60. update "customer"set city =indiana citywhere customer_id = 90530;update "customer"set address = 9090 michigan avewhere customer_id = 90530;update "customer"set cust_state = INwhere customer_id = 90530;UPDATE "customer"set zip_code=41909where customer_id = 90530;update "customer"set city =indiana citywhere customer_id = 90810;update "customer"set address = 401 ceder lake blv apt 23where customer_id = 90810;update "customer"set cust_state = INwhere customer_id = 90810;UPDATE "customer" 59
  61. 61. set zip_code=41909where customer_id = 90810;update "customer"set city =indiana citywhere customer_id =90890;update "customer"set address = 401 ceder lake nw blvdwhere customer_id = 90890;update "customer"set cust_state = INwhere customer_id = 90890;UPDATE "customer"set zip_code=41909where customer_id = 90890;select customer_id, city, address, cust_state from "customer" where address = na;no rows selected/* Manager wants to determine which customer had their cars repaired */select c.customer_id, r.mechanic_id ,r.repair_date, r.repair_notes from "customer" c inner join "repair record" r on c.customer_id = r.customer_id ; 60
  62. 62. CUSTOMER_ID MECHANIC_ID REPAIR_DATE REPAIR_NOTES90650 7000 31-Jan-1190690 7120 31-Jan-1190530 7120 31-Jan-1190730 7000 31-Jan-11 Fixed The Transmission System And The Right Window Frame90770 7120 31-Jan-11 Fixed The Oil Tank90650 7000 31-Jan-11 Fixed The Front Bumper90490 7000 31-Jan-1190410 7030 1-Feb-1191050 7030 1-Feb-1190090 7030 1-Feb-11 Fixed The Cup Holder91250 7030 1-Feb-11 Fixed The Driver Passanger Chair90570 7090 2-Feb-11 Installed New Tv Set90770 7120 2-Feb-11 Body Paint90650 7150 2-Feb-11 Air System Replaced91130 7150 2-Feb-1190330 7150 3-Feb-11 Replace The Front Lights91010 7150 3-Feb-11 Replace The Break Lights91210 7150 3-Feb-11 Na90770 7150 3-Feb-11 Fixed The Horn System90450 7150 4-Feb-11 Fixed The Break System90970 7150 4-Feb-11 Na90610 7000 31-Jan-1190570 7000 31-Jan-11 61
  63. 63. /* Manager wants to know the name of clients who made request */ select c.customer_id, first_name||,|| last_name as client, v.request_date, v.request_type, v.service_option from "customer" c inner join "reservations" v on c.customer_id = v.customer_id where v.request_type = car sale;CUSTOMER_ID CLIENT REQUEST_DATE REQUEST_TYPE SERVICE_OPTION90810 Joshua,Randall 31-Jan-11 car sale91010 Linda,Kobara 31-Jan-11 car sale91130 Salman,Mughal 31-Jan-11 car sale90170 Tyson,Haywood 1-Feb-11 car sale90410 Latifah,msxwall 1-Feb-11 car sale91170 Paul,Born 2-Feb-11 car sale90970 Joseph,Matthews 2-Feb-11 car sale /* manager wants to know which mechanic fixed which car including the model*/ 62
  64. 64. select m.mechanic_id, m.first_name||,||m.last_name as Mechnaic, c.model, c.car_Id, r.repair_id from "mechanic" m inner join"repair record" r on m.mechanic_id = r.mechanic_id inner join "car" c on c.car_id = r.car_id;MECHANIC_ID MECHNAIC CAR_MODEL CAR_ID REPAIR_ID7000 Johnnattan,Bryon 2010 2036 24167120 Hendron,D.Mario 2011 2040 26247000 Johnnattan,Bryon 2010 2036 36647120 Hendron,D.Mario 2010 2038 49127150 Justice,Mario 2010 2036 6160/* Manager wants to know the cost of each repair services*/select m.first_name as Mechnaic, c.model, c.car_Id, r.repair_id, to_char( r.amount_charged,$999,999.99) as Charge_Amount,to_char(r.CASH, $9999,999.99) as Cash from "mechanic" m inner join repairrecord r on m.mechanic_id = r.mechanic_id innerjoin "car" c on c.car_id = r.car_id;MECHNAIC MODEL CAR_ID REPAIR_ID CHARGE_AMOUNT CASHJohnnattan 2010 2036 2416 $70.99 $70.99Hendron 2011 2040 2624 $90.99 $90.99Johnnattan 2010 2036 3664 $70.99 $70.99Hendron 2010 2038 4912 $490.99 $490.99 63
  65. 65. justice 2010 2036 6160 $50.00 $50.00/* Manager wants to know the total cost of repair service*/select to_char(sum(amount_charged), $999,999.99)as Repair_Total from repairrecord;REPAIR_TOTAL------------$2,831.85/* Manager wants to know total repair cost daily *. To get the right first query the database for repair date/select repair_id, repair_date, to_char(amount_charged,$9999,999.99) as Amount_charged, to_char(cash, $9999,999.99) as Cash,sum( cash )over( partition by repair_date) as Repair_Toatl_Amount_dailyfrom repairrecordREPAIR_ID REPAIR_DATE AMOUNT_CHARGED CASH REPAIR_TOATL_AMOUNT_DAILY4496 1-Feb-11 $110.99 $110.99 293.964288 1-Feb-11 $40.99 $40.99 293.964080 1-Feb-11 $70.99 $70.99 293.96 64
  66. 66. 3872 1-Feb-11 $70.99 $70.99 293.964912 2-Feb-11 $490.99 $490.99 851.974704 2-Feb-11 $100.99 $100.99 851.975120 2-Feb-11 $209.00 $209.99 851.975328 2-Feb-11 $50.00 $50.00 851.975744 3-Feb-11 $60.00 $60.00 2205952 3-Feb-11 $50.00 $50.00 2206160 3-Feb-11 $50.00 $50.00 2205536 3-Feb-11 $60.00 $60.00 2206576 4-Feb-11 $80.00 $80.00 2306368 4-Feb-11 $150.00 $150.00 2302000 31-Jan-11 $69.99 $69.99 736.913664 31-Jan-11 $70.99 $70.99 736.913456 31-Jan-11 $290.99 $90.99 736.913248 31-Jan-11 $190.99 $90.99 736.913040 31-Jan-11 $290.99 $90.99 736.912832 31-Jan-11 $90.99 $90.99 736.912208 31-Jan-11 $69.99 $69.99 736.912416 31-Jan-11 $70.99 $70.99 736.912624 31-Jan-11 $90.99 $90.99 736.91 65
  67. 67. /* Manager want to know the amount paid total by check without renaming balance*/select to_char(sum(amount_paid_check), $999,999.99)as Check_total from CarSales where remaning_amount = 0;CHECK_TOTAL------------ $55,000.00/* Manager want to know the amount paid total by loan without renaming balance*/select to_char(sum(amount_paid_loan), $999,999.99)as Loan_total from CarSales where remaning_amount = 0;LOAN_TOTAL------------ $0.00/* Manager want to know the amount paid total by loan*/select to_char(sum(amount_paid_loan), $999,999.99)as Loan_total from CarSales ;LOAN_TOTAL 66
  68. 68. ------------ $114,060.00/* Manager want to know which agent sold a car */ select a.agent_id,a.car_id, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,||b.last_name) as agent from CarSales a inner join "car" c on a.car_id = c.car_id inner join "agent" b on b.agent_id = a.agent_id order by maker;AGENT_ID CAR_ID MODEL MAKER AGENT8316 2006 2008 Ford Maryanne,Stephine8158 2002 2009 Ford Chris,Paul8158 2022 2011 Honda Chris,Paul8316 2034 2011 Honda Maryanne,Stephine8158 2028 2011 Hyndai Chris,Paul8237 2040 2011 Hyndai Melisa,Henwood8316 2032 2009 Hyndai Maryanne,Stephine8079 2030 2010 Hyndai Dolly,Chris8000 2010 2004 Toyota Celin,Doveward8079 2012 2003 Toyota Dolly,Chris/*Manager wants to include transaction id and sales date to the previous report*/ 67
  69. 69. select a.agent_id,a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,||b.last_name) as agent from CarSales a inner join "car" c on a.car_id = c.car_id inner join "agent" b on b.agent_id = a.agent_id order by maker;AGENT_ID CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER AGENT8316 2006 900266 1-Feb-11 2008 Ford Maryanne,Stephine8158 2002 900711 3-Feb-11 2009 Ford Chris,Paul8158 2022 900088 31-Jan-11 2011 Honda Chris,Paul8316 2034 900355 1-Feb-11 2011 Honda Maryanne,Stephine8158 2028 900800 4-Feb-11 2011 Hyndai Chris,Paul8237 2040 900444 2-Feb-11 2011 Hyndai Melisa,Henwood8316 2032 900533 2-Feb-11 2009 Hyndai Maryanne,Stephine8079 2030 900177 31-Jan-11 2010 Hyndai Dolly,Chris8000 2010 900622 3-Feb-11 2004 Toyota Celin,Doveward8079 2012 899999 31-Jan-11 2003 Toyota Dolly,Chris* Manager wants to create table to hold the previous report for easy access*create table "report" asselect a.agent_id,a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,||b.last_name) as agent 68
  70. 70. from CarSales a inner join "car" c on a.car_id = c.car_id inner join "agent" b on b.agent_id = a.agent_id order by maker;select * from "report";AGENT_ID CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER AGENT8316 2006 900266 1-Feb-11 2008 Ford Maryanne,Stephine8158 2002 900711 3-Feb-11 2009 Ford Chris,Paul8158 2022 900088 31-Jan-11 2011 Honda Chris,Paul8316 2034 900355 1-Feb-11 2011 Honda Maryanne,Stephine8158 2028 900800 4-Feb-11 2011 Hyndai Chris,Paul8237 2040 900444 2-Feb-11 2011 Hyndai Melisa,Henwood8316 2032 900533 2-Feb-11 2009 Hyndai Maryanne,Stephine8079 2030 900177 31-Jan-11 2010 Hyndai Dolly,Chris8000 2010 900622 3-Feb-11 2004 Toyota Celin,Doveward8079 2012 899999 31-Jan-11 2003 Toyota Dolly,Chris/* Manager wants to know which of their clients from East Chicago and BlueIsland who bought a car to mail them specialdiscounts*/select b.customer_id, INITCAP(b.city) AS CITY,a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,||b.last_name) as Customer from "customer" b inner join carsales a on b.customer_id = a.customer_id inner join "car" c 69
  71. 71. on a.car_id = c.car_id where city =blueisland or city = East ChicagoCUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER91010 East Chicago 2022 900088 31-Jan-11 2011 Honda Linda,Kobara91250 Blueisland 2034 900355 1-Feb-11 2011 Honda Tim ,O-Brien91250 Blueisland 2040 900444 2-Feb-11 2011 Hyndai Tim ,O-Brien91010 East Chicago 2028 900800 4-Feb-11 2011 Hyndai Linda,Kobara /* Manager wants to know which of their clients from IL who bought a car to give them a call for discounts*/ select b.customer_id, INITCAP(b.city) AS CITY, a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,|| b.last_name) as Customer from "customer" b inner join carsales a on b.customer_id = a.customer_id inner join "car" c on 70
  72. 72. a.car_id = c.car_id where CUST_STATE in (‘IL’, ‘il’,’Il’)CUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER91170 University 2006 900266 1-Feb-11 2008 Ford Paul,Born Park91170 University 2032 900533 2-Feb-11 2009 Hyndai Paul,Born Park91250 Blueisland 2034 900355 1-Feb-11 2011 Honda Tim ,O-Brien91250 Blueisland 2040 900444 2-Feb-11 2011 Hyndai Tim ,O-Brien /* Manager wants to know which of their clients from IN who bought a car to give them a call for discounts*/ select b.customer_id, INITCAP(b.city) AS CITY, a.car_id, a.transaction_id, a.sales_date, c.model, initcap (c.maker) as Maker, initcap (b.first_name||,|| b.last_name) as Customer from "customer" b inner join carsales a on b.customer_id = a.customer_id inner join "car" c on 71
  73. 73. a.car_id = c.car_id where CUST_STATE in (IN, in, In);CUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER90890 Indiana City 2002 900711 3-Feb-11 2009 Ford Kathryn,Wilson90970 St John 2010 900622 3-Feb-11 2004 Toyota Joseph,Matthews90810 Indiana City 2012 899999 31-Jan-11 2003 Toyota Joshua,Randall91010 East Chicago 2022 900088 31-Jan-11 2011 Honda Linda,Kobara91010 East Chicago 2028 900800 4-Feb-11 2011 Hyndai Linda,Kobara91130 Gary 2030 900177 31-Jan-11 2010 Hyndai Salman,Mughal /* Manager wants to know how many reservations has been made*/ select request_id , request_date, request_time, service_option from "reservations" where exists(select customer_id, first_name from "customer") 72
  74. 74. REQUEST_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION790177 31-Jan-11 935 tire change790266 31-Jan-11 930 tire change790355 31-Jan-11 1045 oil change790444 31-Jan-11 1125 battery change790533 31-Jan-11 1125 repair790622 31-Jan-11 1125 repair790711 31-Jan-11 1125 repair790800 31-Jan-11 945790889 31-Jan-11 900790978 31-Jan-11 1045791067 1-Feb-11 1025791156 1-Feb-11 1345791245 1-Feb-11 1200 repair791334 1-Feb-11 1345 oil change791423 1-Feb-11 1405 oil change791512 1-Feb-11 1120791601 1-Feb-11 1045791690 1-Feb-11 1505 repair791779 2-Feb-11 1520791868 2-Feb-11 1100791957 2-Feb-11 935 repair792046 2-Feb-11 930 repair 73
  75. 75. 792135 2-Feb-11 1045 repair792224 2-Feb-11 1125 battery change792313 2-Feb-11 945792402 2-Feb-11 900789999 31-Jan-11 1500 oil change790088 31-Jan-11 1500 battery change28 rowsselected 74

×