Skip to content

benhamouche.solved lab #370

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 1 commit 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 ERD.mwb
Binary file not shown.
Binary file added ERD_LAB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
CREATE DATABASE IF NOT EXISTS lab_mysql;
USE lab_mysql;

DROP TABLE IF EXISTS Cars;
CREATE TABLE Cars (
id INT AUTO_INCREMENT UNIQUE KEY,
vin VARCHAR(40) PRIMARY KEY,
manufacturer VARCHAR(50) NOT NULL,
model VARCHAR(50) NOT NULL,
year YEAR NOT NULL,
color VARCHAR(45)
);

DROP TABLE IF EXISTS Customers;
CREATE TABLE Customers (
id INT AUTO_INCREMENT UNIQUE KEY,
cust_id INT PRIMARY KEY,
cust_name VARCHAR(45) NOT NULL,
cust_phone VARCHAR(20),
cust_email VARCHAR(20),
cust_address VARCHAR(45),
cust_city VARCHAR(45),
cust_state VARCHAR(45),
cust_count VARCHAR(45),
cust_zipcode INT
);

DROP TABLE IF EXISTS Salespersons;
CREATE TABLE Salespersons (
id INT AUTO_INCREMENT UNIQUE KEY,
staff_id VARCHAR(10) PRIMARY KEY,
name VARCHAR(45) NOT NULL,
store VARCHAR(45) NOT NULL
);


DROP TABLE IF EXISTS Invoices;
CREATE TABLE Invoices (
id INT AUTO_INCREMENT UNIQUE KEY,
invoice_number INT PRIMARY KEY,
date DATE NOT NULL,
vin VARCHAR(40) ,
cust_id INT NOT NULL,
staff_id VARCHAR(10) NOT NULL,
FOREIGN KEY (vin) REFERENCES Cars(vin),
FOREIGN KEY (cust_id) REFERENCES Customers(cust_id),
FOREIGN KEY (staff_id) REFERENCES Salespersons(staff_id)
);


Empty file added delete.sql
Empty file.
9 changes: 9 additions & 0 deletions seeding.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SET SQL_SAFE_UPDATES = 0;
DELETE FROM customers;
INSERT INTO customers (cust_id, cust_name,cust_phone,cust_email,cust_address,cust_city,cust_state,cust_count,cust_zipcode)
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 customers;

INSERT FROM
Empty file added update.sql
Empty file.