Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions your-code/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 1 Challenge
#Cars
#Car_ID (auto-increment numeric ID)
#VIN (string)
#Manufacturer (string)
#Model (string)
#Year (integer)
#Color (string)
#Customers
#Customer_ID (auto-increment numeric ID)
#Name (string)
#Phone (string)
#Email (string)
#Address (string)
#City (string)
#State_Province (string)
#Country (string)
#Zip_Postal_Code (string)
#Salespersons
#Staff_ID (auto-increment numeric ID)
#Name (string)
#Store (string)
#Invoices
#Invoice_ID (auto-increment numeric ID)
#Date (date)
#Car_ID (foreign key referencing Cars.Car_ID)
#Customer_ID (foreign key referencing Customers.Customer_ID)
#Staff_ID (foreign key referencing Salespersons.Staff_ID)

# Cars and Customers have a many-to-many relationship through Invoices.
#Cars and Salespersons have a one-to-many relationship through Invoices.
#Customers and Salespersons have a one-to-many relationship through Invoices.




Binary file added your-code/diagram.mwb
Binary file not shown.
42 changes: 42 additions & 0 deletions your-code/update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#Challenge 2

CREATE DATABASE car_dealership;

CREATE TABLE cars (
id INT AUTO_INCREMENT PRIMARY KEY,
vin VARCHAR(17) NOT NULL,
manufacturer VARCHAR(50) NOT NULL,
model VARCHAR(50) NOT NULL,
year INT NOT NULL,
color VARCHAR(50) NOT NULL
);

CREATE TABLE customers (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
phone VARCHAR(20) NOT NULL,
email VARCHAR(100) NOT NULL,
address VARCHAR(100) NOT NULL,
city VARCHAR(50) NOT NULL,
state_province VARCHAR(50) NOT NULL,
country VARCHAR(50) NOT NULL,
zip_code VARCHAR(20) NOT NULL
);

CREATE TABLE salespersons (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50) NOT NULL,
store VARCHAR(50) NOT NULL
);

CREATE TABLE invoices (
id INT AUTO_INCREMENT PRIMARY KEY,
invoice_number INT NOT NULL,
date DATE NOT NULL,
car_id INT NOT NULL,
customer_id INT NOT NULL,
salesperson_id INT NOT NULL,
FOREIGN KEY (car_id) REFERENCES cars(id),
FOREIGN KEY (customer_id) REFERENCES customers(id),
FOREIGN KEY (salesperson_id) REFERENCES salespersons(id)
);