diff --git a/your-code/DIAGRAM.jpg b/your-code/DIAGRAM.jpg new file mode 100644 index 0000000..aedb878 Binary files /dev/null and b/your-code/DIAGRAM.jpg differ diff --git a/your-code/create.sql b/your-code/create.sql index e69de29..78c68fc 100644 --- a/your-code/create.sql +++ b/your-code/create.sql @@ -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) +); + diff --git a/your-code/seeding.sql b/your-code/seeding.sql index e69de29..2890cce 100644 --- a/your-code/seeding.sql +++ b/your-code/seeding.sql @@ -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);