diff --git a/your-code/create.sql b/your-code/create.sql index e69de29..734f0b7 100644 --- a/your-code/create.sql +++ b/your-code/create.sql @@ -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. + + + + diff --git a/your-code/diagram.mwb b/your-code/diagram.mwb new file mode 100644 index 0000000..3e67c26 Binary files /dev/null and b/your-code/diagram.mwb differ diff --git a/your-code/update.sql b/your-code/update.sql index e69de29..7b52022 100644 --- a/your-code/update.sql +++ b/your-code/update.sql @@ -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) +); \ No newline at end of file