SlideShare una empresa de Scribd logo
1 de 75
Lakeshore Auto Database System Project
                         Sunny Okoro
                          DBST651, Spring 2011




                 Graduate School
    University of Maryland University College
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 ..................................................................................................................................................................................................................19
Reports. .....................................................................................................................................................................................................................................52




                                                                                                                                                                                                                                                   1
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 of

cars 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 entered

into 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 appointment

for 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 by

managers to produce monthly and weekly statistical reports.


Diagram Tool

Oracle SQL Developer Data Molder

Database

Oracle 11g


                                                                                                                                                            2
Composition Software

Notepad +++ for writing and editing SQL commands



Hardware and Software
Microsoft Windows 7 Professional x64



DDL, TCL and DML


Oracle SQL would be used for the Data Definition, Data Manipulation and Transaction Control languages of to build the database. I would also use
Database objects including constraints, views, index and sequences to generate unique values for Primary Key.




                                                               Deliverable 2 – ERD




                                                                                                                                                   3
4
ERD Description


Customer Table

A 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 Table

A Car sale must be associated with one agent

One or more car sales must be associated with a car

Agent Table

An agent must be associated with one or more car sales

Mechanic Table

A mechanic must be associated with one or more repair record(s)

Reservations Table

One or more reservations must be associated to a customer.

Car Table

A car must be associated with one or more car sale(s)


                                                                  5
Repair Record

A 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 to
use 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
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_seq
Start with 090090
Increment by 40
nocycle;

/*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
/* 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 same
name.*/


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 created
before.*/

Drop sequence agent_agent_id_seq;

CREATE SEQUENCE agent_agent_id_seq
start with 008000
increment by 079
nocycle;

/* Adds the not null constraint to make sure each column has a value specified by upon input.*/



                                                                                                                                                          8
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
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 the
drop statement.*/

Drop sequence car_car_id_seq;

CREATE SEQUENCE car_car_id_seq
start with 2000
increment by 02
nocycle;


                                                            ***** 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
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_seq
start with 0899999
increment by 089
nocycle;


/*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
Alter table CarSales
modify (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 CarSales
Add constraint csale_agent_id_fk foreign key(agent_id)
 references "agent"(agent_id)on delete cascade;

Alter table CarSales
Add 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
***** 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
/*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 been
created before.*/

Drop sequence reservation_request_id_seq;

CREATE SEQUENCE reservation_request_id_seq
start with 0789999
increment by 089
nocycle;


/*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
/*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
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 created
before.*/

Drop sequence meach_meachinic_id_seq;

CREATE SEQUENCE meach_meachinic_id_seq
start with 007000
increment by 030
nocycle;


/*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
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
/* 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 RepairRecord
Add constraint repair_oil_change check (Oil_Change in ('yes', 'no'));

Alter table RepairRecord
Add constraint repair_Battery_change check (Battery_change in ('yes', 'no'));

Alter table RepairRecord
Add constraint repair_tire_change check (tire_change in ('yes', 'no'));

Alter table RepairRecord
Add 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 RepairRecord
Add constraint repair_mechanic_id_fk foreign key(Mechanic_ID)
   References "mechanic"(Mechanic_ID) ON DELETE CASCADE;

Alter table RepairRecord
Add constraint repair_customer_id_fk foreign key(customer_ID)
   References "customer"(customer_ID) ON DELETE CASCADE;



                                                                                                                      18
Alter table RepairRecord
Add 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 RepairRecord
Add 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 same
name with the drop statement. */

Drop sequence repair_id_seq;

CREATE SEQUENCE repair_id_seq
start with 2000
increment by 0208
nocycle;



                                              Deliverable 4 – DML (Data Manipulation Language)

                                                                   Insert Statements


/*The following commands inserts data into table customer */


                                                                                                                                                             19
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
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
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
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
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
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
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
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
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
(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
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
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
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
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
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
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
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
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
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
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
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
( 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
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
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
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
( 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
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
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
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
(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" where
car_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" where
car_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" where
car_id = 2006), to_date ('01-FEB-11', 'dd-mon-yyyy'),


                                                                                                                                    49
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" where
car_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" where
car_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" where
car_id = 2032), to_date ('02-FEB-11', 'dd-mon-yyyy'),
             0, 21000, 0 ,21000, 12, 38, 91170);


                                                                                                                                    50
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" where
car_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" where
car_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" where
car_id = 2028 ), to_date ('04-FEB-11', 'dd-mon-yyyy'),
              0, 21890, 0 ,21890, 12, 38, 91010);




                                                                                                                                    51
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_Type
from "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
/*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
/*manager wants to know which client received which service for service option */




                                                                                    54
CUSTOMER_ID   REQUEST_DATE   REQUEST_TIME   SERVICE_OPTION
90570         31-Jan-11      935            Tire Change
                                                             /
90530         31-Jan-11      1500           Battery Change
90650         31-Jan-11      1045           Oil Change
90690         31-Jan-11      1125           Battery Change
90650         31-Jan-11      1125           Repair
90730         31-Jan-11      1125           Repair
90770         31-Jan-11      1125           Repair
90610         31-Jan-11      930            Tire Change
90490         31-Jan-11      1500           Oil Change
90170         1-Feb-11       1405           Oil Change
91090         1-Feb-11       1505           Repair
90090         1-Feb-11       1345           Oil Change
90090         1-Feb-11       1200           Repair
90570         2-Feb-11       935            Repair
90770         2-Feb-11       930            Repair
90650         2-Feb-11       1045           Repair
91130         2-Feb-11       1125           Battery Change




                                                                 55
/*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 = 31234590904
where customer_id = 90890;



                                                                                                                               56
update "customer"
set Phone_1 = 2192248902
where customer_id = 90930;


update "customer"
set Phone_1 = 8159091450
where customer_id = 91130;

update "customer"
set Phone_1 = 6304408903
where customer_id = 91170;

update "customer"
set Phone_1 = 8154408903
where customer_id = 91210;

update "customer"
set Phone_1 = 7737338470
where customer_id = 91250;

update "customer"
set Phone_1 = 7097338470
where customer_id = 91290;

update "customer"
set Phone_1 = 31293484567
where customer_id = 91330;


                             57
update "customer"
set Phone_1 = 31989081234
where customer_id = 91410;


update "customer"
set Phone_1 = 2198800903

select 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_STATE
90530                  na              na            na
90810                  na              na            na
90890                  na              na            na


/* update the customer table to fill in the missing values*/


                                                                                            58
update "customer"
set city ='indiana city'
where customer_id = 90530;

update "customer"
set address = '9090 michigan ave'
where customer_id = 90530;

update "customer"
set cust_state = 'IN'
where customer_id = 90530;

UPDATE "customer"
set zip_code=41909
where customer_id = 90530;

update "customer"
set city ='indiana city'
where customer_id = 90810;

update "customer"
set address = '401 ceder lake blv apt 23'
where customer_id = 90810;

update "customer"
set cust_state = 'IN'
where customer_id = 90810;

UPDATE "customer"

                                            59
set zip_code=41909
where customer_id = 90810;


update "customer"
set city ='indiana city'
where customer_id =90890;

update "customer"
set address = '401 ceder lake nw blvd'
where customer_id = 90890;

update "customer"
set cust_state = 'IN'
where customer_id = 90890;

UPDATE "customer"
set zip_code=41909
where 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
CUSTOMER_ID   MECHANIC_ID   REPAIR_DATE   REPAIR_NOTES
90650         7000          31-Jan-11
90690         7120          31-Jan-11
90530         7120          31-Jan-11
90730         7000          31-Jan-11     Fixed The Transmission System And The Right Window Frame
90770         7120          31-Jan-11     Fixed The Oil Tank
90650         7000          31-Jan-11     Fixed The Front Bumper
90490         7000          31-Jan-11
90410         7030          1-Feb-11
91050         7030          1-Feb-11
90090         7030          1-Feb-11      Fixed The Cup Holder
91250         7030          1-Feb-11      Fixed The Driver Passanger Chair
90570         7090          2-Feb-11      Installed New Tv Set
90770         7120          2-Feb-11      Body Paint
90650         7150          2-Feb-11      Air System Replaced
91130         7150          2-Feb-11
90330         7150          3-Feb-11      Replace The Front Lights
91010         7150          3-Feb-11      Replace The Break Lights
91210         7150          3-Feb-11      Na
90770         7150          3-Feb-11      Fixed The Horn System
90450         7150          4-Feb-11      Fixed The Break System
90970         7150          4-Feb-11      Na
90610         7000          31-Jan-11
90570         7000          31-Jan-11


                                                                                                     61
/* 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_OPTION
90810             Joshua,Randall            31-Jan-11                   car sale
91010             Linda,Kobara              31-Jan-11                   car sale
91130             Salman,Mughal             31-Jan-11                   car sale
90170             Tyson,Haywood             1-Feb-11                    car sale
90410             Latifah,msxwall           1-Feb-11                    car sale
91170             Paul,Born                 2-Feb-11                    car sale
90970             Joseph,Matthews           2-Feb-11                    car sale




  /* manager wants to know which mechanic fixed which car including the model*/




                                                                                                                      62
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_ID
7000                                      Johnnattan,Bryon    2010                       2036                  2416
7120                                      Hendron,D.Mario     2011                       2040                  2624
7000                                      Johnnattan,Bryon    2010                       2036                  3664
7120                                      Hendron,D.Mario     2010                       2038                  4912
7150                                      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 inner
join "car" c on c.car_id = r.car_id;



MECHNAIC               MODEL          CAR_ID         REPAIR_ID      CHARGE_AMOUNT             CASH
Johnnattan             2010           2036           2416           $70.99                    $70.99
Hendron                2011           2040           2624           $90.99                    $90.99
Johnnattan             2010           2036           3664           $70.99                    $70.99
Hendron                2010           2038           4912           $490.99                   $490.99


                                                                                                                                63
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_daily
from repairrecord




REPAIR_ID           REPAIR_DATE             AMOUNT_CHARGED CASH                            REPAIR_TOATL_AMOUNT_DAILY

4496                1-Feb-11                $110.99                     $110.99            293.96
4288                1-Feb-11                $40.99                      $40.99             293.96
4080                1-Feb-11                $70.99                      $70.99             293.96


                                                                                                                                  64
3872   1-Feb-11    $70.99    $70.99    293.96
4912   2-Feb-11    $490.99   $490.99   851.97
4704   2-Feb-11    $100.99   $100.99   851.97
5120   2-Feb-11    $209.00   $209.99   851.97
5328   2-Feb-11    $50.00    $50.00    851.97
5744   3-Feb-11    $60.00    $60.00    220
5952   3-Feb-11    $50.00    $50.00    220
6160   3-Feb-11    $50.00    $50.00    220
5536   3-Feb-11    $60.00    $60.00    220
6576   4-Feb-11    $80.00    $80.00    230
6368   4-Feb-11    $150.00   $150.00   230
2000   31-Jan-11   $69.99    $69.99    736.91
3664   31-Jan-11   $70.99    $70.99    736.91
3456   31-Jan-11   $290.99   $90.99    736.91
3248   31-Jan-11   $190.99   $90.99    736.91
3040   31-Jan-11   $290.99   $90.99    736.91
2832   31-Jan-11   $90.99    $90.99    736.91
2208   31-Jan-11   $69.99    $69.99    736.91
2416   31-Jan-11   $70.99    $70.99    736.91
2624   31-Jan-11   $90.99    $90.99    736.91




                                                65
/* 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
------------
 $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                         AGENT
8316              2006              2008              Ford                          Maryanne,Stephine
8158              2002              2009              Ford                          Chris,Paul
8158              2022              2011              Honda                         Chris,Paul
8316              2034              2011              Honda                         Maryanne,Stephine
8158              2028              2011              Hyndai                        Chris,Paul
8237              2040              2011              Hyndai                        Melisa,Henwood
8316              2032              2009              Hyndai                        Maryanne,Stephine
8079              2030              2010              Hyndai                        Dolly,Chris
8000              2010              2004              Toyota                        Celin,Doveward
8079              2012              2003              Toyota                        Dolly,Chris



/*Manager wants to include transaction id and sales date to the previous report*/

                                                                                                                              67
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                    AGENT
8316           2006             900266                   1-Feb-11           2008            Ford                     Maryanne,Stephine
8158           2002             900711                   3-Feb-11           2009            Ford                     Chris,Paul
8158           2022             900088                   31-Jan-11          2011            Honda                    Chris,Paul
8316           2034             900355                   1-Feb-11           2011            Honda                    Maryanne,Stephine
8158           2028             900800                   4-Feb-11           2011            Hyndai                   Chris,Paul
8237           2040             900444                   2-Feb-11           2011            Hyndai                   Melisa,Henwood
8316           2032             900533                   2-Feb-11           2009            Hyndai                   Maryanne,Stephine
8079           2030             900177                   31-Jan-11          2010            Hyndai                   Dolly,Chris
8000           2010             900622                   3-Feb-11           2004            Toyota                   Celin,Doveward
8079           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" as
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

                                                                                                                                         68
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             AGENT
8316            2006            900266                   1-Feb-11           2008            Ford              Maryanne,Stephine
8158            2002            900711                   3-Feb-11           2009            Ford              Chris,Paul
8158            2022            900088                   31-Jan-11          2011            Honda             Chris,Paul
8316            2034            900355                   1-Feb-11           2011            Honda             Maryanne,Stephine
8158            2028            900800                   4-Feb-11           2011            Hyndai            Chris,Paul
8237            2040            900444                   2-Feb-11           2011            Hyndai            Melisa,Henwood
8316            2032            900533                   2-Feb-11           2009            Hyndai            Maryanne,Stephine
8079            2030            900177                   31-Jan-11          2010            Hyndai            Dolly,Chris
8000            2010            900622                   3-Feb-11           2004            Toyota            Celin,Doveward
8079            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 special
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

                                                                                                                                  69
on
          a.car_id = c.car_id
          where city ='blueisland' or city = 'East Chicago'


CUSTOMER_ID CITY                 CAR_ID            TRANSACTION_ID             SALES_DATE MODEL MAKER                   CUSTOMER

91010          East Chicago      2022              900088                     31-Jan-11          2011        Honda     Linda,Kobara
91250          Blueisland        2034              900355                     1-Feb-11           2011        Honda     Tim ,O-Brien
91250          Blueisland        2040              900444                     2-Feb-11           2011        Hyndai    Tim ,O-Brien
91010          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
a.car_id = c.car_id
           where CUST_STATE in (‘IL’, ‘il’,’Il’)




CUSTOMER_ID CITY                CAR_ID          TRANSACTION_ID SALES_DATE MODEL                              MAKER      CUSTOMER
91170       University          2006            900266         1-Feb-11   2008                               Ford       Paul,Born
            Park
91170       University          2032            900533                    2-Feb-11           2009            Hyndai     Paul,Born
            Park
91250       Blueisland          2034            900355                    1-Feb-11           2011            Honda      Tim ,O-Brien
91250       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
a.car_id = c.car_id
         where CUST_STATE in ('IN', 'in', 'In');




CUSTOMER_ID   CITY                CAR_ID           TRANSACTION_ID       SALES_DATE   MODEL   MAKER    CUSTOMER
90890         Indiana City        2002             900711               3-Feb-11     2009    Ford     Kathryn,Wilson
90970         St John             2010             900622               3-Feb-11     2004    Toyota   Joseph,Matthews
90810         Indiana City        2012             899999               31-Jan-11    2003    Toyota   Joshua,Randall
91010         East Chicago        2022             900088               31-Jan-11    2011    Honda    Linda,Kobara
91010         East Chicago        2028             900800               4-Feb-11     2011    Hyndai   Linda,Kobara
91130         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
REQUEST_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION

790177    31-Jan-11     935          tire change
790266    31-Jan-11     930          tire change
790355    31-Jan-11     1045         oil change
790444    31-Jan-11     1125         battery change
790533    31-Jan-11     1125         repair
790622    31-Jan-11     1125         repair
790711    31-Jan-11     1125         repair
790800    31-Jan-11     945
790889    31-Jan-11     900
790978    31-Jan-11     1045
791067    1-Feb-11      1025
791156    1-Feb-11      1345
791245    1-Feb-11      1200         repair
791334    1-Feb-11      1345         oil change
791423    1-Feb-11      1405         oil change
791512    1-Feb-11      1120
791601    1-Feb-11      1045
791690    1-Feb-11      1505         repair
791779    2-Feb-11      1520
791868    2-Feb-11      1100
791957    2-Feb-11      935          repair
792046    2-Feb-11      930          repair


                                                      73
792135     2-Feb-11    1045   repair
792224     2-Feb-11    1125   battery change
792313     2-Feb-11    945
792402     2-Feb-11    900
789999     31-Jan-11   1500   oil change
790088     31-Jan-11   1500   battery change

28 rows
selected




                                               74

Más contenido relacionado

La actualidad más candente

Proposal Project Charter
Proposal Project CharterProposal Project Charter
Proposal Project CharterMohammad Ilham
 
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15Ayapparaj SKS
 
manajemen Proyek perangkat Lunak
manajemen Proyek perangkat Lunakmanajemen Proyek perangkat Lunak
manajemen Proyek perangkat LunakAwank Miclww
 
Modul Praktikum Sistem Basis Data
Modul Praktikum Sistem Basis Data Modul Praktikum Sistem Basis Data
Modul Praktikum Sistem Basis Data Wahyu Widodo
 
15. modul model evaluasi v 0.6
15. modul model evaluasi v 0.615. modul model evaluasi v 0.6
15. modul model evaluasi v 0.6ArdianDwiPraba
 
Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Adam Mukharil Bachtiar
 
Database with SQL Server
Database with SQL ServerDatabase with SQL Server
Database with SQL Servereddie Ismantoe
 
How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-Katy Slemon
 
Modul dasar pemrograman web
Modul dasar pemrograman webModul dasar pemrograman web
Modul dasar pemrograman webDeka M Wildan
 
Makalah array
Makalah arrayMakalah array
Makalah arrayAnanda II
 
Toko online erd dan analisis sistem informasi penjualan berbasis web - mode...
Toko online   erd dan analisis sistem informasi penjualan berbasis web - mode...Toko online   erd dan analisis sistem informasi penjualan berbasis web - mode...
Toko online erd dan analisis sistem informasi penjualan berbasis web - mode...brisma pambudi
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handlingAmol Gaikwad
 

La actualidad más candente (20)

Database rumah sakit
Database rumah sakitDatabase rumah sakit
Database rumah sakit
 
Proposal Project Charter
Proposal Project CharterProposal Project Charter
Proposal Project Charter
 
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
SAS Ron Cody Solutions for even Number problems from Chapter 7 to 15
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
 
Flowchart.ppt
Flowchart.pptFlowchart.ppt
Flowchart.ppt
 
manajemen Proyek perangkat Lunak
manajemen Proyek perangkat Lunakmanajemen Proyek perangkat Lunak
manajemen Proyek perangkat Lunak
 
Solution of Erds
Solution of ErdsSolution of Erds
Solution of Erds
 
Modul Praktikum Sistem Basis Data
Modul Praktikum Sistem Basis Data Modul Praktikum Sistem Basis Data
Modul Praktikum Sistem Basis Data
 
Activity Diagram
Activity DiagramActivity Diagram
Activity Diagram
 
Oracle query optimizer
Oracle query optimizerOracle query optimizer
Oracle query optimizer
 
[RPL2] Activity Diagram
[RPL2] Activity Diagram[RPL2] Activity Diagram
[RPL2] Activity Diagram
 
Session tracking In Java
Session tracking In JavaSession tracking In Java
Session tracking In Java
 
15. modul model evaluasi v 0.6
15. modul model evaluasi v 0.615. modul model evaluasi v 0.6
15. modul model evaluasi v 0.6
 
Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)Data Management (Basis Data Berbasis Dokumen)
Data Management (Basis Data Berbasis Dokumen)
 
Database with SQL Server
Database with SQL ServerDatabase with SQL Server
Database with SQL Server
 
How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-
 
Modul dasar pemrograman web
Modul dasar pemrograman webModul dasar pemrograman web
Modul dasar pemrograman web
 
Makalah array
Makalah arrayMakalah array
Makalah array
 
Toko online erd dan analisis sistem informasi penjualan berbasis web - mode...
Toko online   erd dan analisis sistem informasi penjualan berbasis web - mode...Toko online   erd dan analisis sistem informasi penjualan berbasis web - mode...
Toko online erd dan analisis sistem informasi penjualan berbasis web - mode...
 
Unit-3 event handling
Unit-3 event handlingUnit-3 event handling
Unit-3 event handling
 

Destacado

Oracle Database In-Memory
Oracle Database In-MemoryOracle Database In-Memory
Oracle Database In-MemoryTrivadis
 
Designing for Performance: Database Related Worst Practices
Designing for Performance: Database Related Worst PracticesDesigning for Performance: Database Related Worst Practices
Designing for Performance: Database Related Worst PracticesChristian Antognini
 
Database application and design
Database application and designDatabase application and design
Database application and designsieedah
 
Generating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data ModelerGenerating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data ModelerRob van den Berg
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
Best Practices for Database Schema Design
Best Practices for Database Schema DesignBest Practices for Database Schema Design
Best Practices for Database Schema DesignIron Speed
 
Online Banking Project
Online Banking ProjectOnline Banking Project
Online Banking ProjectM.Saber
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Guy Harrison
 
Dbhondoren 14 15
Dbhondoren 14 15Dbhondoren 14 15
Dbhondoren 14 15arbelar
 
MACHU PICCHU
MACHU PICCHUMACHU PICCHU
MACHU PICCHUlaucs1975
 
10 ways to nurture your spiritual life
10 ways to nurture your spiritual life10 ways to nurture your spiritual life
10 ways to nurture your spiritual lifeBASKARAN P
 
Christmas 2011 - symbols
Christmas 2011 - symbolsChristmas 2011 - symbols
Christmas 2011 - symbolsAny Ataide
 
Finding the meaning in meaningful use
Finding the meaning in meaningful useFinding the meaning in meaningful use
Finding the meaning in meaningful usegdabate
 
Introduction to Learning and Leading by Design
Introduction to Learning and Leading by DesignIntroduction to Learning and Leading by Design
Introduction to Learning and Leading by Designprennertariev
 
Владимир Косых. PR-Охота! "Разработка репутационной политики"
Владимир Косых. PR-Охота! "Разработка репутационной политики"Владимир Косых. PR-Охота! "Разработка репутационной политики"
Владимир Косых. PR-Охота! "Разработка репутационной политики"prasu1995
 
Weird photos - pictures
Weird photos - picturesWeird photos - pictures
Weird photos - picturesFlorin Levarda
 
Art portfolio
Art portfolioArt portfolio
Art portfolioGorislav
 

Destacado (20)

Oracle Database In-Memory
Oracle Database In-MemoryOracle Database In-Memory
Oracle Database In-Memory
 
Designing for Performance: Database Related Worst Practices
Designing for Performance: Database Related Worst PracticesDesigning for Performance: Database Related Worst Practices
Designing for Performance: Database Related Worst Practices
 
Database application and design
Database application and designDatabase application and design
Database application and design
 
Generating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data ModelerGenerating Code with Oracle SQL Developer Data Modeler
Generating Code with Oracle SQL Developer Data Modeler
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
Best Practices for Database Schema Design
Best Practices for Database Schema DesignBest Practices for Database Schema Design
Best Practices for Database Schema Design
 
Online Banking Project
Online Banking ProjectOnline Banking Project
Online Banking Project
 
Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)Top 10 tips for Oracle performance (Updated April 2015)
Top 10 tips for Oracle performance (Updated April 2015)
 
Dbhondoren 14 15
Dbhondoren 14 15Dbhondoren 14 15
Dbhondoren 14 15
 
MACHU PICCHU
MACHU PICCHUMACHU PICCHU
MACHU PICCHU
 
10 ways to nurture your spiritual life
10 ways to nurture your spiritual life10 ways to nurture your spiritual life
10 ways to nurture your spiritual life
 
Christmas 2011 - symbols
Christmas 2011 - symbolsChristmas 2011 - symbols
Christmas 2011 - symbols
 
Daftarhadir&nilai statistik1213
Daftarhadir&nilai statistik1213Daftarhadir&nilai statistik1213
Daftarhadir&nilai statistik1213
 
Knowledge-based web service integration for industrial automation
Knowledge-based web service  integration for industrial automationKnowledge-based web service  integration for industrial automation
Knowledge-based web service integration for industrial automation
 
Finding the meaning in meaningful use
Finding the meaning in meaningful useFinding the meaning in meaningful use
Finding the meaning in meaningful use
 
Introduction to Learning and Leading by Design
Introduction to Learning and Leading by DesignIntroduction to Learning and Leading by Design
Introduction to Learning and Leading by Design
 
Владимир Косых. PR-Охота! "Разработка репутационной политики"
Владимир Косых. PR-Охота! "Разработка репутационной политики"Владимир Косых. PR-Охота! "Разработка репутационной политики"
Владимир Косых. PR-Охота! "Разработка репутационной политики"
 
Weird photos - pictures
Weird photos - picturesWeird photos - pictures
Weird photos - pictures
 
Art portfolio
Art portfolioArt portfolio
Art portfolio
 
Halobios
HalobiosHalobios
Halobios
 

Similar a Database Design Project-Oracle 11g

The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sqlMcNamaraChiwaye
 
The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sqlMcNamaraChiwaye
 
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project ADN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project ADataconomy Media
 
CREATE TABLE OFFICES ( OFFICEID INT, CITY .docx
CREATE TABLE OFFICES ( OFFICEID              INT,  CITY     .docxCREATE TABLE OFFICES ( OFFICEID              INT,  CITY     .docx
CREATE TABLE OFFICES ( OFFICEID INT, CITY .docxvanesaburnand
 
Introduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraIntroduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraDataStax Academy
 
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docx
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docxTopic 1 Rubric Standards Graphic OrganizerCriteria Value.docx
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docxedwardmarivel
 
AimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docxAimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docxsimonlbentley59018
 
Portfolio For Charles Tontz
Portfolio For Charles TontzPortfolio For Charles Tontz
Portfolio For Charles Tontzctontz
 
Data infrastructure for the other 90% of companies
Data infrastructure for the other 90% of companiesData infrastructure for the other 90% of companies
Data infrastructure for the other 90% of companiesMartin Loetzsch
 
Sql basics
Sql basicsSql basics
Sql basicsKumar
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2prasaaanna2
 
Describe DBLC (Database Life Cycle) and its phases.Describ.docx
Describe DBLC (Database Life Cycle) and its phases.Describ.docxDescribe DBLC (Database Life Cycle) and its phases.Describ.docx
Describe DBLC (Database Life Cycle) and its phases.Describ.docxsalmonpybus
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENTLori Moore
 
Premiere Products Exercises
Premiere Products ExercisesPremiere Products Exercises
Premiere Products ExercisesAmy Miller
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2lifesgood12
 

Similar a Database Design Project-Oracle 11g (20)

The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sql
 
The ultimate-guide-to-sql
The ultimate-guide-to-sqlThe ultimate-guide-to-sql
The ultimate-guide-to-sql
 
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project ADN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
DN 2017 | Reducing pain in data engineering | Martin Loetzsch | Project A
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
CREATE TABLE OFFICES ( OFFICEID INT, CITY .docx
CREATE TABLE OFFICES ( OFFICEID              INT,  CITY     .docxCREATE TABLE OFFICES ( OFFICEID              INT,  CITY     .docx
CREATE TABLE OFFICES ( OFFICEID INT, CITY .docx
 
Introduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for CassandraIntroduction to Dating Modeling for Cassandra
Introduction to Dating Modeling for Cassandra
 
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docx
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docxTopic 1 Rubric Standards Graphic OrganizerCriteria Value.docx
Topic 1 Rubric Standards Graphic OrganizerCriteria Value.docx
 
AimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docxAimTo give you practical experience in database modelling, no.docx
AimTo give you practical experience in database modelling, no.docx
 
Portfolio For Charles Tontz
Portfolio For Charles TontzPortfolio For Charles Tontz
Portfolio For Charles Tontz
 
Data infrastructure for the other 90% of companies
Data infrastructure for the other 90% of companiesData infrastructure for the other 90% of companies
Data infrastructure for the other 90% of companies
 
Sql General
Sql General Sql General
Sql General
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Sql basics
Sql basicsSql basics
Sql basics
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2
 
Describe DBLC (Database Life Cycle) and its phases.Describ.docx
Describe DBLC (Database Life Cycle) and its phases.Describ.docxDescribe DBLC (Database Life Cycle) and its phases.Describ.docx
Describe DBLC (Database Life Cycle) and its phases.Describ.docx
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
 
Premiere Products Exercises
Premiere Products ExercisesPremiere Products Exercises
Premiere Products Exercises
 
Cis 336 final exam 2
Cis 336 final exam 2Cis 336 final exam 2
Cis 336 final exam 2
 
Dbms
DbmsDbms
Dbms
 
Fahri tugas cloud1
Fahri tugas cloud1Fahri tugas cloud1
Fahri tugas cloud1
 

Más de Sunny U Okoro

SQL Server and SSAS
SQL Server and SSAS SQL Server and SSAS
SQL Server and SSAS Sunny U Okoro
 
BI Apps Reports 5 QlikSense Desktop
BI Apps Reports 5  QlikSense DesktopBI Apps Reports 5  QlikSense Desktop
BI Apps Reports 5 QlikSense DesktopSunny U Okoro
 
MS SSAS 2008 & MDX Reports
MS SSAS 2008 &  MDX Reports MS SSAS 2008 &  MDX Reports
MS SSAS 2008 & MDX Reports Sunny U Okoro
 
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseDBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseSunny U Okoro
 
BI Apps ETL 4- Informatica PowerCenter Express
BI  Apps ETL 4- Informatica PowerCenter  ExpressBI  Apps ETL 4- Informatica PowerCenter  Express
BI Apps ETL 4- Informatica PowerCenter ExpressSunny U Okoro
 
BI Apps Reports 4 Cognos BI and Crystal Reports
BI Apps Reports 4  Cognos BI and Crystal ReportsBI Apps Reports 4  Cognos BI and Crystal Reports
BI Apps Reports 4 Cognos BI and Crystal ReportsSunny U Okoro
 
Tableau Reports and Oracle OBIEE
Tableau Reports and  Oracle OBIEETableau Reports and  Oracle OBIEE
Tableau Reports and Oracle OBIEESunny U Okoro
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server Sunny U Okoro
 
Advanced ETL2 Pentaho
Advanced ETL2  Pentaho Advanced ETL2  Pentaho
Advanced ETL2 Pentaho Sunny U Okoro
 
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsBI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsSunny U Okoro
 
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012Sunny U Okoro
 
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional Sunny U Okoro
 
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsAdvanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsSunny U Okoro
 
Advanced ETL MS SSIS 2012 & Talend
Advanced ETL  MS  SSIS 2012 & Talend Advanced ETL  MS  SSIS 2012 & Talend
Advanced ETL MS SSIS 2012 & Talend Sunny U Okoro
 
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16  DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16 Sunny U Okoro
 
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsDB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsSunny U Okoro
 

Más de Sunny U Okoro (20)

SQL Server and SSAS
SQL Server and SSAS SQL Server and SSAS
SQL Server and SSAS
 
BI Apps Reports 5 QlikSense Desktop
BI Apps Reports 5  QlikSense DesktopBI Apps Reports 5  QlikSense Desktop
BI Apps Reports 5 QlikSense Desktop
 
MS SSAS 2008 & MDX Reports
MS SSAS 2008 &  MDX Reports MS SSAS 2008 &  MDX Reports
MS SSAS 2008 & MDX Reports
 
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & SybaseDBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
DBA Oracle,SQL Server, MYSQL,DB2 Express Postgres & Sybase
 
Database Migration
Database MigrationDatabase Migration
Database Migration
 
Cognos Express
Cognos ExpressCognos Express
Cognos Express
 
BI Apps ETL 4- Informatica PowerCenter Express
BI  Apps ETL 4- Informatica PowerCenter  ExpressBI  Apps ETL 4- Informatica PowerCenter  Express
BI Apps ETL 4- Informatica PowerCenter Express
 
Oracle ODI
Oracle ODIOracle ODI
Oracle ODI
 
BI Apps Reports 4 Cognos BI and Crystal Reports
BI Apps Reports 4  Cognos BI and Crystal ReportsBI Apps Reports 4  Cognos BI and Crystal Reports
BI Apps Reports 4 Cognos BI and Crystal Reports
 
Tableau Reports and Oracle OBIEE
Tableau Reports and  Oracle OBIEETableau Reports and  Oracle OBIEE
Tableau Reports and Oracle OBIEE
 
DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server DB 3 Sybase ASE 15 & MS SQL Server
DB 3 Sybase ASE 15 & MS SQL Server
 
MS SSAS 2012 & MDX
MS SSAS 2012  &  MDXMS SSAS 2012  &  MDX
MS SSAS 2012 & MDX
 
Advanced ETL2 Pentaho
Advanced ETL2  Pentaho Advanced ETL2  Pentaho
Advanced ETL2 Pentaho
 
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business ObjectsBI Apps Reports2- Oracle OBIEE & SAP Business Objects
BI Apps Reports2- Oracle OBIEE & SAP Business Objects
 
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
MiS SharePoint 2010-SSRS, Power View & PowerPivot 2012
 
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional BI Apps  OLAP & Reports- SSAS 2012 Tabular & Multidimensional
BI Apps OLAP & Reports- SSAS 2012 Tabular & Multidimensional
 
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,FormsAdvanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
Advanced SSRS 2012-SSAS,SSIS, XML, ASP.NET,Forms
 
Advanced ETL MS SSIS 2012 & Talend
Advanced ETL  MS  SSIS 2012 & Talend Advanced ETL  MS  SSIS 2012 & Talend
Advanced ETL MS SSIS 2012 & Talend
 
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16  DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
DB Develop 2 Oracle 12c, DB2, MYSQL, SQL Anywhere 16
 
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & AduitsDB Security Oracle 11g-Application Context, Dynamic Views & Aduits
DB Security Oracle 11g-Application Context, Dynamic Views & Aduits
 

Database Design Project-Oracle 11g

  • 1. Lakeshore Auto Database System Project Sunny Okoro DBST651, Spring 2011 Graduate School University of Maryland University College
  • 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 ..................................................................................................................................................................................................................19 Reports. .....................................................................................................................................................................................................................................52 1
  • 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 of cars 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 entered into 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 appointment for 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 by managers to produce monthly and weekly statistical reports. Diagram Tool Oracle SQL Developer Data Molder Database Oracle 11g 2
  • 4. Composition Software Notepad +++ for writing and editing SQL commands Hardware and Software Microsoft Windows 7 Professional x64 DDL, TCL and DML Oracle SQL would be used for the Data Definition, Data Manipulation and Transaction Control languages of to build the database. I would also use Database objects including constraints, views, index and sequences to generate unique values for Primary Key. Deliverable 2 – ERD 3
  • 5. 4
  • 6. ERD Description Customer Table A 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 Table A Car sale must be associated with one agent One or more car sales must be associated with a car Agent Table An agent must be associated with one or more car sales Mechanic Table A mechanic must be associated with one or more repair record(s) Reservations Table One or more reservations must be associated to a customer. Car Table A car must be associated with one or more car sale(s) 5
  • 7. Repair Record A 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 to use 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. 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_seq Start with 090090 Increment by 40 nocycle; /*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. /* 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 same name.*/ 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 created before.*/ Drop sequence agent_agent_id_seq; CREATE SEQUENCE agent_agent_id_seq start with 008000 increment by 079 nocycle; /* Adds the not null constraint to make sure each column has a value specified by upon input.*/ 8
  • 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. 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 the drop statement.*/ Drop sequence car_car_id_seq; CREATE SEQUENCE car_car_id_seq start with 2000 increment by 02 nocycle; ***** 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. 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_seq start with 0899999 increment by 089 nocycle; /*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. Alter table CarSales modify (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 CarSales Add constraint csale_agent_id_fk foreign key(agent_id) references "agent"(agent_id)on delete cascade; Alter table CarSales Add 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. ***** 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. /*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 been created before.*/ Drop sequence reservation_request_id_seq; CREATE SEQUENCE reservation_request_id_seq start with 0789999 increment by 089 nocycle; /*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. /*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. 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 created before.*/ Drop sequence meach_meachinic_id_seq; CREATE SEQUENCE meach_meachinic_id_seq start with 007000 increment by 030 nocycle; /*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. 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. /* 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 RepairRecord Add constraint repair_oil_change check (Oil_Change in ('yes', 'no')); Alter table RepairRecord Add constraint repair_Battery_change check (Battery_change in ('yes', 'no')); Alter table RepairRecord Add constraint repair_tire_change check (tire_change in ('yes', 'no')); Alter table RepairRecord Add 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 RepairRecord Add constraint repair_mechanic_id_fk foreign key(Mechanic_ID) References "mechanic"(Mechanic_ID) ON DELETE CASCADE; Alter table RepairRecord Add constraint repair_customer_id_fk foreign key(customer_ID) References "customer"(customer_ID) ON DELETE CASCADE; 18
  • 20. Alter table RepairRecord Add 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 RepairRecord Add 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 same name with the drop statement. */ Drop sequence repair_id_seq; CREATE SEQUENCE repair_id_seq start with 2000 increment by 0208 nocycle; Deliverable 4 – DML (Data Manipulation Language) Insert Statements /*The following commands inserts data into table customer */ 19
  • 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. 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. 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. 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. 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. 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. 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. 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. 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. (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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. ( 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. 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. 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. 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. ( 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. 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. 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. 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. (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" where car_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" where car_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" where car_id = 2006), to_date ('01-FEB-11', 'dd-mon-yyyy'), 49
  • 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" where car_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" where car_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" where car_id = 2032), to_date ('02-FEB-11', 'dd-mon-yyyy'), 0, 21000, 0 ,21000, 12, 38, 91170); 50
  • 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" where car_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" where car_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" where car_id = 2028 ), to_date ('04-FEB-11', 'dd-mon-yyyy'), 0, 21890, 0 ,21890, 12, 38, 91010); 51
  • 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_Type from "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. /*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. /*manager wants to know which client received which service for service option */ 54
  • 56. CUSTOMER_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION 90570 31-Jan-11 935 Tire Change / 90530 31-Jan-11 1500 Battery Change 90650 31-Jan-11 1045 Oil Change 90690 31-Jan-11 1125 Battery Change 90650 31-Jan-11 1125 Repair 90730 31-Jan-11 1125 Repair 90770 31-Jan-11 1125 Repair 90610 31-Jan-11 930 Tire Change 90490 31-Jan-11 1500 Oil Change 90170 1-Feb-11 1405 Oil Change 91090 1-Feb-11 1505 Repair 90090 1-Feb-11 1345 Oil Change 90090 1-Feb-11 1200 Repair 90570 2-Feb-11 935 Repair 90770 2-Feb-11 930 Repair 90650 2-Feb-11 1045 Repair 91130 2-Feb-11 1125 Battery Change 55
  • 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 = 31234590904 where customer_id = 90890; 56
  • 58. update "customer" set Phone_1 = 2192248902 where customer_id = 90930; update "customer" set Phone_1 = 8159091450 where customer_id = 91130; update "customer" set Phone_1 = 6304408903 where customer_id = 91170; update "customer" set Phone_1 = 8154408903 where customer_id = 91210; update "customer" set Phone_1 = 7737338470 where customer_id = 91250; update "customer" set Phone_1 = 7097338470 where customer_id = 91290; update "customer" set Phone_1 = 31293484567 where customer_id = 91330; 57
  • 59. update "customer" set Phone_1 = 31989081234 where customer_id = 91410; update "customer" set Phone_1 = 2198800903 select 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_STATE 90530 na na na 90810 na na na 90890 na na na /* update the customer table to fill in the missing values*/ 58
  • 60. update "customer" set city ='indiana city' where customer_id = 90530; update "customer" set address = '9090 michigan ave' where customer_id = 90530; update "customer" set cust_state = 'IN' where customer_id = 90530; UPDATE "customer" set zip_code=41909 where customer_id = 90530; update "customer" set city ='indiana city' where customer_id = 90810; update "customer" set address = '401 ceder lake blv apt 23' where customer_id = 90810; update "customer" set cust_state = 'IN' where customer_id = 90810; UPDATE "customer" 59
  • 61. set zip_code=41909 where customer_id = 90810; update "customer" set city ='indiana city' where customer_id =90890; update "customer" set address = '401 ceder lake nw blvd' where customer_id = 90890; update "customer" set cust_state = 'IN' where customer_id = 90890; UPDATE "customer" set zip_code=41909 where 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. CUSTOMER_ID MECHANIC_ID REPAIR_DATE REPAIR_NOTES 90650 7000 31-Jan-11 90690 7120 31-Jan-11 90530 7120 31-Jan-11 90730 7000 31-Jan-11 Fixed The Transmission System And The Right Window Frame 90770 7120 31-Jan-11 Fixed The Oil Tank 90650 7000 31-Jan-11 Fixed The Front Bumper 90490 7000 31-Jan-11 90410 7030 1-Feb-11 91050 7030 1-Feb-11 90090 7030 1-Feb-11 Fixed The Cup Holder 91250 7030 1-Feb-11 Fixed The Driver Passanger Chair 90570 7090 2-Feb-11 Installed New Tv Set 90770 7120 2-Feb-11 Body Paint 90650 7150 2-Feb-11 Air System Replaced 91130 7150 2-Feb-11 90330 7150 3-Feb-11 Replace The Front Lights 91010 7150 3-Feb-11 Replace The Break Lights 91210 7150 3-Feb-11 Na 90770 7150 3-Feb-11 Fixed The Horn System 90450 7150 4-Feb-11 Fixed The Break System 90970 7150 4-Feb-11 Na 90610 7000 31-Jan-11 90570 7000 31-Jan-11 61
  • 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_OPTION 90810 Joshua,Randall 31-Jan-11 car sale 91010 Linda,Kobara 31-Jan-11 car sale 91130 Salman,Mughal 31-Jan-11 car sale 90170 Tyson,Haywood 1-Feb-11 car sale 90410 Latifah,msxwall 1-Feb-11 car sale 91170 Paul,Born 2-Feb-11 car sale 90970 Joseph,Matthews 2-Feb-11 car sale /* manager wants to know which mechanic fixed which car including the model*/ 62
  • 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_ID 7000 Johnnattan,Bryon 2010 2036 2416 7120 Hendron,D.Mario 2011 2040 2624 7000 Johnnattan,Bryon 2010 2036 3664 7120 Hendron,D.Mario 2010 2038 4912 7150 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 inner join "car" c on c.car_id = r.car_id; MECHNAIC MODEL CAR_ID REPAIR_ID CHARGE_AMOUNT CASH Johnnattan 2010 2036 2416 $70.99 $70.99 Hendron 2011 2040 2624 $90.99 $90.99 Johnnattan 2010 2036 3664 $70.99 $70.99 Hendron 2010 2038 4912 $490.99 $490.99 63
  • 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_daily from repairrecord REPAIR_ID REPAIR_DATE AMOUNT_CHARGED CASH REPAIR_TOATL_AMOUNT_DAILY 4496 1-Feb-11 $110.99 $110.99 293.96 4288 1-Feb-11 $40.99 $40.99 293.96 4080 1-Feb-11 $70.99 $70.99 293.96 64
  • 66. 3872 1-Feb-11 $70.99 $70.99 293.96 4912 2-Feb-11 $490.99 $490.99 851.97 4704 2-Feb-11 $100.99 $100.99 851.97 5120 2-Feb-11 $209.00 $209.99 851.97 5328 2-Feb-11 $50.00 $50.00 851.97 5744 3-Feb-11 $60.00 $60.00 220 5952 3-Feb-11 $50.00 $50.00 220 6160 3-Feb-11 $50.00 $50.00 220 5536 3-Feb-11 $60.00 $60.00 220 6576 4-Feb-11 $80.00 $80.00 230 6368 4-Feb-11 $150.00 $150.00 230 2000 31-Jan-11 $69.99 $69.99 736.91 3664 31-Jan-11 $70.99 $70.99 736.91 3456 31-Jan-11 $290.99 $90.99 736.91 3248 31-Jan-11 $190.99 $90.99 736.91 3040 31-Jan-11 $290.99 $90.99 736.91 2832 31-Jan-11 $90.99 $90.99 736.91 2208 31-Jan-11 $69.99 $69.99 736.91 2416 31-Jan-11 $70.99 $70.99 736.91 2624 31-Jan-11 $90.99 $90.99 736.91 65
  • 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. ------------ $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 AGENT 8316 2006 2008 Ford Maryanne,Stephine 8158 2002 2009 Ford Chris,Paul 8158 2022 2011 Honda Chris,Paul 8316 2034 2011 Honda Maryanne,Stephine 8158 2028 2011 Hyndai Chris,Paul 8237 2040 2011 Hyndai Melisa,Henwood 8316 2032 2009 Hyndai Maryanne,Stephine 8079 2030 2010 Hyndai Dolly,Chris 8000 2010 2004 Toyota Celin,Doveward 8079 2012 2003 Toyota Dolly,Chris /*Manager wants to include transaction id and sales date to the previous report*/ 67
  • 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 AGENT 8316 2006 900266 1-Feb-11 2008 Ford Maryanne,Stephine 8158 2002 900711 3-Feb-11 2009 Ford Chris,Paul 8158 2022 900088 31-Jan-11 2011 Honda Chris,Paul 8316 2034 900355 1-Feb-11 2011 Honda Maryanne,Stephine 8158 2028 900800 4-Feb-11 2011 Hyndai Chris,Paul 8237 2040 900444 2-Feb-11 2011 Hyndai Melisa,Henwood 8316 2032 900533 2-Feb-11 2009 Hyndai Maryanne,Stephine 8079 2030 900177 31-Jan-11 2010 Hyndai Dolly,Chris 8000 2010 900622 3-Feb-11 2004 Toyota Celin,Doveward 8079 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" as 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 68
  • 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 AGENT 8316 2006 900266 1-Feb-11 2008 Ford Maryanne,Stephine 8158 2002 900711 3-Feb-11 2009 Ford Chris,Paul 8158 2022 900088 31-Jan-11 2011 Honda Chris,Paul 8316 2034 900355 1-Feb-11 2011 Honda Maryanne,Stephine 8158 2028 900800 4-Feb-11 2011 Hyndai Chris,Paul 8237 2040 900444 2-Feb-11 2011 Hyndai Melisa,Henwood 8316 2032 900533 2-Feb-11 2009 Hyndai Maryanne,Stephine 8079 2030 900177 31-Jan-11 2010 Hyndai Dolly,Chris 8000 2010 900622 3-Feb-11 2004 Toyota Celin,Doveward 8079 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 special 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 69
  • 71. on a.car_id = c.car_id where city ='blueisland' or city = 'East Chicago' CUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER 91010 East Chicago 2022 900088 31-Jan-11 2011 Honda Linda,Kobara 91250 Blueisland 2034 900355 1-Feb-11 2011 Honda Tim ,O-Brien 91250 Blueisland 2040 900444 2-Feb-11 2011 Hyndai Tim ,O-Brien 91010 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. a.car_id = c.car_id where CUST_STATE in (‘IL’, ‘il’,’Il’) CUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER 91170 University 2006 900266 1-Feb-11 2008 Ford Paul,Born Park 91170 University 2032 900533 2-Feb-11 2009 Hyndai Paul,Born Park 91250 Blueisland 2034 900355 1-Feb-11 2011 Honda Tim ,O-Brien 91250 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. a.car_id = c.car_id where CUST_STATE in ('IN', 'in', 'In'); CUSTOMER_ID CITY CAR_ID TRANSACTION_ID SALES_DATE MODEL MAKER CUSTOMER 90890 Indiana City 2002 900711 3-Feb-11 2009 Ford Kathryn,Wilson 90970 St John 2010 900622 3-Feb-11 2004 Toyota Joseph,Matthews 90810 Indiana City 2012 899999 31-Jan-11 2003 Toyota Joshua,Randall 91010 East Chicago 2022 900088 31-Jan-11 2011 Honda Linda,Kobara 91010 East Chicago 2028 900800 4-Feb-11 2011 Hyndai Linda,Kobara 91130 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. REQUEST_ID REQUEST_DATE REQUEST_TIME SERVICE_OPTION 790177 31-Jan-11 935 tire change 790266 31-Jan-11 930 tire change 790355 31-Jan-11 1045 oil change 790444 31-Jan-11 1125 battery change 790533 31-Jan-11 1125 repair 790622 31-Jan-11 1125 repair 790711 31-Jan-11 1125 repair 790800 31-Jan-11 945 790889 31-Jan-11 900 790978 31-Jan-11 1045 791067 1-Feb-11 1025 791156 1-Feb-11 1345 791245 1-Feb-11 1200 repair 791334 1-Feb-11 1345 oil change 791423 1-Feb-11 1405 oil change 791512 1-Feb-11 1120 791601 1-Feb-11 1045 791690 1-Feb-11 1505 repair 791779 2-Feb-11 1520 791868 2-Feb-11 1100 791957 2-Feb-11 935 repair 792046 2-Feb-11 930 repair 73
  • 75. 792135 2-Feb-11 1045 repair 792224 2-Feb-11 1125 battery change 792313 2-Feb-11 945 792402 2-Feb-11 900 789999 31-Jan-11 1500 oil change 790088 31-Jan-11 1500 battery change 28 rows selected 74