diff --git a/your-code/342413504_697207265739201_3950973650753755013_n.png b/your-code/342413504_697207265739201_3950973650753755013_n.png new file mode 100644 index 0000000..9a6aee3 Binary files /dev/null and b/your-code/342413504_697207265739201_3950973650753755013_n.png differ diff --git a/your-code/create.sql b/your-code/create.sql index e69de29..eda14ae 100644 --- a/your-code/create.sql +++ b/your-code/create.sql @@ -0,0 +1,61 @@ +# Use DATABASE lab_mysql +USE lab_mysql; + +# create table Cars: +CREATE TABLE IF NOT EXISTS Cars ( + ID SMALLINT PRIMARY KEY, + VIN VARCHAR(52) NOT NULL, + Manufacturer VARCHAR(72) NOT NULL, + Model VARCHAR(32) NOT NULL, + Make_year YEAR NOT NULL, + Color VARCHAR(32) NOT NULL); + +# CREATE TABLE Salespersons: +CREATE TABLE IF NOT EXISTS Salespersons( + ID SMALLINT PRIMARY KEY , + Staff_ID VARCHAR(32) NOT NULL, + Name VARCHAR(72) NOT NULL, + Store VARCHAR(72) NOT NULL); + +# Create table Customers: +CREATE TABLE IF NOT EXISTS Customers ( + ID SMALLINT PRIMARY KEY, + Customer_ID INT NOT NULL, + Name VARCHAR(72) NOT NULL, + Phone VARCHAR(52) NOT NULL, + Email VARCHAR(52), + Address VARCHAR(72) NOT NULL, + City VARCHAR(22) NOT NULL, + State VARCHAR(32), + Country VARCHAR(52) NOT NULL, + Postal_code VARCHAR(22) NOT NULL); + +# Create table Invoices: +CREATE TABLE IF NOT EXISTS Invoices ( + ID INT PRIMARY KEY, + Invoice_Number INT NOT NULL, + Date DATE NOT NULL, + Car_id SMALLINT , + Customer_id SMALLINT, + Staff_id SMALLINT); + + +ALTER TABLE Invoices +ADD FOREIGN KEY (Car_id) REFERENCES Cars(ID), +ADD FOREIGN KEY (Customer_id) REFERENCES Customers(ID), +ADD FOREIGN KEY (Staff_id) REFERENCES salespersons(ID); + + +SELECT * FROM lab_mysql.customers; + +SELECT * FROM lab_mysql.salespersons; + +SELECT * FROM lab_mysql.invoices; + +SELECT * FROM lab_mysql.cars; + + + + + + diff --git a/your-code/seeding.sql b/your-code/seeding.sql index e69de29..1c57979 100644 --- a/your-code/seeding.sql +++ b/your-code/seeding.sql @@ -0,0 +1,37 @@ + # Seeding table Cars: + INSERT INTO cars (ID, VIN, Manufacturer, Model, Make_year, Color) + VALUES + (0, '3K096I98581DHSNUP', 'Volkswagen', 'Tiguan', 2019, 'Blue'), + (1, 'ZM8G7BEUQZ97IH46V', 'Peugeot', 'Rifter', 2019, 'Red'), + (2, 'RKXVNNIHLVVZOUB4M', 'Ford', 'Fusion', 2018, 'White'), + (3 ,'HKNDGS7CU31E9Z7JW', 'Toyota', 'RAV4', 2018, 'Silver'), + (4, 'DAM41UDN3CHU2WVF6','Volvo', 'V60', 2019, 'Gray'), + (5, 'DAM41UDN3CHU2WVF6', 'Volvo', 'V60 Cross Country', 2019, 'Gray'); + + +# Seeding table Customers: +INSERT INTO customers (ID, Customer_id, Name, Phone, Address, City, State, COuntry, Postal_code) +VALUES +(0, 10001, 'Pablo Picasso', '+34 636 17 63 82', 'Paseo de la Chopera, 14', 'Madrid', 'Madrid', 'Spain', '28045'), +(1, 20001, 'Abraham Lincoln', '+1 305 907 7086', '120 SW 8th St', 'Miami', 'Florida', 'United States', '33130'), +(2, 30001, 'Napoléon Bonaparte', '+33 1 79 75 40 00', '40 Rue du Colisée', 'Paris', 'Île-de-France', 'France', 75008); + +# Seeding table salespersons: +INSERT INTO salespersons ( ID, Staff_ID, Name, Store) +VALUES + (0, '00001', 'Petey Cruiser', 'Madrid'), + (1, '00002', 'Anna Sthesia', 'Barcelona'), + (2, '00003', 'Paul Molive', 'Berlin'), + (3, '00004', 'Gail Forcewind', 'Paris'), + (4, '00005', 'Paige Turner', 'Mimia'), + (5, '00006', 'Bob Frapples', 'Mexico City'), + (6, '00007', 'Walter Melon', 'Amsterdam'), + (7, '00008', 'Shonda Leer', 'São Paulo'); + +# Seeding in to table invoice: +INSERT INTO invoices (ID, invoice_Number, Date, Car_id, Customer_id, Staff_id) +VALUES + (0, 852399038, '2018-08-22', 0, 1, 3), + (1, 731166526, '2018-12-31', 3, 0, 5), + (2, 271135104, '2019-01-22', 2, 2, 7); +