Question

Create a DDL MYSQL create a database where a user can sell their vehicle, lease a vehicle, financ...

create a DDL MYSQL

create a database where a user can sell their vehicle, lease a vehicle, finance a cart, or donate their current vehicle.

Also we'll have a adminstrator that will have access to the customers and vehicles.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Customers(CID, first_name, Last_Name, Address)

Vehicle(VID, Mileage, Location, Size, Transmission)

Reservations(CID,VID, Start_Date, End_Date)

Note :

->Vehicle.transmission can have two values ‘manual’ and ‘automatic’.

->Vehicle.size can have following values. ‘compact’, ‘mid-size’, ‘full-size’, ‘premium’ and ‘luxury’. The default size is compact.

Create customers table

CREATE TABLE Customers

(

CID varchar2(5) PRIMARY KEY,

FIRST_NAME varchar2(20),

LAST_NAME varchar2(15),

ADDRESS varchar2(30)

);

Create vehicle table

CREATE TABLE Vehicle

(

VID varchar2(5) PRIMARY KEY,

MILEAGE NUMBER(7,2),

LOCATION varchar2(20),

VSIZE varchar2(30) CHECK (VSIZE IN('COMPACT','MID-SIZE','FULL-SIZE','PREMIUM','LUXURY')),

TRANSMISSION varchar2(10) CHECK (TRANSMISSION IN('MANUAL','AUTOMATIC'))

);

Create reservation table

CREATE TABLE Reservation

(

CID varchar2(5) REFERENCES Customers(CID),

VID varchar2(5) REFERENCES Vehicle(VID),

START_DATE DATE,

END_DATE DATE,

PRIMARY KEY(CID,VID)

);

Description / definition of customer table

DESC CUSTOMERS;

Output :

Name Null? Type

CID NOT NULL VARCHAR2(5)

FIRST_NAME VARCHAR2(20)

LAST_NAME VARCHAR2(15)

ADDRESS VARCHAR2(30)

Description / definition of vehicle table

DESC VEHICLE;

Output :

Name Null? Type

VID NOT NULL VARCHAR2(5)

MILEAGE NUMBER(7,2)

LOCATION VARCHAR2(20)

VSIZE VARCHAR2(30)

TRANSMISSION VARCHAR2(10)

Description / definition of reservation table

DESC RESERVATION;

Output :

Name Null? Type

CID NOT NULL VARCHAR2(5)

VID NOT NULL VARCHAR2(5)

START_DATE DATE

END_DATE DATE

Insert statements

INSERT STATEMENT FOR CUSTOMER TABLE

INSERT INTO Customers

(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES ('101','KRUNAL','PATEL','MANINAGAR,AHMD');

INSERT INTO Customers

(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES ('102','BHAVESH','MODI','VADAJ,AHMD');

INSERT INTO Customers

(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES ('103','DARSHAN','DERASARI','HIMANTNAGAR');

INSERT INTO Customers

(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES ('104','VISHAL','DAVE','ISSANPUR,AHMD');

INSERT INTO Customers

(CID,FIRST_NAME,LAST_NAME,ADDRESS) VALUES ('105','SAGAR','SHAH','VATVA,AHMD');

INSERT STATEMENT FOR VEHICLE TABLE

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-101','70','AHMD','COMPACT','AUTOMATIC');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-102','50','SURAT','COMPACT','AUTOMATIC');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-103','10','AHMD','MID-SIZE','MANUAL');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-104','30','AHMD','MID-SIZE','AUTOMATIC');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-105','15','VADODARA','FULL-SIZE','AUTOMATIC');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-106','20','AHMD','LUXURY','AUTOMATIC');

INSERT INTO Vehicle (VID,MILEAGE,LOCATION,VSIZE,TRANSMISSION)

VALUES ('V-107','50','AHMD','LUXURY','MANUAL');

INSERT STATEMENT FOR RESERVATION TABLE

INSERT INTO Reservation

(CID,VID,START_DATE,END_DATE) VALUES ('101','V-101','10-JAN-2001','10-FEB-2005');

INSERT INTO Reservation

(CID,VID,START_DATE,END_DATE) VALUES ('102','V-102','12-MAR-2001','10-JUN-2006');

INSERT INTO Reservation

(CID,VID,START_DATE,END_DATE) VALUES ('103','V-103','15-FEB-1999','09-SEP-2005');

INSERT INTO Reservation

(CID,VID,START_DATE,END_DATE) VALUES ('105','V-105','15-FEB-2003','09-SEP-2005');

Display records of customer table

SELECT * FROM CUSTOMERS;

Output :

CID FIRST_NAME LAST_NAME ADDRESS

101 KRUNAL PATEL MANINAGAR,AHMD

102 BHAVESH MODI VADAJ,AHMD

103 DARSHAN DERASARI HIMANTNAGAR

104 VISHAL DAVE ISSANPUR,AHMD

105 SAGAR SHAH VATVA,AHMD

Display records of vehicle table

SELECT * FROM VEHICLE;

Output :

VID MILEAGE LOCATION VSIZE TRANSMISSI

V-101 70 AHMD COMPACT AUTOMATIC

V-102 50 SURAT COMPACT AUTOMATIC

V-103 10 AHMD MID-SIZE MANUAL

V-104 30 AHMD MID-SIZE AUTOMATIC

V-105 15 VADODARA FULL-SIZE AUTOMATIC

V-106 20 AHMD LUXURY AUTOMATIC

V-107 50 AHMD LUXURY MANUAL

Display records of reservation table

SELECT * FROM RESERVATION;

Output :

CID VID START_DAT END_DATE

101 V-101 10-JAN-01 10-FEB-05

102 V-102 12-MAR-01 10-JUN-06

103 V-103 15-FEB-99 09-SEP-05

105 V-105 15-FEB-03 09-SEP-05

Display vehicles which are reserved for maximum times

SELECT * FROM VEHICLE WHERE VID =

   (

   SELECT VID FROM RESERVATION WHERE ROUND((END_DATE-START_DATE)/365) =

   (SELECT MAX(ROUND((END_DATE-START_DATE)/365)) AS "MAXIMUM TIME"FROM RESERVATION)

   );

Output :

VID MILEAGE LOCATION VSIZE TRANSMISSI

V-103 10 AHMD MID-SIZE MANUAL

Display vehicles size is the most preferred.

SELECT VSIZE FROM VEHICLE WHERE MILEAGE = (SELECT MAX(MILEAGE) FROM VEHICLE);

Output :

VSIZE

COMPACT

Find location and total mileage of all vehicles specific to each respective location.

SELECT LOCATION,SUM(MILEAGE) FROM VEHICLE GROUP BY LOCATION;

Output :

OCATION SUM(MILEAGE)

HMD 110

URAT 50

ADODARA 15

Find the locations that have at least one vehicle with manual transmission that has lower mileage than any luxury vehicle at that location.

SELECT VID,MILEAGE,TRANSMISSION FROM VEHICLE WHERE TRANSMISSION = 'MANUAL' AND MILEAGE < (SELECT MILEAGE FROM VEHICLE WHERE VSIZE = 'LUXURY');

Output :

VID MILEAGE TRANSMISSION

V-103 10 MANUAL

Find the last names of people who have at least one reservation at a location such that the number of reservations at that location is less than the number of vehicles at that location with automatic transmission.

SELECT COUNT(VID),LOCATION FROM VEHICLE GROUP BY LOCATION NOT IN (SELECT COUNT(VID),LOCATION FROM VEHICLE GROUP BY LOCATION);

Find average mileage of vehicles for each location, which has at least five vehicles.

SELECT AVG(MILEAGE),COUNT(VID),LOCATION FROM VEHICLE GROUP BY LOCATION HAVING COUNT(VID) >= 5;

Output :

AVG(MILEAGE) COUNT(VID) LOCATION

   36 5 AHMD

Find names of customers whose lastname starts with ‘S’ and who has reserved more vehicles than the customer with CID as 101.

SELECT LAST_NAME,FIRST_NAME FROM CUSTOMERS WHERE LAST_NAME like 'S%';

Delete all the reservations for customer whose last name starts with ‘S’.

DELETE FROM RESERVATION WHERE CID IN (SELECT CID FROM CUSTOMERS WHERE LAST_NAME LIKE 'S%');

Output :

RESERVATION TABLE BEFORE 'DELETE' OPERATION :=====>

CID VID START_DAT END_DATE

101 V-101 10-JAN-01 10-FEB-05

102 V-102 12-MAR-01 10-JUN-06

103 V-103 15-FEB-99 09-SEP-05

105 V-105 15-FEB-03 09-SEP-05

RESERVATION TABLE AFTER 'DELETE' OPERATION :=====>

CID VID START_DAT END_DATE

101 V-101 10-JAN-01 10-FEB-05

102 V-102 12-MAR-01 10-JUN-06

103 V-103 15-FEB-99 09-SEP-05

Add a comment
Know the answer?
Add Answer to:
Create a DDL MYSQL create a database where a user can sell their vehicle, lease a vehicle, financ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • create a relational schmea for this Scenario!!! like fileds and keys Our application is a database...

    create a relational schmea for this Scenario!!! like fileds and keys Our application is a database used to discover, sell, and purchase vehicles. The client at first logs into the database by either joining, or making a record. The alternatives are the client can either sell their present vehicle, rent another vehicle, account a vehicle, or give their present vehicle. Additionally we'll have a admin doing every one of the approvals and erasing of solicitations in our framework. Clients will...

  • Instructions Using Php and MySQL, database from Xampp In this assignment, you will create an application...

    Instructions Using Php and MySQL, database from Xampp In this assignment, you will create an application using PHP and MySQL, incorporating all of the skills that you have learned throughout the course. As you complete the project, be sure that you are using the correct format and syntax as well as the appropriate structure for your coding. To move forward to the next module, you will need to demonstrate mastery by scoring an 80% or higher. If you score less...

  • Create a Web page to be used for storing software development bug reports in a MySQL...

    Create a Web page to be used for storing software development bug reports in a MySQL database. Include fields such as product name and version, type of hardware, operating system, frequency of occurrence, and proposed solutions. On the main page you display all the reported bugs (hint: use a table). Include a link at the bottom of the page which takes you to another page where you can create a new bug report. Furthermore, add a link after every filed...

  • Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than...

    Use MySQL Workbench for these questions. Do NOT use Lucidchart. MySQL Workbench has more capability than Lucidchart, as it allows creation of DDL SQL from the model. Turn in 1 Workbench file , 1 document with the forward-engineered sql statements, and a Word document with your inserted data. This problem mimics the one from the previous assignment. Model it in Workbench, then forward-engineer the database script and import into your database. If the import fails, fix it in the model,...

  • For this set of Review Questions, we will create and use a database for the Wedgewood...

    For this set of Review Questions, we will create and use a database for the Wedgewood Pacific Corporation (WPC) that is similar to the Microsoft Access database we created and used in Chapters 1 and 2. Founded in 1957 in Seattle, Washington, WPC has grown into an internationally recognized organization. The company is located in two buildings. One building houses the Administration, Accounting, Finance, and Human Resources departments, and the second houses the Production, Marketing, and Information Systems departments. The...

  • Your team of consultants has been hired to create a database for MD Employment Agency (MDEA)....

    Your team of consultants has been hired to create a database for MD Employment Agency (MDEA). MDEA is an employment agency that contracts with the city of Miami, FL to assist displaced workers in finding new career opportunities and to help workers currently collecting unemployment benefits. Up to this point MDEA has been using standalone PCs to handle data entry of new clients and to update their status. The company also has relationships with local government agencies that have openings...

  • SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh...

    SQL: The schema name should be mxxws, where mxx is your MySQL user name. To refresh your memory – here is the schema for that database: Create the rest of the contact management database by writing the statements that do each of the following items below. For each one: (1) execute them on your copy of the database, and (2) write the statements in the space: Statement to create the Contact table (one statement) Statement to create the Employee table...

  • Help with database creation - create a visio ER diagram of the scenerio below.. thanks The...

    Help with database creation - create a visio ER diagram of the scenerio below.. thanks The registrar's office at Weber State University wants you to create a new database to support an future application that will help their department better keep track of the scheduled classes offered each semester, including the specific course sections and lecturers appearing in the schedule, and the students registering for courses according to the published schedule. Courses (think course catalog) may or may not be...

  • Consider the database schema of college database. Students have a major department and take classes where...

    Consider the database schema of college database. Students have a major department and take classes where faculty can be met. Student (cwid int, name, text, age int, majorDept text) Department (name text, chair text) Faculty (name text, deptName text) Enrollment (facName text, studID int) Note that the underlined attributes are primary keys. studID, chair, deptName of Faculty, facName and majorDept of Student are foreign keys to cwid, name of Faculty, name of Department, name of Faculty and also name of...

  • Prepare an entity-relationship (ER) diagram using MySQL Workbench for the user requirements described below. Be sure...

    Prepare an entity-relationship (ER) diagram using MySQL Workbench for the user requirements described below. Be sure that your ER diagram has the following elements: entities; relationships between entities; primary and foreign keys, and other necessary columns for each entity. Global Trading (GT) is a wholesale business that sells a variety of products; its customers are other businesses. Also GT's vendors are other businesses. GT has the following business rules for the database that the company wants you to design: -A...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT