From 3859ae2e8d0d88ca032948ea453fe91f8280edc9 Mon Sep 17 00:00:00 2001 From: sangeetha Date: Wed, 1 Nov 2023 17:32:25 +0530 Subject: [PATCH 1/2] create migrations --- .../database/insert_into_hr_database.sql | 306 +++++++++--------- lib/sql_ecto/hr/country.ex | 2 +- lib/sql_ecto/hr/department.ex | 3 +- lib/sql_ecto/hr/dependent.ex | 2 +- lib/sql_ecto/hr/employee.ex | 3 +- lib/sql_ecto/hr/job.ex | 2 +- lib/sql_ecto/hr/location.ex | 4 +- lib/sql_ecto/hr/region.ex | 2 +- .../repo/migrations/20231101035925_region.exs | 10 + .../migrations/20231101035926_country.exs | 14 + .../migrations/20231101035927_location.exs | 17 + .../migrations/20231101035928_department.exs | 14 + priv/repo/migrations/20231101035942_job.exs | 12 + .../migrations/20231101035943_employee.exs | 22 ++ .../migrations/20231101035944_dependent.exs | 16 + 15 files changed, 262 insertions(+), 167 deletions(-) create mode 100644 priv/repo/migrations/20231101035925_region.exs create mode 100644 priv/repo/migrations/20231101035926_country.exs create mode 100644 priv/repo/migrations/20231101035927_location.exs create mode 100644 priv/repo/migrations/20231101035928_department.exs create mode 100644 priv/repo/migrations/20231101035942_job.exs create mode 100644 priv/repo/migrations/20231101035943_employee.exs create mode 100644 priv/repo/migrations/20231101035944_dependent.exs diff --git a/lib/sql_ecto/database/insert_into_hr_database.sql b/lib/sql_ecto/database/insert_into_hr_database.sql index 0151edd..092f498 100644 --- a/lib/sql_ecto/database/insert_into_hr_database.sql +++ b/lib/sql_ecto/database/insert_into_hr_database.sql @@ -1,160 +1,148 @@ -/*Data for the table regions */ -INSERT INTO regions(region_id,region_name) VALUES (1,'Europe'); -INSERT INTO regions(region_id,region_name) VALUES (2,'Americas'); -INSERT INTO regions(region_id,region_name) VALUES (3,'Asia'); -INSERT INTO regions(region_id,region_name) VALUES (4,'Middle East and Africa'); - - -/*Data for the table countries */ -INSERT INTO countries(country_id,country_name,region_id) VALUES ('AR','Argentina',2); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('AU','Australia',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('BE','Belgium',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('BR','Brazil',2); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('CA','Canada',2); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('CH','Switzerland',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('CN','China',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('DE','Germany',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('DK','Denmark',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('EG','Egypt',4); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('FR','France',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('HK','HongKong',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('IL','Israel',4); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('IN','India',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('IT','Italy',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('JP','Japan',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('KW','Kuwait',4); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('MX','Mexico',2); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('NG','Nigeria',4); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('NL','Netherlands',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('SG','Singapore',3); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('UK','United Kingdom',1); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('US','United States of America',2); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('ZM','Zambia',4); -INSERT INTO countries(country_id,country_name,region_id) VALUES ('ZW','Zimbabwe',4); - -/*Data for the table locations */ -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1400,'2014 Jabberwocky Rd','26192','Southlake','Texas','US'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1500,'2011 Interiors Blvd','99236','South San Francisco','California','US'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1700,'2004 Charade Rd','98199','Seattle','Washington','US'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1800,'147 Spadina Ave','M5V 2L7','Toronto','Ontario','CA'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2400,'8204 Arthur St',NULL,'London',NULL,'UK'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2500,'Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford','UK'); -INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2700,'Schwanthalerstr. 7031','80925','Munich','Bavaria','DE'); - - -/*Data for the table jobs */ - -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (1,'Public Accountant',4200.00,9000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (2,'Accounting Manager',8200.00,16000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (3,'Administration Assistant',3000.00,6000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (4,'President',20000.00,40000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (5,'Administration Vice President',15000.00,30000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (6,'Accountant',4200.00,9000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (7,'Finance Manager',8200.00,16000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (8,'Human Resources Representative',4000.00,9000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (9,'Programmer',4000.00,10000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (10,'Marketing Manager',9000.00,15000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (11,'Marketing Representative',4000.00,9000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (12,'Public Relations Representative',4500.00,10500.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (13,'Purchasing Clerk',2500.00,5500.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (14,'Purchasing Manager',8000.00,15000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (15,'Sales Manager',10000.00,20000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (16,'Sales Representative',6000.00,12000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (17,'Shipping Clerk',2500.00,5500.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (18,'Stock Clerk',2000.00,5000.00); -INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (19,'Stock Manager',5500.00,8500.00); - - -/*Data for the table departments */ - -INSERT INTO departments(department_id,department_name,location_id) VALUES (1,'Administration',1700); -INSERT INTO departments(department_id,department_name,location_id) VALUES (2,'Marketing',1800); -INSERT INTO departments(department_id,department_name,location_id) VALUES (3,'Purchasing',1700); -INSERT INTO departments(department_id,department_name,location_id) VALUES (4,'Human Resources',2400); -INSERT INTO departments(department_id,department_name,location_id) VALUES (5,'Shipping',1500); -INSERT INTO departments(department_id,department_name,location_id) VALUES (6,'IT',1400); -INSERT INTO departments(department_id,department_name,location_id) VALUES (7,'Public Relations',2700); -INSERT INTO departments(department_id,department_name,location_id) VALUES (8,'Sales',2500); -INSERT INTO departments(department_id,department_name,location_id) VALUES (9,'Executive',1700); -INSERT INTO departments(department_id,department_name,location_id) VALUES (10,'Finance',1700); -INSERT INTO departments(department_id,department_name,location_id) VALUES (11,'Accounting',1700); - - - -/*Data for the table employees */ - -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (100,'Steven','King','steven.king@sqltutorial.org','515.123.4567','1987-06-17',4,24000.00,NULL,9); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (101,'Neena','Kochhar','neena.kochhar@sqltutorial.org','515.123.4568','1989-09-21',5,17000.00,100,9); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (102,'Lex','De Haan','lex.de haan@sqltutorial.org','515.123.4569','1993-01-13',5,17000.00,100,9); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (103,'Alexander','Hunold','alexander.hunold@sqltutorial.org','590.423.4567','1990-01-03',9,9000.00,102,6); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (104,'Bruce','Ernst','bruce.ernst@sqltutorial.org','590.423.4568','1991-05-21',9,6000.00,103,6); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (105,'David','Austin','david.austin@sqltutorial.org','590.423.4569','1997-06-25',9,4800.00,103,6); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (106,'Valli','Pataballa','valli.pataballa@sqltutorial.org','590.423.4560','1998-02-05',9,4800.00,103,6); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (107,'Diana','Lorentz','diana.lorentz@sqltutorial.org','590.423.5567','1999-02-07',9,4200.00,103,6); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (108,'Nancy','Greenberg','nancy.greenberg@sqltutorial.org','515.124.4569','1994-08-17',7,12000.00,101,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (109,'Daniel','Faviet','daniel.faviet@sqltutorial.org','515.124.4169','1994-08-16',6,9000.00,108,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (110,'John','Chen','john.chen@sqltutorial.org','515.124.4269','1997-09-28',6,8200.00,108,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (111,'Ismael','Sciarra','ismael.sciarra@sqltutorial.org','515.124.4369','1997-09-30',6,7700.00,108,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (112,'Jose Manuel','Urman','jose manuel.urman@sqltutorial.org','515.124.4469','1998-03-07',6,7800.00,108,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (113,'Luis','Popp','luis.popp@sqltutorial.org','515.124.4567','1999-12-07',6,6900.00,108,10); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (114,'Den','Raphaely','den.raphaely@sqltutorial.org','515.127.4561','1994-12-07',14,11000.00,100,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (115,'Alexander','Khoo','alexander.khoo@sqltutorial.org','515.127.4562','1995-05-18',13,3100.00,114,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (116,'Shelli','Baida','shelli.baida@sqltutorial.org','515.127.4563','1997-12-24',13,2900.00,114,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (117,'Sigal','Tobias','sigal.tobias@sqltutorial.org','515.127.4564','1997-07-24',13,2800.00,114,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (118,'Guy','Himuro','guy.himuro@sqltutorial.org','515.127.4565','1998-11-15',13,2600.00,114,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (119,'Karen','Colmenares','karen.colmenares@sqltutorial.org','515.127.4566','1999-08-10',13,2500.00,114,3); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (120,'Matthew','Weiss','matthew.weiss@sqltutorial.org','650.123.1234','1996-07-18',19,8000.00,100,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (121,'Adam','Fripp','adam.fripp@sqltutorial.org','650.123.2234','1997-04-10',19,8200.00,100,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (122,'Payam','Kaufling','payam.kaufling@sqltutorial.org','650.123.3234','1995-05-01',19,7900.00,100,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (123,'Shanta','Vollman','shanta.vollman@sqltutorial.org','650.123.4234','1997-10-10',19,6500.00,100,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (126,'Irene','Mikkilineni','irene.mikkilineni@sqltutorial.org','650.124.1224','1998-09-28',18,2700.00,120,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (145,'John','Russell','john.russell@sqltutorial.org',NULL,'1996-10-01',15,14000.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (146,'Karen','Partners','karen.partners@sqltutorial.org',NULL,'1997-01-05',15,13500.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (176,'Jonathon','Taylor','jonathon.taylor@sqltutorial.org',NULL,'1998-03-24',16,8600.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (177,'Jack','Livingston','jack.livingston@sqltutorial.org',NULL,'1998-04-23',16,8400.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (178,'Kimberely','Grant','kimberely.grant@sqltutorial.org',NULL,'1999-05-24',16,7000.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (179,'Charles','Johnson','charles.johnson@sqltutorial.org',NULL,'2000-01-04',16,6200.00,100,8); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (192,'Sarah','Bell','sarah.bell@sqltutorial.org','650.501.1876','1996-02-04',17,4000.00,123,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (193,'Britney','Everett','britney.everett@sqltutorial.org','650.501.2876','1997-03-03',17,3900.00,123,5); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (200,'Jennifer','Whalen','jennifer.whalen@sqltutorial.org','515.123.4444','1987-09-17',3,4400.00,101,1); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (201,'Michael','Hartstein','michael.hartstein@sqltutorial.org','515.123.5555','1996-02-17',10,13000.00,100,2); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (202,'Pat','Fay','pat.fay@sqltutorial.org','603.123.6666','1997-08-17',11,6000.00,201,2); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (203,'Susan','Mavris','susan.mavris@sqltutorial.org','515.123.7777','1994-06-07',8,6500.00,101,4); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (204,'Hermann','Baer','hermann.baer@sqltutorial.org','515.123.8888','1994-06-07',12,10000.00,101,7); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (205,'Shelley','Higgins','shelley.higgins@sqltutorial.org','515.123.8080','1994-06-07',2,12000.00,101,11); -INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (206,'William','Gietz','william.gietz@sqltutorial.org','515.123.8181','1994-06-07',1,8300.00,205,11); - - -/*Data for the table dependents */ - -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (1,'Penelope','Gietz','Child',206); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (2,'Nick','Higgins','Child',205); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (3,'Ed','Whalen','Child',200); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (4,'Jennifer','King','Child',100); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (5,'Johnny','Kochhar','Child',101); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (6,'Bette','De Haan','Child',102); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (7,'Grace','Faviet','Child',109); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (8,'Matthew','Chen','Child',110); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (9,'Joe','Sciarra','Child',111); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (10,'Christian','Urman','Child',112); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (11,'Zero','Popp','Child',113); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (12,'Karl','Greenberg','Child',108); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (13,'Uma','Mavris','Child',203); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (14,'Vivien','Hunold','Child',103); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (15,'Cuba','Ernst','Child',104); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (16,'Fred','Austin','Child',105); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (17,'Helen','Pataballa','Child',106); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (18,'Dan','Lorentz','Child',107); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (19,'Bob','Hartstein','Child',201); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (20,'Lucille','Fay','Child',202); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (21,'Kirsten','Baer','Child',204); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (22,'Elvis','Khoo','Child',115); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (23,'Sandra','Baida','Child',116); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (24,'Cameron','Tobias','Child',117); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (25,'Kevin','Himuro','Child',118); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (26,'Rip','Colmenares','Child',119); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (27,'Julia','Raphaely','Child',114); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (28,'Woody','Russell','Child',145); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (29,'Alec','Partners','Child',146); -INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (30,'Sandra','Taylor','Child',176); \ No newline at end of file +INSERT INTO regions(id,region_name) VALUES (1,'Europe'); +INSERT INTO regions(id,region_name) VALUES (2,'Americas'); +INSERT INTO regions(id,region_name) VALUES (3,'Asia'); +INSERT INTO regions(id,region_name) VALUES (4,'Middle East and Africa'); + + +INSERT INTO countries(id,country_name,region_id) VALUES (5,'Argentina',2); +INSERT INTO countries(id,country_name,region_id) VALUES (6,'Australia',3); +INSERT INTO countries(id,country_name,region_id) VALUES (7,'Belgium',1); +INSERT INTO countries(id,country_name,region_id) VALUES (8,'Brazil',2); +INSERT INTO countries(id,country_name,region_id) VALUES (2,'Canada',2); +INSERT INTO countries(id,country_name,region_id) VALUES (9,'Switzerland',1); +INSERT INTO countries(id,country_name,region_id) VALUES (10,'China',3); +INSERT INTO countries(id,country_name,region_id) VALUES (4,'Germany',1); +INSERT INTO countries(id,country_name,region_id) VALUES (11,'Denmark',1); +INSERT INTO countries(id,country_name,region_id) VALUES (12,'Egypt',4); +INSERT INTO countries(id,country_name,region_id) VALUES (13,'France',1); +INSERT INTO countries(id,country_name,region_id) VALUES (14,'HongKong',3); +INSERT INTO countries(id,country_name,region_id) VALUES (15,'Israel',4); +INSERT INTO countries(id,country_name,region_id) VALUES (16,'India',3); +INSERT INTO countries(id,country_name,region_id) VALUES (17,'Italy',1); +INSERT INTO countries(id,country_name,region_id) VALUES (18,'Japan',3); +INSERT INTO countries(id,country_name,region_id) VALUES (19,'Kuwait',4); +INSERT INTO countries(id,country_name,region_id) VALUES (20,'Mexico',2); +INSERT INTO countries(id,country_name,region_id) VALUES (21,'Nigeria',4); +INSERT INTO countries(id,country_name,region_id) VALUES (22,'Netherlands',1); +INSERT INTO countries(id,country_name,region_id) VALUES (23,'Singapore',3); +INSERT INTO countries(id,country_name,region_id) VALUES (3,'United Kingdom',1); +INSERT INTO countries(id,country_name,region_id) VALUES (1,'United States of America',2); +INSERT INTO countries(id,country_name,region_id) VALUES (24,'Zambia',4); +INSERT INTO countries(id,country_name,region_id) VALUES (25,'Zimbabwe',4); + + +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1400,'2014 Jabberwocky Rd','26192','Southlake','Texas', 1); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1500,'2011 Interiors Blvd','99236','South San Francisco','California',1 ); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1700,'2004 Charade Rd','98199','Seattle','Washington',1); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1800,'147 Spadina Ave','M5V 2L7','Toronto','Ontario',2); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2400,'8204 Arthur St',NULL,'London',NULL,3); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2500,'Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford',3); +INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2700,'Schwanthalerstr. 7031','80925','Munich','Bavaria',4); + + +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (1,'Public Accountant',4200.00,9000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (2,'Accounting Manager',8200.00,16000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (3,'Administration Assistant',3000.00,6000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (4,'President',20000.00,40000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (5,'Administration Vice President',15000.00,30000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (6,'Accountant',4200.00,9000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (7,'Finance Manager',8200.00,16000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (8,'Human Resources Representative',4000.00,9000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (9,'Programmer',4000.00,10000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (10,'Marketing Manager',9000.00,15000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (11,'Marketing Representative',4000.00,9000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (12,'Public Relations Representative',4500.00,10500.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (13,'Purchasing Clerk',2500.00,5500.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (14,'Purchasing Manager',8000.00,15000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (15,'Sales Manager',10000.00,20000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (16,'Sales Representative',6000.00,12000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (17,'Shipping Clerk',2500.00,5500.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (18,'Stock Clerk',2000.00,5000.00); +INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (19,'Stock Manager',5500.00,8500.00); + + +INSERT INTO departments(id,department_name,location_id) VALUES (1,'Administration',1700); +INSERT INTO departments(id,department_name,location_id) VALUES (2,'Marketing',1800); +INSERT INTO departments(id,department_name,location_id) VALUES (3,'Purchasing',1700); +INSERT INTO departments(id,department_name,location_id) VALUES (4,'Human Resources',2400); +INSERT INTO departments(id,department_name,location_id) VALUES (5,'Shipping',1500); +INSERT INTO departments(id,department_name,location_id) VALUES (6,'IT',1400); +INSERT INTO departments(id,department_name,location_id) VALUES (7,'Public Relations',2700); +INSERT INTO departments(id,department_name,location_id) VALUES (8,'Sales',2500); +INSERT INTO departments(id,department_name,location_id) VALUES (9,'Executive',1700); +INSERT INTO departments(id,department_name,location_id) VALUES (10,'Finance',1700); +INSERT INTO departments(id,department_name,location_id) VALUES (11,'Accounting',1700); + + + + +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (100,'Steven','King','steven.king@sqltutorial.org','515.123.4567','1987-06-17',4,24000.00,NULL,9); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (101,'Neena','Kochhar','neena.kochhar@sqltutorial.org','515.123.4568','1989-09-21',5,17000.00,100,9); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (102,'Lex','De Haan','lex.de haan@sqltutorial.org','515.123.4569','1993-01-13',5,17000.00,100,9); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (103,'Alexander','Hunold','alexander.hunold@sqltutorial.org','590.423.4567','1990-01-03',9,9000.00,102,6); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (104,'Bruce','Ernst','bruce.ernst@sqltutorial.org','590.423.4568','1991-05-21',9,6000.00,103,6); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (105,'David','Austin','david.austin@sqltutorial.org','590.423.4569','1997-06-25',9,4800.00,103,6); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (106,'Valli','Pataballa','valli.pataballa@sqltutorial.org','590.423.4560','1998-02-05',9,4800.00,103,6); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (107,'Diana','Lorentz','diana.lorentz@sqltutorial.org','590.423.5567','1999-02-07',9,4200.00,103,6); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (108,'Nancy','Greenberg','nancy.greenberg@sqltutorial.org','515.124.4569','1994-08-17',7,12000.00,101,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (109,'Daniel','Faviet','daniel.faviet@sqltutorial.org','515.124.4169','1994-08-16',6,9000.00,108,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (110,'John','Chen','john.chen@sqltutorial.org','515.124.4269','1997-09-28',6,8200.00,108,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (111,'Ismael','Sciarra','ismael.sciarra@sqltutorial.org','515.124.4369','1997-09-30',6,7700.00,108,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (112,'Jose Manuel','Urman','jose manuel.urman@sqltutorial.org','515.124.4469','1998-03-07',6,7800.00,108,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (113,'Luis','Popp','luis.popp@sqltutorial.org','515.124.4567','1999-12-07',6,6900.00,108,10); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (114,'Den','Raphaely','den.raphaely@sqltutorial.org','515.127.4561','1994-12-07',14,11000.00,100,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (115,'Alexander','Khoo','alexander.khoo@sqltutorial.org','515.127.4562','1995-05-18',13,3100.00,114,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (116,'Shelli','Baida','shelli.baida@sqltutorial.org','515.127.4563','1997-12-24',13,2900.00,114,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (117,'Sigal','Tobias','sigal.tobias@sqltutorial.org','515.127.4564','1997-07-24',13,2800.00,114,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (118,'Guy','Himuro','guy.himuro@sqltutorial.org','515.127.4565','1998-11-15',13,2600.00,114,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (119,'Karen','Colmenares','karen.colmenares@sqltutorial.org','515.127.4566','1999-08-10',13,2500.00,114,3); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (120,'Matthew','Weiss','matthew.weiss@sqltutorial.org','650.123.1234','1996-07-18',19,8000.00,100,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (121,'Adam','Fripp','adam.fripp@sqltutorial.org','650.123.2234','1997-04-10',19,8200.00,100,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (122,'Payam','Kaufling','payam.kaufling@sqltutorial.org','650.123.3234','1995-05-01',19,7900.00,100,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (123,'Shanta','Vollman','shanta.vollman@sqltutorial.org','650.123.4234','1997-10-10',19,6500.00,100,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (126,'Irene','Mikkilineni','irene.mikkilineni@sqltutorial.org','650.124.1224','1998-09-28',18,2700.00,120,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (145,'John','Russell','john.russell@sqltutorial.org','777.888.1234','1996-10-01',15,14000.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (146,'Karen','Partners','karen.partners@sqltutorial.org','101.202.3030','1997-01-05',15,13500.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (176,'Jonathon','Taylor','jonathon.taylor@sqltutorial.org','000.111.3333','1998-03-24',16,8600.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (177,'Jack','Livingston','jack.livingston@sqltutorial.org','345.678.9012','1998-04-23',16,8400.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (178,'Kimberely','Grant','kimberely.grant@sqltutorial.org','121.190.5678','1999-05-24',16,7000.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (179,'Charles','Johnson','charles.johnson@sqltutorial.org','090.123.8765','2000-01-04',16,6200.00,100,8); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (192,'Sarah','Bell','sarah.bell@sqltutorial.org','650.501.1876','1996-02-04',17,4000.00,123,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (193,'Britney','Everett','britney.everett@sqltutorial.org','650.501.2876','1997-03-03',17,3900.00,123,5); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (200,'Jennifer','Whalen','jennifer.whalen@sqltutorial.org','515.123.4444','1987-09-17',3,4400.00,101,1); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (201,'Michael','Hartstein','michael.hartstein@sqltutorial.org','515.123.5555','1996-02-17',10,13000.00,100,2); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (202,'Pat','Fay','pat.fay@sqltutorial.org','603.123.6666','1997-08-17',11,6000.00,201,2); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (203,'Susan','Mavris','susan.mavris@sqltutorial.org','515.123.7777','1994-06-07',8,6500.00,101,4); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (204,'Hermann','Baer','hermann.baer@sqltutorial.org','515.123.8888','1994-06-07',12,10000.00,101,7); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (205,'Shelley','Higgins','shelley.higgins@sqltutorial.org','515.123.8080','1994-06-07',2,12000.00,101,11); +INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (206,'William','Gietz','william.gietz@sqltutorial.org','515.123.8181','1994-06-07',1,8300.00,205,11); + + +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (1,'Penelope','Gietz','Child',206); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (2,'Nick','Higgins','Child',205); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (3,'Ed','Whalen','Child',200); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (4,'Jennifer','King','Child',100); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (5,'Johnny','Kochhar','Child',101); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (6,'Bette','De Haan','Child',102); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (7,'Grace','Faviet','Child',109); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (8,'Matthew','Chen','Child',110); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (9,'Joe','Sciarra','Child',111); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (10,'Christian','Urman','Child',112); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (11,'Zero','Popp','Child',113); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (12,'Karl','Greenberg','Child',108); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (13,'Uma','Mavris','Child',203); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (14,'Vivien','Hunold','Child',103); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (15,'Cuba','Ernst','Child',104); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (16,'Fred','Austin','Child',105); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (17,'Helen','Pataballa','Child',106); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (18,'Dan','Lorentz','Child',107); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (19,'Bob','Hartstein','Child',201); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (20,'Lucille','Fay','Child',202); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (21,'Kirsten','Baer','Child',204); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (22,'Elvis','Khoo','Child',115); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (23,'Sandra','Baida','Child',116); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (24,'Cameron','Tobias','Child',117); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (25,'Kevin','Himuro','Child',118); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (26,'Rip','Colmenares','Child',119); +INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (27,'Julia','Raphaely','Child',114); diff --git a/lib/sql_ecto/hr/country.ex b/lib/sql_ecto/hr/country.ex index 1f40e8c..cae11d9 100644 --- a/lib/sql_ecto/hr/country.ex +++ b/lib/sql_ecto/hr/country.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Country do use Ecto.Schema import Ecto.Changeset - @primary_key {:country_id, :string, []} + @primary_key {:id, :integer, autogenerate: false} schema "countries" do diff --git a/lib/sql_ecto/hr/department.ex b/lib/sql_ecto/hr/department.ex index 33442bb..f659abe 100644 --- a/lib/sql_ecto/hr/department.ex +++ b/lib/sql_ecto/hr/department.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Department do use Ecto.Schema import Ecto.Changeset - @primary_key {:department_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "departments" do @@ -11,6 +11,7 @@ defmodule SqlEcto.Hr.Department do end + @spec changeset(Ecto.Changeset.t(), any()) :: Ecto.Changeset.t() def changeset(departments, _params) do departments |> validate_required(:department_name) diff --git a/lib/sql_ecto/hr/dependent.ex b/lib/sql_ecto/hr/dependent.ex index bdab563..a1cef7d 100644 --- a/lib/sql_ecto/hr/dependent.ex +++ b/lib/sql_ecto/hr/dependent.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Dependent do use Ecto.Schema import Ecto.Changeset - @primary_key {:dependent_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "dependents" do diff --git a/lib/sql_ecto/hr/employee.ex b/lib/sql_ecto/hr/employee.ex index 805d42d..6a0b4aa 100644 --- a/lib/sql_ecto/hr/employee.ex +++ b/lib/sql_ecto/hr/employee.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Employee do use Ecto.Schema import Ecto.Changeset - @primary_key {:employee_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "employees" do @@ -18,6 +18,7 @@ defmodule SqlEcto.Hr.Employee do end + @spec changeset(Ecto.Changeset.t(), any()) :: Ecto.Changeset.t() def changeset(employees, _params) do employees |> validate_required(:last_name) diff --git a/lib/sql_ecto/hr/job.ex b/lib/sql_ecto/hr/job.ex index 6606fb4..1566d38 100644 --- a/lib/sql_ecto/hr/job.ex +++ b/lib/sql_ecto/hr/job.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Job do use Ecto.Schema import Ecto.Changeset - @primary_key {:job_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "jobs" do diff --git a/lib/sql_ecto/hr/location.ex b/lib/sql_ecto/hr/location.ex index d294d4e..f38d100 100644 --- a/lib/sql_ecto/hr/location.ex +++ b/lib/sql_ecto/hr/location.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Location do use Ecto.Schema import Ecto.Changeset - @primary_key {:location_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "locations" do @@ -10,7 +10,7 @@ defmodule SqlEcto.Hr.Location do field :postal_code, :string field :city, :string field :state_province, :string - field :country_id, :string + field :country_id, :integer end diff --git a/lib/sql_ecto/hr/region.ex b/lib/sql_ecto/hr/region.ex index 3c5b0c5..b49f70d 100644 --- a/lib/sql_ecto/hr/region.ex +++ b/lib/sql_ecto/hr/region.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Region do use Ecto.Schema import Ecto.Changeset - @primary_key {:region_id, :integer, []} + @primary_key {:id, :integer, autogenerate: false} schema "regions" do diff --git a/priv/repo/migrations/20231101035925_region.exs b/priv/repo/migrations/20231101035925_region.exs new file mode 100644 index 0000000..ebaedcc --- /dev/null +++ b/priv/repo/migrations/20231101035925_region.exs @@ -0,0 +1,10 @@ +defmodule SqlEcto.Repo.Migrations.Region do + use Ecto.Migration + + def change do + create table(:regions, primary_key: false) do + add :id, :integer, primary_key: true + add :region_name, :string, size: 25 + end + end +end diff --git a/priv/repo/migrations/20231101035926_country.exs b/priv/repo/migrations/20231101035926_country.exs new file mode 100644 index 0000000..6a72a0e --- /dev/null +++ b/priv/repo/migrations/20231101035926_country.exs @@ -0,0 +1,14 @@ +defmodule SqlEcto.Repo.Migrations.Country do + use Ecto.Migration + + def change do + create table(:countries, primary_key: false) do + add :id, :bigint, primary_key: true + add :country_name, :string, size: 40 + add :region_id, references(:regions), null: false + end + + create index(:countries, [:region_id]) + + end +end diff --git a/priv/repo/migrations/20231101035927_location.exs b/priv/repo/migrations/20231101035927_location.exs new file mode 100644 index 0000000..8e49852 --- /dev/null +++ b/priv/repo/migrations/20231101035927_location.exs @@ -0,0 +1,17 @@ +defmodule SqlEcto.Repo.Migrations.Location do + use Ecto.Migration + + def change do + create table(:locations, primary_key: false) do + add :id, :integer, primary_key: true + add :street_address, :string, size: 40 + add :postal_code, :string, size: 12 + add :city, :string, size: 30, null: false + add :state_province, :string, size: 25 + add :country_id, references(:countries), size: 2, null: false + end + + create index(:locations, [:country_id]) + + end +end diff --git a/priv/repo/migrations/20231101035928_department.exs b/priv/repo/migrations/20231101035928_department.exs new file mode 100644 index 0000000..58ca8ed --- /dev/null +++ b/priv/repo/migrations/20231101035928_department.exs @@ -0,0 +1,14 @@ +defmodule SqlEcto.Repo.Migrations.Department do + use Ecto.Migration + + def change do + create table(:departments, primary_key: false) do + add :id, :integer, primary_key: true + add :department_name, :string, size: 30, null: false + add :location_id, references(:locations) + end + + create index(:departments, [:location_id]) + + end +end diff --git a/priv/repo/migrations/20231101035942_job.exs b/priv/repo/migrations/20231101035942_job.exs new file mode 100644 index 0000000..d11aac6 --- /dev/null +++ b/priv/repo/migrations/20231101035942_job.exs @@ -0,0 +1,12 @@ +defmodule SqlEcto.Repo.Migrations.Job do + use Ecto.Migration + + def change do + create table(:jobs, primary_key: false) do + add :id, :integer, primary_key: true + add :job_title, :string, null: false, size: 35 + add :min_salary, :decimal, check: [8, 2] + add :max_salary, :decimal + end + end +end diff --git a/priv/repo/migrations/20231101035943_employee.exs b/priv/repo/migrations/20231101035943_employee.exs new file mode 100644 index 0000000..97b760c --- /dev/null +++ b/priv/repo/migrations/20231101035943_employee.exs @@ -0,0 +1,22 @@ +defmodule SqlEcto.Repo.Migrations.Employee do + use Ecto.Migration + + def change do + create table(:employees, primary_key: false) do + add :id, :integer, primary_key: true + add :first_name, :string, size: 20 + add :last_name, :string, null: false, size: 25 + add :email, :string, null: false, size: 100 + add :phone_number, :string, null: false, size: 20 + add :hire_date, :date, null: false + add :salary, :decimal, null: false, check: [8, 2] + add :manager_id, :integer + add :job_id, references(:countries), null: false + add :department_id, references(:departments) + + end + + create index(:employees, [:job_id, :department_id]) + + end +end diff --git a/priv/repo/migrations/20231101035944_dependent.exs b/priv/repo/migrations/20231101035944_dependent.exs new file mode 100644 index 0000000..6700840 --- /dev/null +++ b/priv/repo/migrations/20231101035944_dependent.exs @@ -0,0 +1,16 @@ +defmodule SqlEcto.Repo.Migrations.Dependent do + use Ecto.Migration + + def change do + create table(:dependents, primary_key: false) do + add :id, :integer, primary_key: true + add :first_name, :string, null: false, size: 50 + add :last_name, :string, null: false, size: 50 + add :relationship, :string, null: false, size: 25 + add :employee_id, references(:employees), null: false + end + + create index(:dependents, [:employee_id]) + + end +end From df4c0b33ae4e576b680fea8ab32975df586a5e14 Mon Sep 17 00:00:00 2001 From: sangeetha Date: Thu, 2 Nov 2023 10:30:26 +0530 Subject: [PATCH 2/2] Rework --- .../database/insert_into_hr_database.sql | 306 +++++++++--------- lib/sql_ecto/hr/country.ex | 2 +- lib/sql_ecto/hr/department.ex | 2 +- lib/sql_ecto/hr/dependent.ex | 2 +- lib/sql_ecto/hr/employee.ex | 2 +- lib/sql_ecto/hr/job.ex | 2 +- lib/sql_ecto/hr/location.ex | 4 +- lib/sql_ecto/hr/region.ex | 2 +- ....exs => 20231101035925_create_regions.exs} | 4 +- .../migrations/20231101035926_country.exs | 14 - .../migrations/20231101035927_location.exs | 17 - .../migrations/20231101035928_department.exs | 14 - priv/repo/migrations/20231101035942_job.exs | 12 - .../migrations/20231101035943_employee.exs | 22 -- .../migrations/20231101035944_dependent.exs | 16 - .../20231102033546_create_countries.exs | 11 + .../20231102035048_create_locations.exs | 16 + .../20231102040321_create_departments.exs | 11 + .../migrations/20231102041246_create_jobs.exs | 12 + .../20231102042459_create_employees.exs | 18 ++ .../20231102044510_create_dependents.exs | 13 + 21 files changed, 250 insertions(+), 252 deletions(-) rename priv/repo/migrations/{20231101035925_region.exs => 20231101035925_create_regions.exs} (59%) delete mode 100644 priv/repo/migrations/20231101035926_country.exs delete mode 100644 priv/repo/migrations/20231101035927_location.exs delete mode 100644 priv/repo/migrations/20231101035928_department.exs delete mode 100644 priv/repo/migrations/20231101035942_job.exs delete mode 100644 priv/repo/migrations/20231101035943_employee.exs delete mode 100644 priv/repo/migrations/20231101035944_dependent.exs create mode 100644 priv/repo/migrations/20231102033546_create_countries.exs create mode 100644 priv/repo/migrations/20231102035048_create_locations.exs create mode 100644 priv/repo/migrations/20231102040321_create_departments.exs create mode 100644 priv/repo/migrations/20231102041246_create_jobs.exs create mode 100644 priv/repo/migrations/20231102042459_create_employees.exs create mode 100644 priv/repo/migrations/20231102044510_create_dependents.exs diff --git a/lib/sql_ecto/database/insert_into_hr_database.sql b/lib/sql_ecto/database/insert_into_hr_database.sql index 092f498..0151edd 100644 --- a/lib/sql_ecto/database/insert_into_hr_database.sql +++ b/lib/sql_ecto/database/insert_into_hr_database.sql @@ -1,148 +1,160 @@ +/*Data for the table regions */ -INSERT INTO regions(id,region_name) VALUES (1,'Europe'); -INSERT INTO regions(id,region_name) VALUES (2,'Americas'); -INSERT INTO regions(id,region_name) VALUES (3,'Asia'); -INSERT INTO regions(id,region_name) VALUES (4,'Middle East and Africa'); - - -INSERT INTO countries(id,country_name,region_id) VALUES (5,'Argentina',2); -INSERT INTO countries(id,country_name,region_id) VALUES (6,'Australia',3); -INSERT INTO countries(id,country_name,region_id) VALUES (7,'Belgium',1); -INSERT INTO countries(id,country_name,region_id) VALUES (8,'Brazil',2); -INSERT INTO countries(id,country_name,region_id) VALUES (2,'Canada',2); -INSERT INTO countries(id,country_name,region_id) VALUES (9,'Switzerland',1); -INSERT INTO countries(id,country_name,region_id) VALUES (10,'China',3); -INSERT INTO countries(id,country_name,region_id) VALUES (4,'Germany',1); -INSERT INTO countries(id,country_name,region_id) VALUES (11,'Denmark',1); -INSERT INTO countries(id,country_name,region_id) VALUES (12,'Egypt',4); -INSERT INTO countries(id,country_name,region_id) VALUES (13,'France',1); -INSERT INTO countries(id,country_name,region_id) VALUES (14,'HongKong',3); -INSERT INTO countries(id,country_name,region_id) VALUES (15,'Israel',4); -INSERT INTO countries(id,country_name,region_id) VALUES (16,'India',3); -INSERT INTO countries(id,country_name,region_id) VALUES (17,'Italy',1); -INSERT INTO countries(id,country_name,region_id) VALUES (18,'Japan',3); -INSERT INTO countries(id,country_name,region_id) VALUES (19,'Kuwait',4); -INSERT INTO countries(id,country_name,region_id) VALUES (20,'Mexico',2); -INSERT INTO countries(id,country_name,region_id) VALUES (21,'Nigeria',4); -INSERT INTO countries(id,country_name,region_id) VALUES (22,'Netherlands',1); -INSERT INTO countries(id,country_name,region_id) VALUES (23,'Singapore',3); -INSERT INTO countries(id,country_name,region_id) VALUES (3,'United Kingdom',1); -INSERT INTO countries(id,country_name,region_id) VALUES (1,'United States of America',2); -INSERT INTO countries(id,country_name,region_id) VALUES (24,'Zambia',4); -INSERT INTO countries(id,country_name,region_id) VALUES (25,'Zimbabwe',4); - - -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1400,'2014 Jabberwocky Rd','26192','Southlake','Texas', 1); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1500,'2011 Interiors Blvd','99236','South San Francisco','California',1 ); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1700,'2004 Charade Rd','98199','Seattle','Washington',1); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (1800,'147 Spadina Ave','M5V 2L7','Toronto','Ontario',2); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2400,'8204 Arthur St',NULL,'London',NULL,3); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2500,'Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford',3); -INSERT INTO locations(id,street_address,postal_code,city,state_province,country_id) VALUES (2700,'Schwanthalerstr. 7031','80925','Munich','Bavaria',4); - - -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (1,'Public Accountant',4200.00,9000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (2,'Accounting Manager',8200.00,16000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (3,'Administration Assistant',3000.00,6000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (4,'President',20000.00,40000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (5,'Administration Vice President',15000.00,30000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (6,'Accountant',4200.00,9000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (7,'Finance Manager',8200.00,16000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (8,'Human Resources Representative',4000.00,9000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (9,'Programmer',4000.00,10000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (10,'Marketing Manager',9000.00,15000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (11,'Marketing Representative',4000.00,9000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (12,'Public Relations Representative',4500.00,10500.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (13,'Purchasing Clerk',2500.00,5500.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (14,'Purchasing Manager',8000.00,15000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (15,'Sales Manager',10000.00,20000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (16,'Sales Representative',6000.00,12000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (17,'Shipping Clerk',2500.00,5500.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (18,'Stock Clerk',2000.00,5000.00); -INSERT INTO jobs(id,job_title,min_salary,max_salary) VALUES (19,'Stock Manager',5500.00,8500.00); - - -INSERT INTO departments(id,department_name,location_id) VALUES (1,'Administration',1700); -INSERT INTO departments(id,department_name,location_id) VALUES (2,'Marketing',1800); -INSERT INTO departments(id,department_name,location_id) VALUES (3,'Purchasing',1700); -INSERT INTO departments(id,department_name,location_id) VALUES (4,'Human Resources',2400); -INSERT INTO departments(id,department_name,location_id) VALUES (5,'Shipping',1500); -INSERT INTO departments(id,department_name,location_id) VALUES (6,'IT',1400); -INSERT INTO departments(id,department_name,location_id) VALUES (7,'Public Relations',2700); -INSERT INTO departments(id,department_name,location_id) VALUES (8,'Sales',2500); -INSERT INTO departments(id,department_name,location_id) VALUES (9,'Executive',1700); -INSERT INTO departments(id,department_name,location_id) VALUES (10,'Finance',1700); -INSERT INTO departments(id,department_name,location_id) VALUES (11,'Accounting',1700); - - - - -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (100,'Steven','King','steven.king@sqltutorial.org','515.123.4567','1987-06-17',4,24000.00,NULL,9); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (101,'Neena','Kochhar','neena.kochhar@sqltutorial.org','515.123.4568','1989-09-21',5,17000.00,100,9); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (102,'Lex','De Haan','lex.de haan@sqltutorial.org','515.123.4569','1993-01-13',5,17000.00,100,9); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (103,'Alexander','Hunold','alexander.hunold@sqltutorial.org','590.423.4567','1990-01-03',9,9000.00,102,6); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (104,'Bruce','Ernst','bruce.ernst@sqltutorial.org','590.423.4568','1991-05-21',9,6000.00,103,6); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (105,'David','Austin','david.austin@sqltutorial.org','590.423.4569','1997-06-25',9,4800.00,103,6); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (106,'Valli','Pataballa','valli.pataballa@sqltutorial.org','590.423.4560','1998-02-05',9,4800.00,103,6); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (107,'Diana','Lorentz','diana.lorentz@sqltutorial.org','590.423.5567','1999-02-07',9,4200.00,103,6); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (108,'Nancy','Greenberg','nancy.greenberg@sqltutorial.org','515.124.4569','1994-08-17',7,12000.00,101,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (109,'Daniel','Faviet','daniel.faviet@sqltutorial.org','515.124.4169','1994-08-16',6,9000.00,108,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (110,'John','Chen','john.chen@sqltutorial.org','515.124.4269','1997-09-28',6,8200.00,108,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (111,'Ismael','Sciarra','ismael.sciarra@sqltutorial.org','515.124.4369','1997-09-30',6,7700.00,108,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (112,'Jose Manuel','Urman','jose manuel.urman@sqltutorial.org','515.124.4469','1998-03-07',6,7800.00,108,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (113,'Luis','Popp','luis.popp@sqltutorial.org','515.124.4567','1999-12-07',6,6900.00,108,10); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (114,'Den','Raphaely','den.raphaely@sqltutorial.org','515.127.4561','1994-12-07',14,11000.00,100,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (115,'Alexander','Khoo','alexander.khoo@sqltutorial.org','515.127.4562','1995-05-18',13,3100.00,114,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (116,'Shelli','Baida','shelli.baida@sqltutorial.org','515.127.4563','1997-12-24',13,2900.00,114,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (117,'Sigal','Tobias','sigal.tobias@sqltutorial.org','515.127.4564','1997-07-24',13,2800.00,114,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (118,'Guy','Himuro','guy.himuro@sqltutorial.org','515.127.4565','1998-11-15',13,2600.00,114,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (119,'Karen','Colmenares','karen.colmenares@sqltutorial.org','515.127.4566','1999-08-10',13,2500.00,114,3); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (120,'Matthew','Weiss','matthew.weiss@sqltutorial.org','650.123.1234','1996-07-18',19,8000.00,100,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (121,'Adam','Fripp','adam.fripp@sqltutorial.org','650.123.2234','1997-04-10',19,8200.00,100,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (122,'Payam','Kaufling','payam.kaufling@sqltutorial.org','650.123.3234','1995-05-01',19,7900.00,100,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (123,'Shanta','Vollman','shanta.vollman@sqltutorial.org','650.123.4234','1997-10-10',19,6500.00,100,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (126,'Irene','Mikkilineni','irene.mikkilineni@sqltutorial.org','650.124.1224','1998-09-28',18,2700.00,120,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (145,'John','Russell','john.russell@sqltutorial.org','777.888.1234','1996-10-01',15,14000.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (146,'Karen','Partners','karen.partners@sqltutorial.org','101.202.3030','1997-01-05',15,13500.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (176,'Jonathon','Taylor','jonathon.taylor@sqltutorial.org','000.111.3333','1998-03-24',16,8600.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (177,'Jack','Livingston','jack.livingston@sqltutorial.org','345.678.9012','1998-04-23',16,8400.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (178,'Kimberely','Grant','kimberely.grant@sqltutorial.org','121.190.5678','1999-05-24',16,7000.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (179,'Charles','Johnson','charles.johnson@sqltutorial.org','090.123.8765','2000-01-04',16,6200.00,100,8); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (192,'Sarah','Bell','sarah.bell@sqltutorial.org','650.501.1876','1996-02-04',17,4000.00,123,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (193,'Britney','Everett','britney.everett@sqltutorial.org','650.501.2876','1997-03-03',17,3900.00,123,5); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (200,'Jennifer','Whalen','jennifer.whalen@sqltutorial.org','515.123.4444','1987-09-17',3,4400.00,101,1); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (201,'Michael','Hartstein','michael.hartstein@sqltutorial.org','515.123.5555','1996-02-17',10,13000.00,100,2); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (202,'Pat','Fay','pat.fay@sqltutorial.org','603.123.6666','1997-08-17',11,6000.00,201,2); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (203,'Susan','Mavris','susan.mavris@sqltutorial.org','515.123.7777','1994-06-07',8,6500.00,101,4); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (204,'Hermann','Baer','hermann.baer@sqltutorial.org','515.123.8888','1994-06-07',12,10000.00,101,7); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (205,'Shelley','Higgins','shelley.higgins@sqltutorial.org','515.123.8080','1994-06-07',2,12000.00,101,11); -INSERT INTO employees(id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (206,'William','Gietz','william.gietz@sqltutorial.org','515.123.8181','1994-06-07',1,8300.00,205,11); - - -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (1,'Penelope','Gietz','Child',206); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (2,'Nick','Higgins','Child',205); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (3,'Ed','Whalen','Child',200); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (4,'Jennifer','King','Child',100); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (5,'Johnny','Kochhar','Child',101); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (6,'Bette','De Haan','Child',102); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (7,'Grace','Faviet','Child',109); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (8,'Matthew','Chen','Child',110); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (9,'Joe','Sciarra','Child',111); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (10,'Christian','Urman','Child',112); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (11,'Zero','Popp','Child',113); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (12,'Karl','Greenberg','Child',108); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (13,'Uma','Mavris','Child',203); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (14,'Vivien','Hunold','Child',103); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (15,'Cuba','Ernst','Child',104); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (16,'Fred','Austin','Child',105); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (17,'Helen','Pataballa','Child',106); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (18,'Dan','Lorentz','Child',107); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (19,'Bob','Hartstein','Child',201); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (20,'Lucille','Fay','Child',202); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (21,'Kirsten','Baer','Child',204); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (22,'Elvis','Khoo','Child',115); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (23,'Sandra','Baida','Child',116); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (24,'Cameron','Tobias','Child',117); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (25,'Kevin','Himuro','Child',118); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (26,'Rip','Colmenares','Child',119); -INSERT INTO dependents(id,first_name,last_name,relationship,employee_id) VALUES (27,'Julia','Raphaely','Child',114); +INSERT INTO regions(region_id,region_name) VALUES (1,'Europe'); +INSERT INTO regions(region_id,region_name) VALUES (2,'Americas'); +INSERT INTO regions(region_id,region_name) VALUES (3,'Asia'); +INSERT INTO regions(region_id,region_name) VALUES (4,'Middle East and Africa'); + + +/*Data for the table countries */ +INSERT INTO countries(country_id,country_name,region_id) VALUES ('AR','Argentina',2); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('AU','Australia',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('BE','Belgium',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('BR','Brazil',2); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('CA','Canada',2); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('CH','Switzerland',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('CN','China',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('DE','Germany',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('DK','Denmark',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('EG','Egypt',4); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('FR','France',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('HK','HongKong',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('IL','Israel',4); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('IN','India',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('IT','Italy',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('JP','Japan',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('KW','Kuwait',4); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('MX','Mexico',2); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('NG','Nigeria',4); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('NL','Netherlands',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('SG','Singapore',3); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('UK','United Kingdom',1); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('US','United States of America',2); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('ZM','Zambia',4); +INSERT INTO countries(country_id,country_name,region_id) VALUES ('ZW','Zimbabwe',4); + +/*Data for the table locations */ +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1400,'2014 Jabberwocky Rd','26192','Southlake','Texas','US'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1500,'2011 Interiors Blvd','99236','South San Francisco','California','US'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1700,'2004 Charade Rd','98199','Seattle','Washington','US'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (1800,'147 Spadina Ave','M5V 2L7','Toronto','Ontario','CA'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2400,'8204 Arthur St',NULL,'London',NULL,'UK'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2500,'Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford','UK'); +INSERT INTO locations(location_id,street_address,postal_code,city,state_province,country_id) VALUES (2700,'Schwanthalerstr. 7031','80925','Munich','Bavaria','DE'); + + +/*Data for the table jobs */ + +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (1,'Public Accountant',4200.00,9000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (2,'Accounting Manager',8200.00,16000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (3,'Administration Assistant',3000.00,6000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (4,'President',20000.00,40000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (5,'Administration Vice President',15000.00,30000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (6,'Accountant',4200.00,9000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (7,'Finance Manager',8200.00,16000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (8,'Human Resources Representative',4000.00,9000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (9,'Programmer',4000.00,10000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (10,'Marketing Manager',9000.00,15000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (11,'Marketing Representative',4000.00,9000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (12,'Public Relations Representative',4500.00,10500.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (13,'Purchasing Clerk',2500.00,5500.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (14,'Purchasing Manager',8000.00,15000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (15,'Sales Manager',10000.00,20000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (16,'Sales Representative',6000.00,12000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (17,'Shipping Clerk',2500.00,5500.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (18,'Stock Clerk',2000.00,5000.00); +INSERT INTO jobs(job_id,job_title,min_salary,max_salary) VALUES (19,'Stock Manager',5500.00,8500.00); + + +/*Data for the table departments */ + +INSERT INTO departments(department_id,department_name,location_id) VALUES (1,'Administration',1700); +INSERT INTO departments(department_id,department_name,location_id) VALUES (2,'Marketing',1800); +INSERT INTO departments(department_id,department_name,location_id) VALUES (3,'Purchasing',1700); +INSERT INTO departments(department_id,department_name,location_id) VALUES (4,'Human Resources',2400); +INSERT INTO departments(department_id,department_name,location_id) VALUES (5,'Shipping',1500); +INSERT INTO departments(department_id,department_name,location_id) VALUES (6,'IT',1400); +INSERT INTO departments(department_id,department_name,location_id) VALUES (7,'Public Relations',2700); +INSERT INTO departments(department_id,department_name,location_id) VALUES (8,'Sales',2500); +INSERT INTO departments(department_id,department_name,location_id) VALUES (9,'Executive',1700); +INSERT INTO departments(department_id,department_name,location_id) VALUES (10,'Finance',1700); +INSERT INTO departments(department_id,department_name,location_id) VALUES (11,'Accounting',1700); + + + +/*Data for the table employees */ + +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (100,'Steven','King','steven.king@sqltutorial.org','515.123.4567','1987-06-17',4,24000.00,NULL,9); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (101,'Neena','Kochhar','neena.kochhar@sqltutorial.org','515.123.4568','1989-09-21',5,17000.00,100,9); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (102,'Lex','De Haan','lex.de haan@sqltutorial.org','515.123.4569','1993-01-13',5,17000.00,100,9); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (103,'Alexander','Hunold','alexander.hunold@sqltutorial.org','590.423.4567','1990-01-03',9,9000.00,102,6); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (104,'Bruce','Ernst','bruce.ernst@sqltutorial.org','590.423.4568','1991-05-21',9,6000.00,103,6); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (105,'David','Austin','david.austin@sqltutorial.org','590.423.4569','1997-06-25',9,4800.00,103,6); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (106,'Valli','Pataballa','valli.pataballa@sqltutorial.org','590.423.4560','1998-02-05',9,4800.00,103,6); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (107,'Diana','Lorentz','diana.lorentz@sqltutorial.org','590.423.5567','1999-02-07',9,4200.00,103,6); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (108,'Nancy','Greenberg','nancy.greenberg@sqltutorial.org','515.124.4569','1994-08-17',7,12000.00,101,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (109,'Daniel','Faviet','daniel.faviet@sqltutorial.org','515.124.4169','1994-08-16',6,9000.00,108,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (110,'John','Chen','john.chen@sqltutorial.org','515.124.4269','1997-09-28',6,8200.00,108,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (111,'Ismael','Sciarra','ismael.sciarra@sqltutorial.org','515.124.4369','1997-09-30',6,7700.00,108,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (112,'Jose Manuel','Urman','jose manuel.urman@sqltutorial.org','515.124.4469','1998-03-07',6,7800.00,108,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (113,'Luis','Popp','luis.popp@sqltutorial.org','515.124.4567','1999-12-07',6,6900.00,108,10); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (114,'Den','Raphaely','den.raphaely@sqltutorial.org','515.127.4561','1994-12-07',14,11000.00,100,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (115,'Alexander','Khoo','alexander.khoo@sqltutorial.org','515.127.4562','1995-05-18',13,3100.00,114,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (116,'Shelli','Baida','shelli.baida@sqltutorial.org','515.127.4563','1997-12-24',13,2900.00,114,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (117,'Sigal','Tobias','sigal.tobias@sqltutorial.org','515.127.4564','1997-07-24',13,2800.00,114,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (118,'Guy','Himuro','guy.himuro@sqltutorial.org','515.127.4565','1998-11-15',13,2600.00,114,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (119,'Karen','Colmenares','karen.colmenares@sqltutorial.org','515.127.4566','1999-08-10',13,2500.00,114,3); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (120,'Matthew','Weiss','matthew.weiss@sqltutorial.org','650.123.1234','1996-07-18',19,8000.00,100,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (121,'Adam','Fripp','adam.fripp@sqltutorial.org','650.123.2234','1997-04-10',19,8200.00,100,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (122,'Payam','Kaufling','payam.kaufling@sqltutorial.org','650.123.3234','1995-05-01',19,7900.00,100,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (123,'Shanta','Vollman','shanta.vollman@sqltutorial.org','650.123.4234','1997-10-10',19,6500.00,100,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (126,'Irene','Mikkilineni','irene.mikkilineni@sqltutorial.org','650.124.1224','1998-09-28',18,2700.00,120,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (145,'John','Russell','john.russell@sqltutorial.org',NULL,'1996-10-01',15,14000.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (146,'Karen','Partners','karen.partners@sqltutorial.org',NULL,'1997-01-05',15,13500.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (176,'Jonathon','Taylor','jonathon.taylor@sqltutorial.org',NULL,'1998-03-24',16,8600.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (177,'Jack','Livingston','jack.livingston@sqltutorial.org',NULL,'1998-04-23',16,8400.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (178,'Kimberely','Grant','kimberely.grant@sqltutorial.org',NULL,'1999-05-24',16,7000.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (179,'Charles','Johnson','charles.johnson@sqltutorial.org',NULL,'2000-01-04',16,6200.00,100,8); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (192,'Sarah','Bell','sarah.bell@sqltutorial.org','650.501.1876','1996-02-04',17,4000.00,123,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (193,'Britney','Everett','britney.everett@sqltutorial.org','650.501.2876','1997-03-03',17,3900.00,123,5); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (200,'Jennifer','Whalen','jennifer.whalen@sqltutorial.org','515.123.4444','1987-09-17',3,4400.00,101,1); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (201,'Michael','Hartstein','michael.hartstein@sqltutorial.org','515.123.5555','1996-02-17',10,13000.00,100,2); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (202,'Pat','Fay','pat.fay@sqltutorial.org','603.123.6666','1997-08-17',11,6000.00,201,2); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (203,'Susan','Mavris','susan.mavris@sqltutorial.org','515.123.7777','1994-06-07',8,6500.00,101,4); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (204,'Hermann','Baer','hermann.baer@sqltutorial.org','515.123.8888','1994-06-07',12,10000.00,101,7); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (205,'Shelley','Higgins','shelley.higgins@sqltutorial.org','515.123.8080','1994-06-07',2,12000.00,101,11); +INSERT INTO employees(employee_id,first_name,last_name,email,phone_number,hire_date,job_id,salary,manager_id,department_id) VALUES (206,'William','Gietz','william.gietz@sqltutorial.org','515.123.8181','1994-06-07',1,8300.00,205,11); + + +/*Data for the table dependents */ + +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (1,'Penelope','Gietz','Child',206); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (2,'Nick','Higgins','Child',205); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (3,'Ed','Whalen','Child',200); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (4,'Jennifer','King','Child',100); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (5,'Johnny','Kochhar','Child',101); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (6,'Bette','De Haan','Child',102); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (7,'Grace','Faviet','Child',109); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (8,'Matthew','Chen','Child',110); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (9,'Joe','Sciarra','Child',111); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (10,'Christian','Urman','Child',112); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (11,'Zero','Popp','Child',113); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (12,'Karl','Greenberg','Child',108); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (13,'Uma','Mavris','Child',203); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (14,'Vivien','Hunold','Child',103); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (15,'Cuba','Ernst','Child',104); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (16,'Fred','Austin','Child',105); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (17,'Helen','Pataballa','Child',106); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (18,'Dan','Lorentz','Child',107); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (19,'Bob','Hartstein','Child',201); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (20,'Lucille','Fay','Child',202); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (21,'Kirsten','Baer','Child',204); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (22,'Elvis','Khoo','Child',115); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (23,'Sandra','Baida','Child',116); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (24,'Cameron','Tobias','Child',117); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (25,'Kevin','Himuro','Child',118); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (26,'Rip','Colmenares','Child',119); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (27,'Julia','Raphaely','Child',114); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (28,'Woody','Russell','Child',145); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (29,'Alec','Partners','Child',146); +INSERT INTO dependents(dependent_id,first_name,last_name,relationship,employee_id) VALUES (30,'Sandra','Taylor','Child',176); \ No newline at end of file diff --git a/lib/sql_ecto/hr/country.ex b/lib/sql_ecto/hr/country.ex index cae11d9..45eae18 100644 --- a/lib/sql_ecto/hr/country.ex +++ b/lib/sql_ecto/hr/country.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Country do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:country_id, :string, autogenerate: false} schema "countries" do diff --git a/lib/sql_ecto/hr/department.ex b/lib/sql_ecto/hr/department.ex index f659abe..dbdfcf1 100644 --- a/lib/sql_ecto/hr/department.ex +++ b/lib/sql_ecto/hr/department.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Department do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:department_id, :integer, autogenerate: false} schema "departments" do diff --git a/lib/sql_ecto/hr/dependent.ex b/lib/sql_ecto/hr/dependent.ex index a1cef7d..6dcf30c 100644 --- a/lib/sql_ecto/hr/dependent.ex +++ b/lib/sql_ecto/hr/dependent.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Dependent do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:dependent_id, :integer, autogenerate: false} schema "dependents" do diff --git a/lib/sql_ecto/hr/employee.ex b/lib/sql_ecto/hr/employee.ex index 6a0b4aa..7b72661 100644 --- a/lib/sql_ecto/hr/employee.ex +++ b/lib/sql_ecto/hr/employee.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Employee do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:employee_id, :integer, autogenerate: false} schema "employees" do diff --git a/lib/sql_ecto/hr/job.ex b/lib/sql_ecto/hr/job.ex index 1566d38..2fd0644 100644 --- a/lib/sql_ecto/hr/job.ex +++ b/lib/sql_ecto/hr/job.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Job do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:job_id, :integer, autogenerate: false} schema "jobs" do diff --git a/lib/sql_ecto/hr/location.ex b/lib/sql_ecto/hr/location.ex index f38d100..5acc98a 100644 --- a/lib/sql_ecto/hr/location.ex +++ b/lib/sql_ecto/hr/location.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Location do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:location_id, :integer, autogenerate: false} schema "locations" do @@ -10,7 +10,7 @@ defmodule SqlEcto.Hr.Location do field :postal_code, :string field :city, :string field :state_province, :string - field :country_id, :integer + field :country_id, :string end diff --git a/lib/sql_ecto/hr/region.ex b/lib/sql_ecto/hr/region.ex index b49f70d..8af2b97 100644 --- a/lib/sql_ecto/hr/region.ex +++ b/lib/sql_ecto/hr/region.ex @@ -2,7 +2,7 @@ defmodule SqlEcto.Hr.Region do use Ecto.Schema import Ecto.Changeset - @primary_key {:id, :integer, autogenerate: false} + @primary_key {:region_id, :integer, autogenerate: false} schema "regions" do diff --git a/priv/repo/migrations/20231101035925_region.exs b/priv/repo/migrations/20231101035925_create_regions.exs similarity index 59% rename from priv/repo/migrations/20231101035925_region.exs rename to priv/repo/migrations/20231101035925_create_regions.exs index ebaedcc..b1d6ab6 100644 --- a/priv/repo/migrations/20231101035925_region.exs +++ b/priv/repo/migrations/20231101035925_create_regions.exs @@ -1,9 +1,9 @@ -defmodule SqlEcto.Repo.Migrations.Region do +defmodule SqlEcto.Repo.Migrations.CreateRegions do use Ecto.Migration def change do create table(:regions, primary_key: false) do - add :id, :integer, primary_key: true + add :region_id, :serial, primary_key: true add :region_name, :string, size: 25 end end diff --git a/priv/repo/migrations/20231101035926_country.exs b/priv/repo/migrations/20231101035926_country.exs deleted file mode 100644 index 6a72a0e..0000000 --- a/priv/repo/migrations/20231101035926_country.exs +++ /dev/null @@ -1,14 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Country do - use Ecto.Migration - - def change do - create table(:countries, primary_key: false) do - add :id, :bigint, primary_key: true - add :country_name, :string, size: 40 - add :region_id, references(:regions), null: false - end - - create index(:countries, [:region_id]) - - end -end diff --git a/priv/repo/migrations/20231101035927_location.exs b/priv/repo/migrations/20231101035927_location.exs deleted file mode 100644 index 8e49852..0000000 --- a/priv/repo/migrations/20231101035927_location.exs +++ /dev/null @@ -1,17 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Location do - use Ecto.Migration - - def change do - create table(:locations, primary_key: false) do - add :id, :integer, primary_key: true - add :street_address, :string, size: 40 - add :postal_code, :string, size: 12 - add :city, :string, size: 30, null: false - add :state_province, :string, size: 25 - add :country_id, references(:countries), size: 2, null: false - end - - create index(:locations, [:country_id]) - - end -end diff --git a/priv/repo/migrations/20231101035928_department.exs b/priv/repo/migrations/20231101035928_department.exs deleted file mode 100644 index 58ca8ed..0000000 --- a/priv/repo/migrations/20231101035928_department.exs +++ /dev/null @@ -1,14 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Department do - use Ecto.Migration - - def change do - create table(:departments, primary_key: false) do - add :id, :integer, primary_key: true - add :department_name, :string, size: 30, null: false - add :location_id, references(:locations) - end - - create index(:departments, [:location_id]) - - end -end diff --git a/priv/repo/migrations/20231101035942_job.exs b/priv/repo/migrations/20231101035942_job.exs deleted file mode 100644 index d11aac6..0000000 --- a/priv/repo/migrations/20231101035942_job.exs +++ /dev/null @@ -1,12 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Job do - use Ecto.Migration - - def change do - create table(:jobs, primary_key: false) do - add :id, :integer, primary_key: true - add :job_title, :string, null: false, size: 35 - add :min_salary, :decimal, check: [8, 2] - add :max_salary, :decimal - end - end -end diff --git a/priv/repo/migrations/20231101035943_employee.exs b/priv/repo/migrations/20231101035943_employee.exs deleted file mode 100644 index 97b760c..0000000 --- a/priv/repo/migrations/20231101035943_employee.exs +++ /dev/null @@ -1,22 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Employee do - use Ecto.Migration - - def change do - create table(:employees, primary_key: false) do - add :id, :integer, primary_key: true - add :first_name, :string, size: 20 - add :last_name, :string, null: false, size: 25 - add :email, :string, null: false, size: 100 - add :phone_number, :string, null: false, size: 20 - add :hire_date, :date, null: false - add :salary, :decimal, null: false, check: [8, 2] - add :manager_id, :integer - add :job_id, references(:countries), null: false - add :department_id, references(:departments) - - end - - create index(:employees, [:job_id, :department_id]) - - end -end diff --git a/priv/repo/migrations/20231101035944_dependent.exs b/priv/repo/migrations/20231101035944_dependent.exs deleted file mode 100644 index 6700840..0000000 --- a/priv/repo/migrations/20231101035944_dependent.exs +++ /dev/null @@ -1,16 +0,0 @@ -defmodule SqlEcto.Repo.Migrations.Dependent do - use Ecto.Migration - - def change do - create table(:dependents, primary_key: false) do - add :id, :integer, primary_key: true - add :first_name, :string, null: false, size: 50 - add :last_name, :string, null: false, size: 50 - add :relationship, :string, null: false, size: 25 - add :employee_id, references(:employees), null: false - end - - create index(:dependents, [:employee_id]) - - end -end diff --git a/priv/repo/migrations/20231102033546_create_countries.exs b/priv/repo/migrations/20231102033546_create_countries.exs new file mode 100644 index 0000000..61627d4 --- /dev/null +++ b/priv/repo/migrations/20231102033546_create_countries.exs @@ -0,0 +1,11 @@ +defmodule SqlEcto.Repo.Migrations.CreateCountries do + use Ecto.Migration + + def change do + create table(:countries, primary_key: false) do + add :country_id, :string, primary_key: true, size: 2 + add :country_name, :string, size: 40 + add :region_id, references("regions", column: :region_id, type: :serial, on_update: :update_all, on_delete: :delete_all), null: false + end + end +end diff --git a/priv/repo/migrations/20231102035048_create_locations.exs b/priv/repo/migrations/20231102035048_create_locations.exs new file mode 100644 index 0000000..c5070b7 --- /dev/null +++ b/priv/repo/migrations/20231102035048_create_locations.exs @@ -0,0 +1,16 @@ +defmodule SqlEcto.Repo.Migrations.CreateLocations do + use Ecto.Migration + + def change do + create table("locations", primary_key: false) do + add :location_id, :serial, primary_key: true + add :street_address, :string, size: 40 + add :postal_code, :string, size: 12 + add :city, :string, size: 30, null: false + add :state_province, :string, size: 25 + add :country_id, references("countries", type: :string, column: :country_id, on_update: :update_all, on_delete: :delete_all), null: false, size: 2 + + end + + end +end diff --git a/priv/repo/migrations/20231102040321_create_departments.exs b/priv/repo/migrations/20231102040321_create_departments.exs new file mode 100644 index 0000000..1ba1a33 --- /dev/null +++ b/priv/repo/migrations/20231102040321_create_departments.exs @@ -0,0 +1,11 @@ +defmodule SqlEcto.Repo.Migrations.CreateDepartments do + use Ecto.Migration + + def change do + create table("departments", primary_key: false) do + add :department_id, :serial, primary_key: true + add :department_name, :string, size: 30, null: false + add :location_id, references("locations", type: :serial, column: :location_id, on_update: :update_all, on_delete: :delete_all) + end + end +end diff --git a/priv/repo/migrations/20231102041246_create_jobs.exs b/priv/repo/migrations/20231102041246_create_jobs.exs new file mode 100644 index 0000000..a1c94cd --- /dev/null +++ b/priv/repo/migrations/20231102041246_create_jobs.exs @@ -0,0 +1,12 @@ +defmodule SqlEcto.Repo.Migrations.CreateJobs do + use Ecto.Migration + + def change do + create table(:jobs, primary_key: false) do + add :job_id, :serial, primary_key: true + add :job_title, :string, size: 35, null: false + add :min_salary, :decimal, precision: 8, scale: 2 + add :max_salary, :decimal, precision: 8, scale: 2 + end + end +end diff --git a/priv/repo/migrations/20231102042459_create_employees.exs b/priv/repo/migrations/20231102042459_create_employees.exs new file mode 100644 index 0000000..5757a80 --- /dev/null +++ b/priv/repo/migrations/20231102042459_create_employees.exs @@ -0,0 +1,18 @@ +defmodule SqlEcto.Repo.Migrations.CreateEmployees do + use Ecto.Migration + + def change do + create table("employees", primary_key: false) do + add :employee_id, :serial, primary_key: true + add :first_name, :string, size: 20 + add :last_name, :string, size: 25, null: false + add :email, :string, size: 100, null: false + add :phone_number, :string, size: 20 + add :hire_date, :date, null: false + add :salary, :decimal, precision: 8, scale: 2, null: false + add :job_id, references("jobs", type: :serial, column: :job_id, on_update: :update_all, on_delete: :delete_all) + add :department_id, references("departments", type: :serial, column: :department_id, on_update: :update_all, on_delete: :delete_all) + add :manager_id, references("employees", type: :serial, column: :employee_id, on_update: :update_all, on_delete: :delete_all) + end + end +end diff --git a/priv/repo/migrations/20231102044510_create_dependents.exs b/priv/repo/migrations/20231102044510_create_dependents.exs new file mode 100644 index 0000000..b501bda --- /dev/null +++ b/priv/repo/migrations/20231102044510_create_dependents.exs @@ -0,0 +1,13 @@ +defmodule SqlEcto.Repo.Migrations.CreateDependents do + use Ecto.Migration + + def change do + create table("dependents", primary_key: false) do + add :dependent_id, :serial, primary_key: true + add :first_name, :string, size: 50, null: false + add :last_name, :string, size: 50, null: false + add :relationship, :string, size: 25, null: false + add :employee_id, references("employees", type: :serial, column: :employee_id, on_update: :update_all, on_delete: :delete_all), null: false + end + end +end