diff --git a/your-code/create.sql b/your-code/create.sql index e69de29..232cec1 100644 --- a/your-code/create.sql +++ b/your-code/create.sql @@ -0,0 +1,39 @@ +/* Challenge 2 */ + +/* Creating the database */ + +CREATE DATABASE IF NOT EXISTS lab_mysql; + +/* Using it */ + +USE lab_mysql; + +CREATE TABLE IF NOT EXISTS lab_mysql.cars (ID INT PRIMARY KEY, + VIN VARCHAR (30), + Manufacturer VARCHAR (30), + Model VARCHAR (30), + Car_year INT NOT NULL, + Color VARCHAR (30)); + +CREATE TABLE IF NOT EXISTS lab_mysql.costumers (ID INT PRIMARY KEY, + Customer_ID INT NOT NULL, + Customer_Name VARCHAR (30), + Phone VARCHAR (30), + Email VARCHAR (30), + Address VARCHAR (30), + City VARCHAR (30), + State_Province VARCHAR (30), + Country VARCHAR (30), + Postal INT NOT NULL); + +CREATE TABLE IF NOT EXISTS lab_mysql.salespersons (ID INT PRIMARY KEY, + Staff_ID INT NOT NULL, + Name VARCHAR (30), + Store VARCHAR (30)); + +CREATE TABLE IF NOT EXISTS lab_mysql.invoices (ID INT PRIMARY KEY, + Invoice_Number INT NOT NULL, + Date DATE, + Car INT, + Customer INT, + Sales_Person INT); \ No newline at end of file diff --git a/your-code/delete.sql b/your-code/delete.sql index e69de29..5491988 100644 --- a/your-code/delete.sql +++ b/your-code/delete.sql @@ -0,0 +1,6 @@ +/* Bonus Challenge 2 */ + +/* Duplicate Deletion */ + +DELETE FROM lab_mysql.cars +WHERE ID = 4; \ No newline at end of file diff --git a/your-code/probably_wrong_ERD.HEIC b/your-code/probably_wrong_ERD.HEIC new file mode 100644 index 0000000..af21f6a Binary files /dev/null and b/your-code/probably_wrong_ERD.HEIC differ diff --git a/your-code/seeding.sql b/your-code/seeding.sql index e69de29..97dec75 100644 --- a/your-code/seeding.sql +++ b/your-code/seeding.sql @@ -0,0 +1,45 @@ +/* Challenge 3 */ + +/* Seeding cars */ +INSERT INTO lab_mysql.cars(id, VIN, Manufacturer, Model, Car_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 costumers */ +INSERT INTO lab_mysql.costumers(id, Customer_ID, Customer_Name, Phone, Email, Address, City, State_Province, Country, Postal) +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 salespersons */ +INSERT INTO lab_mysql.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 Finvoicesrapples', 'Mexico City'), +(6,00007 , 'Walter Melon', 'Amsterdam'), +(7,00008 , 'Shonda Leer', 'São Paulo'); + +/* Seeding invoices */ +INSERT INTO lab_mysql.invoices(ID, Invoice_number, Date, Car, Customer, Sales_Person) +VALUES(0, 852399038 , 20180222 , 0 , 1 , 3), +(1, 731166526 , 20181231 , 3 , 0 , 5), +(2, 271135104 , 20190122 , 2 , 2 , 7); + +SELECT * +FROM cars; + +SELECT * +FROM costumers; + +SELECT * +FROM salespersons; + +SELECT * +FROM invoices; diff --git a/your-code/update.sql b/your-code/update.sql index e69de29..be18812 100644 --- a/your-code/update.sql +++ b/your-code/update.sql @@ -0,0 +1,19 @@ +/* Bonus Challenge */ + +/* Updating Database Records */ + +UPDATE lab_mysql.salespersons +SET store = 'Miami' +WHERE id = 4; + +UPDATE lab_mysql.costumers +SET email = 'ppicasso@gmail.com' +WHERE id = 0; + +UPDATE lab_mysql.costumers +SET email = 'lincoln@us.gov' +WHERE id = 1; + +UPDATE lab_mysql.costumers +SET email = 'hello@napoleon.me' +WHERE id = 2; \ No newline at end of file