diff --git a/README.md b/README.md index 7681e0d..c177bb5 100755 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Use pen and paper to create the design, take a picture with your phone and send 1. **Then following the `USE` statement, write all your `CREATE TABLE` statements.** You'll need one `CREATE TABLE` statement for each table you decide to create. Make sure to end each statement with a semicolon. -This `.sql` file will be one of your deliverables. A `.sql` file is often used by software/data engineers to automate database operations. For example, to execute all the commands in the `create.sql` file, you can simply execute `source create.sql;` in MySQL command line. Many programming languages such as Python and PHP can also execute `.sql` files. +This `.sql` file will be one of your deliverables. A `.sql` file is often used by software/data engineers to automate database operationzs. For example, to execute all the commands in the `create.sql` file, you can simply execute `source create.sql;` in MySQL command line. Many programming languages such as Python and PHP can also execute `.sql` files. ## Challenge 3 - Seeding the Database diff --git a/your-code/ERD_Lab8.png b/your-code/ERD_Lab8.png new file mode 100644 index 0000000..eb93209 Binary files /dev/null and b/your-code/ERD_Lab8.png differ diff --git a/your-code/Lab8_results.txt b/your-code/Lab8_results.txt new file mode 100644 index 0000000..e69de29 diff --git a/your-code/challenges_lab8.sql b/your-code/challenges_lab8.sql new file mode 100644 index 0000000..792ece5 --- /dev/null +++ b/your-code/challenges_lab8.sql @@ -0,0 +1,45 @@ +CREATE DATABASE lab8; + +CREATE TABLE Cars ( +index_id BIGINT , +VIN BIGINT NOT NULL, +manufacturer VARCHAR(64) NOT NULL, +model VARCHAR(64), +year_model DATE, +colour VARCHAR(64), +PRIMARY KEY (VIN) +); + +CREATE TABLE Salesperson ( +Staff_ID BIGINT , +Salesman_name VARCHAR(64), +Store VARCHAR(64), +Sales_person_Index BIGINT, +PRIMARY KEY (Staff_ID) +); + +CREATE TABLE Costumers ( +costumer_index BIGINT , +costumer_ID BIGINT NOT NULL, +costumer_name VARCHAR(64) NOT NULL, +phone_number BIGINT, +email VARCHAR(64), +address VARCHAR(64), +city VARCHAR(64), +state VARCHAR(64), +country VARCHAR(64), +zip_code VARCHAR(64), +PRIMARY KEY (costumer_ID) +); + +CREATE TABLE Invoices ( +invoice_index BIGINT , +invoice_number BIGINT NOT NULL, +date_invoice DATE, +VIN BIGINT, +car VARCHAR(64), +costumer_ID BIGINT, +staff_ID BIGINT, +PRIMARY KEY (invoice_number) +); + diff --git a/your-code/create.sql b/your-code/create.sql index e69de29..b285b4c 100644 --- a/your-code/create.sql +++ b/your-code/create.sql @@ -0,0 +1,46 @@ +CREATE DATABASE lab8; + +CREATE TABLE lab8.Cars ( +index_id BIGINT , +VIN BIGINT NOT NULL, +manufacturer VARCHAR(64) NOT NULL, +model VARCHAR(64), +year_model DATE, +colour VARCHAR(64), +PRIMARY KEY (VIN) +); + +CREATE TABLE lab8.Salesperson ( +sales_index BIGINT , +Salesman_ID VARCHAR(64), +Salesman_name VARCHAR(64), +Store VARCHAR(64), +PRIMARY KEY (Salesman_ID) +); + + +CREATE TABLE lab8.Costumers ( +costumer_index BIGINT , +costumer_ID BIGINT NOT NULL, +costumer_name VARCHAR(64) NOT NULL, +phone_number BIGINT, +email VARCHAR(64), +address VARCHAR(64), +city VARCHAR(64), +state VARCHAR(64), +country VARCHAR(64), +zip_code VARCHAR(64), +PRIMARY KEY (costumer_ID) +); + +CREATE TABLE lab8.Invoices ( +invoice_index BIGINT , +invoice_number BIGINT NOT NULL, +date_invoice VARCHAR(64), +car VARCHAR(64), +costumer_ID BIGINT, +staff_ID BIGINT, +PRIMARY KEY (invoice_number) +); + + diff --git a/your-code/seeding.sql b/your-code/seeding.sql index e69de29..2649fb1 100644 --- a/your-code/seeding.sql +++ b/your-code/seeding.sql @@ -0,0 +1,31 @@ + +insert into lab8.Cars(index_id, VIN, manufacturer, model, year_model, colour) +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 lab8.costumers(costumer_index, costumer_id, costumer_name, phone_number, address, city, state, country, zip_code) +values (0, 10001, "Pablo Picasso", "34636176382", "Paseo de la Chopera, 14", "Madrid", "Madrid", "Spain", 28045), +(1, 20001, "Abraham Lincoln", "13059077086", "120 SW 8th St", "Miami", "Florida", "United States", 33130), +(2, 30001, "Napoléon Bonaparte", "33179754000", "40 Rue du Colisée", "Paris", "Île-de-France", "France", "75008"); +/* the phone number i put as srt because one of the values have more than ten so given error out of range*/ + + +insert into lab8.salesperson(sales_index, Salesman_ID, Salesman_name, Store) +values (0, 00001, "Petey Cruiser", "Madrid"), +(1, 00002, "Anna Sthesia", "Barcelona"), +(2, 00003, "Paul Molive", "Berlin"), +(3, 00004, "Gail Forcewind", "Paris"), +(4, 00005, "Paige Turner", "Mimia"), +(5, 00006, "Bob Frapples", "Mexico City"), +(6, 00007, "Walter Melon", "Amsterdam"), +(7, 00008, "Shonda Leer", "São Paulo"); + + +insert into lab8.invoices(invoice_index,invoice_number, date_invoice, car, costumer_ID, staff_ID) +value(0, 852399038, "22-08-2018", 0, 1, 3), +(1, 731166526, "31-12-2018", 3, 0, 5), +(2, 271135104, "22-01-2019", 2, 2, 7);