Skip to content
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

[lab-mysql] Alvaro Gracio #144

Open
wants to merge 1 commit into
base: master
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 your-code/DIAGRAM.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions your-code/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
CREATE DATABASE lab_mysql;

USE lab_mysql;


CREATE TABLE Cars (
ID INT NOT NULL PRIMARY KEY,
VIN VARCHAR(17) NOT NULL,
Manufacturer VARCHAR(50) NOT NULL,
Model VARCHAR(50) NOT NULL,
Year INT NOT NULL,
Color VARCHAR(50) NOT NULL
);


CREATE TABLE Customers (
ID INT NOT NULL PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
Phone VARCHAR(20),
Email VARCHAR(100),
Address VARCHAR(100),
City VARCHAR(50),
StateProvince VARCHAR(50),
Country VARCHAR(50),
PostalCode VARCHAR(20)
);

CREATE TABLE Salespersons (
ID INT NOT NULL PRIMARY KEY,
Name VARCHAR(100) NOT NULL,
Store VARCHAR(100) NOT NULL
);

CREATE TABLE Invoices (
ID INT NOT NULL PRIMARY KEY,
InvoiceNumber VARCHAR(20) NOT NULL,
InvoiceDate DATE NOT NULL,
CarID INT UNSIGNED NOT NULL,
CustomerID INT UNSIGNED NOT NULL,
SalespersonID INT UNSIGNED NOT NULL,
FOREIGN KEY (CarID) REFERENCES Cars(ID),
FOREIGN KEY (CustomerID) REFERENCES Customers(ID),
FOREIGN KEY (SalespersonID) REFERENCES Salespersons(ID)
);

33 changes: 33 additions & 0 deletions your-code/seeding.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
INSERT INTO cars (id, vin, manufacturer, model, 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');



INSERT INTO customers (id, name, phone, email, address, city, stateprovince, country, postalcode) 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);

INSERT INTO salespersons (id, name, store) VALUES
('00001', 'Petey Cruiser', 'Madrid'),
('00002', 'Anna Sthesia', 'Barcelona'),
('00003', 'Paul Molive', 'Berlin'),
('00004', 'Gail Forcewind', 'Paris'),
('00005', 'Paige Turner', 'Miami'),
('00006', 'Bob Frapples', 'Mexico City'),
('00007', 'Walter Melon', 'Amsterdam'),
('00008', 'Shonda Leer', 'São Paulo');

INSERT INTO Invoices (ID, InvoiceNumber, InvoiceDate, CarID, CustomerID, SalespersonID)
VALUES (0, '852399038', '2018-08-22', 0, 20001, 3);

INSERT INTO Invoices (ID, InvoiceNumber, InvoiceDate, CarID, CustomerID, SalespersonID)
VALUES (1, '731166526', '2018-12-31', 3, 10001, 5);

INSERT INTO Invoices (ID, InvoiceNumber, InvoiceDate, CarID, CustomerID, SalespersonID)
VALUES (2, '271135104', '2019-01-22', 2, 30001, 7);