diff --git a/ER diagram.jpeg b/ER diagram.jpeg new file mode 100644 index 0000000..b9e6634 Binary files /dev/null and b/ER diagram.jpeg differ diff --git a/ER diagram.png b/ER diagram.png new file mode 100644 index 0000000..80a7e38 Binary files /dev/null and b/ER diagram.png differ diff --git a/Update.sql b/Update.sql new file mode 100644 index 0000000..96eb99d --- /dev/null +++ b/Update.sql @@ -0,0 +1,14 @@ +DESCRIBE Cars; +SELECT * FROM customers; +update Customers +set name= 'Pablo Picasso', +email = 'ppicasso@gmail.com' +where id = 1; +update Customers +set name= 'Abraham Lincoln', +email = 'lincoln@us.gov' +where id = 2; +update Customers +set name= 'Napoléon Bonaparte', +email = 'hello@napoleon.me' +where id = 3; \ No newline at end of file diff --git a/create.sql b/create.sql new file mode 100644 index 0000000..18049af --- /dev/null +++ b/create.sql @@ -0,0 +1,48 @@ +CREATE DATABASE IF NOT EXISTS lab_mysql; +USE lab_mysql; + +CREATE TABLE Cars ( +id int auto_increment primary key, +VIN VARCHAR(20), +manufacturer VARCHAR(20), +model VARCHAR(20), +year year, +color varchar (20)); + +Create Table Customers ( +id int auto_increment primary key, +Cust_ID int, +name varchar(20), +phone varchar(20), +email varchar(20), +address varchar(40), +city varchar(20), +state_province varchar(20), +country varchar(20), +zip_postal_code int); + +create table Salespersons ( +id int auto_increment primary key, +Staff_ID int, +name varchar(20), +store varchar(20)); + +create table Invoice ( +id int auto_increment primary key, +invoice_number varchar(20), +invoice_date date, +car int, +customer int, +salesperson int, +constraint fk_car foreign key (car) references Cars(id), +constraint fk_customer foreign key (customer) references Customers(id), +constraint fk_salesperson foreign key (salesperson) references Salespersons(id)); + +-- drop database lab_mysql; +-- SELECT DATABASE(); +-- SHOW TABLES; + + + + + diff --git a/delete.sql b/delete.sql new file mode 100644 index 0000000..a323bd7 --- /dev/null +++ b/delete.sql @@ -0,0 +1,4 @@ +select * from customers; +delete from cars +where id = 6 and vin= 'DAM41UDN3CHU2WVF6'; +select * from cars; \ No newline at end of file diff --git a/seeding.sql b/seeding.sql new file mode 100644 index 0000000..71d8802 --- /dev/null +++ b/seeding.sql @@ -0,0 +1,41 @@ +INSERT INTO Cars (VIN, manufacturer, model, year, color) +VALUES ( '3K096I98581DHSNUP', 'Volkswagen', 'Tiguan', 2019, 'Blue'), + ( 'ZM8G7BEUQZ97IH46V', 'Peugeot', 'Rifter', 2019, 'Red'), + ( 'RKXVNNIHLVVZOUB4M', 'Ford', 'Fusion', 2018, 'White'), + ( 'HKNDGS7CU31E9Z7JW', 'Toyota', 'RAV4', 2018, 'Silver'), + ( 'DAM41UDN3CHU2WVF6', 'Volvo', 'V60', 2019, 'Gray'), + ( 'DAM41UDN3CHU2WVF6', 'Volvo', 'V60 Cross Country', 2019, 'Gray'); + +SELECT * FROM lab_mysql.Cars; + +INSERT INTO Customers (cust_id, name, phone, email, address, city, state_province, country, zip_postal_code) +Values (10001, 'Pablo Picasso', '+34 636 17 63 82','-', 'Paseo de la Chopera, 14', 'Madrid', 'Madrid', 'Spain',28045), + (20001, 'Abraham Lincoln', '+1 305 907 7086', '-', '120 SW 8th St', 'Miami','Florida','United States',33130), + (30001, 'Napoléon Bonaparte', '+33 1 79 75 40 00', '-', '40 Rue du Colisée', 'Paris', 'Île-de-France', 'France', 75008); + +select * from lab_mysql.Customers; + +Insert into Salespersons ( Staff_ID, name, store) +values ( 00001, 'Petey Cruiser', 'Madrid'), + ( 00002, 'Anna Sthesia', 'Barcelona'), + ( 00003, 'Paul Molive', 'Berlin'), + ( 00004, 'Gail Forcewind', 'Paris'), + ( 00005, 'Paige Turner', 'Mimia'), + ( 00006, 'Bob Frapples', 'Mexico City'), + ( 00007, 'Walter Melon', 'Amsterdam'), + ( 00008, 'Shonda Leer', 'São Paulo'); + +select * from lab_mysql.Salespersons; + +Insert into Invoice ( invoice_number, invoice_date, car, customer, salesperson) + values ( '852399038', '2018-08-22',1, 1, 3), + ( '731166526', '2018-12-31',3, 3, 5), + ( '271135104', '2019-01-22',2, 2, 7); + +select * from lab_mysql.Invoice; + + + + + +