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
Binary file added ER diagram.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ER diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions Update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DESCRIBE Cars;
SELECT * FROM customers;
update Customers
set name= 'Pablo Picasso',
email = '[email protected]'
where id = 1;
update Customers
set name= 'Abraham Lincoln',
email = '[email protected]'
where id = 2;
update Customers
set name= 'Napoléon Bonaparte',
email = '[email protected]'
where id = 3;
48 changes: 48 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
@@ -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;





4 changes: 4 additions & 0 deletions delete.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
select * from customers;
delete from cars
where id = 6 and vin= 'DAM41UDN3CHU2WVF6';
select * from cars;
41 changes: 41 additions & 0 deletions seeding.sql
Original file line number Diff line number Diff line change
@@ -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;