Skip to content

Add files via upload #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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 E_Rcars.drawio.pdf
Binary file not shown.
49 changes: 49 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
CREATE DATABASE IF NOT EXISTS lab_mysql;

USE lab_mysql;

DROP TABLE IF EXISTS car;
CREATE TABLE car (
car_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
vin VARCHAR(30) UNIQUE NOT NULL,
manufacture VARCHAR(30) NOT NULL,
model VARCHAR(20) NOT NULL,
color VARCHAR(20) NOT NULL,
year YEAR NOT NULL);

DROP TABLES IF EXISTS customer;
CREATE TABLE customer (
customer_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR (30) NOT NULL,
email VARCHAR(30) NOT NULL,
phone VARCHAR(20)NOT NULL,
address VARCHAR(20) NOT NULL,
city VARCHAR(20) NOT NULL,
state VARCHAR(20) NOT NULL,
country VARCHAR(10)NOT NULL,
zip_code VARCHAR(20)NOT NULL);

DROP TABLES IF EXISTS salesperson;
CREATE TABLE salesperson (
salesperson_id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
name VARCHAR(20) NOT NULL,
email VARCHAR(30)NOT NULL,
store VARCHAR(30) NOT NULL);

DROP TABLES IF EXISTS invoice;
CREATE TABLE invoice (
invoice_id INT AUTO_INCREMENT PRIMARY KEY,
car_id INT NOT NULL,
customer_id INT NOT NULL,
salesperson_id INT NOT NULL,
date_of_invoice DATE NOT NULL,

FOREIGN KEY (car_id) REFERENCES car(id),
FOREIGN KEY (customer_id) REFERENCES customer(id),
FOREIGN KEY (salesperson_id) REFERENCES salesperson(id)
);

DESCRIBE customer



4 changes: 4 additions & 0 deletions delete.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SET SQL_SAFE_UPDATES = 0;
DELETE FROM car
WHERE car_id = 4;
SET SQL_SAFE_UPDATES = 1;
32 changes: 32 additions & 0 deletions seeding.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
INSERT INTO car (car_id, vin, manufacture, model, year, color)
VALUES
(1, '3K096I98581DHSNUP','Volkswagen', 'Tiguan', 2019, 'Blue'),
(2, 'ZM8G7BEUQZ97IH46V', 'Peugeot', 'Rifter', 2019, 'Red'),
(3, 'RKXVNNIHLVVZOUB4M', 'Ford', 'Fusion', 2018, 'White'),
(4, 'HKNDGS7CU31E9Z7JW', 'Toyota', 'RAV4', 2018, 'Silver'),
(5, 'DAM41UDN3CHU2WVF6', 'Volvo', 'V60', 2019, 'Gray'),
(6, 'DAM41UDN3CHU2WVF8', 'Volvo', 'V60 Cross Country', 2019, 'Gray');

INSERT INTO customer (customer_id, name, phone, email, address, city, state, country, zip_code)
VALUES
(10001, 'Kurt Cobain', '+41 543 789 7865', '-', 'Paseo de la Chopera, 14', 'Madrid', 'Madrid', 'Spain', '28045'),
(10002, 'Abraham Lincoln', '+1 305 907 7086', '-', '120 SW 8th St', 'Miami', 'Florida', 'United States', '33130'),
(10003, 'Napoléon Bonaparte', '+33 1 79 75 40 00', '-', '40 Rue du Colisée', 'Paris', 'Île-de-France', 'France', '75008');
(10004
INSERT INTO salesperson (salesperson_id, name, email, store)
VALUES
('1', 'Petey Cruiser', '-', 'Madrid'),
('2', 'Anna Sthesia', '-', 'Barcelona'),
('3', 'Paul Molive', '-', 'Berlin'),
('4', 'Gail Forcewind', '-', 'Paris'),
('5', 'Paige Turner', '-', 'Mimia'),
('6', 'Bob Frapples', '-', 'Mexico City'),
('7', 'Walter Melon', '-', 'Amsterdam'),
('8', 'Shonda Leer', '-', 'São Paulo');

INSERT INTO invoice (invoice_number,car_id,customer_id,salesperson_id,date_of_invoice)
VALUES
(1, 1, 10001, '1', '2018-08-22'),
(3, 2, 10002, '2', '2018-12-31'),
(2, 3, 10003, '3', '2019-01-22');

15 changes: 15 additions & 0 deletions updates.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
SET SQL_SAFE_UPDATES = 0;
UPDATE customer
SET email = '[email protected]'
WHERE name = 'Pablo Picasso';

UPDATE customer
SET email = '[email protected]'
WHERE name = 'Abraham Lincoln';

UPDATE customer
SET email = '[email protected]'
WHERE name = 'Napoléon Bonaparte';

SET SQL_SAFE_UPDATES = 1;