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
43 changes: 43 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
USE carsales;

CREATE TABLE cars (
Id INT NOT NULL AUTO_INCREMENT,
Vin VARCHAR(255) NOT NULL,
Manufacturer VARCHAR(255) NOT NULL,
MakeYear Year NOT NULL,
Color VARCHAR(255) NOT NULL,
PRIMARY KEY (ID)
);

CREATE TABLE salespersons (
Id INT NOT NULL AUTO_INCREMENT,
SalesPersonId VARCHAR(255) NOT NULL,
SalesPersonName VARCHAR(255) NOT NULL,
Store VARCHAR(255) NOT NULL,
PRIMARY KEY (ID)
);

CREATE TABLE customers (
Id INT NOT NULL AUTO_INCREMENT,
CustomerId VARCHAR(255) NOT NULL,
CustomerName VARCHAR(255) NOT NULL,
Phone VARCHAR(255) NOT NULL,
Email VARCHAR(255),
Address VARCHAR(255) NOT NULL,
City VARCHAR(255),
State_Province VARCHAR(255),
ZipCode VARCHAR(255) NOT NULL,
PRIMARY KEY (ID)
);

CREATE TABLE invoices (
Id INT NOT NULL AUTO_INCREMENT,
InvoiceDate DATE NOT NULL,
CarId INT NOT NULL,
CustomerId INT NOT NULL,
SalesPersonId INT NOT NULL,
PRIMARY KEY (ID),
FOREIGN KEY (CarId) REFERENCES cars(Id),
FOREIGN KEY (CustomerId) REFERENCES customers(Id),
FOREIGN KEY (SalesPersonId) REFERENCES salespersons(Id)
);
3 changes: 3 additions & 0 deletions delete.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USE carsales;

DELETE FROM cars WHERE Id = 5;
Binary file added mysql.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions seeding.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
USE carsales;

INSERT INTO cars (Vin, Manufacturer, Model, MakeYear, 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");

INSERT INTO customers (CustomerId, CustomerName, Phone, Email, Address, City, State_Province, ZipCode, Country)
VALUES("10001", "Pablo Picasso", "+34 636 17 63 82", NULL, "Paseo de la Chopera, 14", "Madrid", "Madrid", "28045", "Spain"),
("20001", "Abraham Lincoln", "+1 305 907 7086", NULL, "120 SW 8th St", "Miami", "Florida", "33130", "United States"),
("30001", "Napoléon Bonaparte", "+33 1 79 75 40 00", NULL, "40 Rue du Colisée", "Paris", "Île-de-France", "75008", "France");

INSERT INTO salespersons (SalesPersonId, SalesPersonName, 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");

INSERT INTO invoices (InvoiceId, InvoiceDate, CarId, CustomerId, SalesPersonId)
VALUES("852399038", "2018-08-22", 1, 1, 3),
("731166526", "2018-12-31", 3, 1, 5),
("271135104", "2019-01-22", 2, 2, 7);

17 changes: 17 additions & 0 deletions update.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
USE carsales;

UPDATE salespersons
SET Store = "Miami"
WHERE ID = 5;

UPDATE customers
SET Email = "ppicasso@gmail.com"
WHERE CustomerName = "Pablo Picasso" and Id = 1;

UPDATE customers
SET Email = "lincoln@us.gov"
WHERE CustomerName = "Abraham Lincoln" and ID = 2;

UPDATE customers
SET Email = "hello@napoleon.me"
WHERE CustomerName = "Napoleón Bonaparte" and ID = 3;