0% found this document useful (0 votes)
3 views2 pages

SQL

The document outlines the creation of five database tables: Customer, Sales_agent, Vehicles, Feature_list, Order, and Order_details. Each table includes various fields with specified data types and constraints, such as primary keys and foreign keys to establish relationships between the tables. This structure is designed to manage customer information, sales agents, vehicle details, features, and orders in a relational database system.

Uploaded by

Oanh Vo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

SQL

The document outlines the creation of five database tables: Customer, Sales_agent, Vehicles, Feature_list, Order, and Order_details. Each table includes various fields with specified data types and constraints, such as primary keys and foreign keys to establish relationships between the tables. This structure is designed to manage customer information, sales agents, vehicle details, features, and orders in a relational database system.

Uploaded by

Oanh Vo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE TABLE Customer

(
First_name VARCHAR(50) NOT NULL,
Last_name VARCHAR(50) NOT NULL,
Gender VARCHAR(50) NOT NULL,
Age INT NOT NULL,
Street VARCHAR(100) NOT NULL,
Suburb VARCHAR(50) NOT NULL,
State VARCHAR(50) NOT NULL,
Post_code VARCHAR(50) NOT NULL,
Customer_ID INT NOT NULL,
Phone_number VARCHAR(50) NOT NULL,
Email VARCHAR(100) NOT NULL,
PRIMARY KEY (Customer_ID)
);

CREATE TABLE Sales_agent


(
First_name VARCHAR(50) NOT NULL,
Last_name VARCHAR(50) NOT NULL,
Job_title VARCHAR(50) NOT NULL,
Email VARCHAR(50) NOT NULL,
Sales_agent_ID INT NOT NULL,
Phone_number VARCHAR(50) NOT NULL,
PRIMARY KEY (Sales_agent_ID)
);

CREATE TABLE Vehicles


(
Vehicle_ID INT NOT NULL,
Vehicle_name VARCHAR(50) NOT NULL,
Manufacturer VARCHAR(50) NOT NULL,
Country_of_origin VARCHAR(50) NOT NULL,
Year yyyy NOT NULL,
Price_paid_by_dealer INT NOT NULL,
Date_entered_to_dealer DATE NOT NULL,
Body_type VARCHAR(50) NOT NULL,
Fuel_type VARCHAR(50) NOT NULL,
Engine_cylinders VARCHAR(50) NOT NULL,
Wheel_system VARCHAR(50) NOT NULL,
PRIMARY KEY (Vehicle_ID)
);

CREATE TABLE Feature_list


(
Electric Binary NOT NULL,
Automatic__transition Binary NOT NULL,
Keyless Binary NOT NULL,
Airbag Binary NOT NULL,
ABS Binary NOT NULL,
Cruise_control Binary NOT NULL,
MP4_player Binary NOT NULL,
Leader_seats Binary NOT NULL,
Remote_start Binary NOT NULL,
Bluetooth_system Binary NOT NULL,
Auto_drive Binary NOT NULL,
Parking_sensors Binary NOT NULL,
Rear_camera Binary NOT NULL,
Lane_keeping__assist Binary NOT NULL,
Customer_ID INT,
Vehicle_ID INT NOT NULL,
FOREIGN KEY (Customer_ID) REFERENCES Customer(Customer_ID),
FOREIGN KEY (Vehicle_ID) REFERENCES Vehicles(Vehicle_ID)
);

CREATE TABLE Order


(
Order_ID INT NOT NULL,
Transaction_date DATE NOT NULL,
Payment_type VARCHAR(50) NOT NULL,
Customer_ID INT NOT NULL,
Sales_agent_ID INT NOT NULL,
PRIMARY KEY (Order_ID),
FOREIGN KEY (Customer_ID) REFERENCES Customer(Customer_ID),
FOREIGN KEY (Sales_agent_ID) REFERENCES Sales_agent(Sales_agent_ID)
);

CREATE TABLE Order_details


(
Price INT NOT NULL,
Quantity INT NOT NULL,
Discount INT NOT NULL,
Order_ID INT NOT NULL,
Vehicle_ID INT NOT NULL,
PRIMARY KEY (Order_ID, Vehicle_ID),
FOREIGN KEY (Order_ID) REFERENCES Order(Order_ID),
FOREIGN KEY (Vehicle_ID) REFERENCES Vehicles(Vehicle_ID)
);

You might also like