-- REGIONS START
CREATE TABLE REGIONS
(
  REGION_ID    NUMBER CONSTRAINT REGION_ID_NN   NOT NULL,
  REGION_NAME  VARCHAR2(25 BYTE)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;


CREATE UNIQUE INDEX REG_ID_PK ON REGIONS
(REGION_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


ALTER TABLE REGIONS ADD (
  CONSTRAINT REG_ID_PK
 PRIMARY KEY
 (REGION_ID)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

-- REGIONS END

-- COUNTRIES START
CREATE TABLE COUNTRIES
(
  COUNTRY_ID    CHAR(2 BYTE) CONSTRAINT COUNTRY_ID_NN NOT NULL,
  COUNTRY_NAME  VARCHAR2(40 BYTE),
  REGION_ID     NUMBER, 
  CONSTRAINT COUNTRY_C_ID_PK
 PRIMARY KEY
 (COUNTRY_ID)
)
ORGANIZATION INDEX
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
PCTUSED    0
STORAGE    (
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOPARALLEL
MONITORING;

COMMENT ON TABLE COUNTRIES IS 'country table. Contains 25 rows. References with locations table.';

COMMENT ON COLUMN COUNTRIES.COUNTRY_ID IS 'Primary key of countries table.';

COMMENT ON COLUMN COUNTRIES.COUNTRY_NAME IS 'Country name';

COMMENT ON COLUMN COUNTRIES.REGION_ID IS 'Region ID for the country. Foreign key to region_id column in the departments table.';




CREATE SYNONYM OE.COUNTRIES FOR COUNTRIES;


ALTER TABLE COUNTRIES ADD (
  CONSTRAINT COUNTR_REG_FK 
 FOREIGN KEY (REGION_ID) 
 REFERENCES REGIONS (REGION_ID));

GRANT REFERENCES, SELECT ON COUNTRIES TO OE;
-- COUNTRIES END

-- LOCATIONS START
CREATE TABLE LOCATIONS
(
  LOCATION_ID     NUMBER(4),
  STREET_ADDRESS  VARCHAR2(40 BYTE),
  POSTAL_CODE     VARCHAR2(12 BYTE),
  CITY            VARCHAR2(30 BYTE) CONSTRAINT LOC_CITY_NN NOT NULL,
  STATE_PROVINCE  VARCHAR2(25 BYTE),
  COUNTRY_ID      CHAR(2 BYTE)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

COMMENT ON TABLE LOCATIONS IS 'Locations table that contains specific address of a specific office,
warehouse, and/or production site of a company. Does not store addresses /
locations of customers. Contains 23 rows; references with the
departments and countries tables. ';

COMMENT ON COLUMN LOCATIONS.LOCATION_ID IS 'Primary key of locations table';

COMMENT ON COLUMN LOCATIONS.STREET_ADDRESS IS 'Street address of an office, warehouse, or production site of a company.
Contains building number and street name';

COMMENT ON COLUMN LOCATIONS.POSTAL_CODE IS 'Postal code of the location of an office, warehouse, or production site
of a company. ';

COMMENT ON COLUMN LOCATIONS.CITY IS 'A not null column that shows city where an office, warehouse, or
production site of a company is located. ';

COMMENT ON COLUMN LOCATIONS.STATE_PROVINCE IS 'State or Province where an office, warehouse, or production site of a
company is located.';

COMMENT ON COLUMN LOCATIONS.COUNTRY_ID IS 'Country where an office, warehouse, or production site of a company is
located. Foreign key to country_id column of the countries table.';


CREATE INDEX LOC_CITY_IX ON LOCATIONS
(CITY)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX LOC_COUNTRY_IX ON LOCATIONS
(COUNTRY_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE UNIQUE INDEX LOC_ID_PK ON LOCATIONS
(LOCATION_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX LOC_STATE_PROVINCE_IX ON LOCATIONS
(STATE_PROVINCE)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE SYNONYM OE.LOCATIONS FOR LOCATIONS;


ALTER TABLE LOCATIONS ADD (
  CONSTRAINT LOC_ID_PK
 PRIMARY KEY
 (LOCATION_ID)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

ALTER TABLE LOCATIONS ADD (
  CONSTRAINT LOC_C_ID_FK 
 FOREIGN KEY (COUNTRY_ID) 
 REFERENCES COUNTRIES (COUNTRY_ID));

GRANT REFERENCES, SELECT ON LOCATIONS TO OE;
--LOCATIONS END

-- JOBS START
CREATE TABLE JOBS
(
  JOB_ID      VARCHAR2(10 BYTE),
  JOB_TITLE   VARCHAR2(35 BYTE) CONSTRAINT JOB_TITLE_NN NOT NULL,
  MIN_SALARY  NUMBER(6),
  MAX_SALARY  NUMBER(6)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

COMMENT ON TABLE JOBS IS 'jobs table with job titles and salary ranges. Contains 19 rows.
References with employees and job_history table.';

COMMENT ON COLUMN JOBS.JOB_ID IS 'Primary key of jobs table.';

COMMENT ON COLUMN JOBS.JOB_TITLE IS 'A not null column that shows job title, e.g. AD_VP, FI_ACCOUNTANT';

COMMENT ON COLUMN JOBS.MIN_SALARY IS 'Minimum salary for a job title.';

COMMENT ON COLUMN JOBS.MAX_SALARY IS 'Maximum salary for a job title';


CREATE UNIQUE INDEX JOB_ID_PK ON JOBS
(JOB_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE SYNONYM OE.JOBS FOR JOBS;


ALTER TABLE JOBS ADD (
  CONSTRAINT JOB_ID_PK
 PRIMARY KEY
 (JOB_ID)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

GRANT SELECT ON JOBS TO OE;
-- JOBS END

-- EmPLOYEES START
CREATE TABLE EMPLOYEES
(
  EMPLOYEE_ID     NUMBER(6),
  FIRST_NAME      VARCHAR2(20 BYTE),
  LAST_NAME       VARCHAR2(25 BYTE) CONSTRAINT EMP_LAST_NAME_NN NOT NULL,
  EMAIL           VARCHAR2(25 BYTE) CONSTRAINT EMP_EMAIL_NN NOT NULL,
  PHONE_NUMBER    VARCHAR2(20 BYTE),
  HIRE_DATE       DATE CONSTRAINT EMP_HIRE_DATE_NN NOT NULL,
  JOB_ID          VARCHAR2(10 BYTE) CONSTRAINT EMP_JOB_NN NOT NULL,
  SALARY          NUMBER(8,2),
  COMMISSION_PCT  NUMBER(2,2),
  MANAGER_ID      NUMBER(6),
  DEPARTMENT_ID   NUMBER(4)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

COMMENT ON TABLE EMPLOYEES IS 'employees table. Contains 107 rows. References with departments,
jobs, job_history tables. Contains a self reference.';

COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID IS 'Primary key of employees table.';

COMMENT ON COLUMN EMPLOYEES.FIRST_NAME IS 'First name of the employee. A not null column.';

COMMENT ON COLUMN EMPLOYEES.LAST_NAME IS 'Last name of the employee. A not null column.';

COMMENT ON COLUMN EMPLOYEES.EMAIL IS 'Email id of the employee';

COMMENT ON COLUMN EMPLOYEES.PHONE_NUMBER IS 'Phone number of the employee; includes country code and area code';

COMMENT ON COLUMN EMPLOYEES.HIRE_DATE IS 'Date when the employee started on this job. A not null column.';

COMMENT ON COLUMN EMPLOYEES.JOB_ID IS 'Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.';

COMMENT ON COLUMN EMPLOYEES.SALARY IS 'Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)';

COMMENT ON COLUMN EMPLOYEES.COMMISSION_PCT IS 'Commission percentage of the employee; Only employees in sales
department elgible for commission percentage';

COMMENT ON COLUMN EMPLOYEES.MANAGER_ID IS 'Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)';

COMMENT ON COLUMN EMPLOYEES.DEPARTMENT_ID IS 'Department id where employee works; foreign key to department_id
column of the departments table';


CREATE INDEX EMP_DEPARTMENT_IX ON EMPLOYEES
(DEPARTMENT_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE UNIQUE INDEX EMP_EMAIL_UK ON EMPLOYEES
(EMAIL)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE UNIQUE INDEX EMP_EMP_ID_PK ON EMPLOYEES
(EMPLOYEE_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX EMP_JOB_IX ON EMPLOYEES
(JOB_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX EMP_MANAGER_IX ON EMPLOYEES
(MANAGER_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX EMP_NAME_IX ON EMPLOYEES
(LAST_NAME, FIRST_NAME)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE OR REPLACE TRIGGER secure_employees
  BEFORE INSERT OR UPDATE OR DELETE ON EMPLOYEES 
DISABLE
BEGIN
  secure_dml;
END secure_employees;
/


CREATE OR REPLACE TRIGGER update_job_history
  AFTER UPDATE OF job_id, department_id ON EMPLOYEES   FOR EACH ROW
BEGIN
  add_job_history(:old.employee_id, :old.hire_date, sysdate,
                  :old.job_id, :old.department_id);
END;
/


CREATE SYNONYM OE.EMPLOYEES FOR EMPLOYEES;


ALTER TABLE EMPLOYEES ADD (
  CONSTRAINT EMP_SALARY_MIN
 CHECK (salary > 0),
  CONSTRAINT EMP_EMP_ID_PK
 PRIMARY KEY
 (EMPLOYEE_ID)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ),
  CONSTRAINT EMP_EMAIL_UK
 UNIQUE (EMAIL)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

ALTER TABLE EMPLOYEES ADD (
  CONSTRAINT EMP_DEPT_FK 
 FOREIGN KEY (DEPARTMENT_ID) 
 REFERENCES DEPARTMENTS (DEPARTMENT_ID),
  CONSTRAINT EMP_JOB_FK 
 FOREIGN KEY (JOB_ID) 
 REFERENCES JOBS (JOB_ID),
  CONSTRAINT EMP_MANAGER_FK 
 FOREIGN KEY (MANAGER_ID) 
 REFERENCES EMPLOYEES (EMPLOYEE_ID));

GRANT REFERENCES, SELECT ON EMPLOYEES TO OE;
--EMPLOYEES END

-- DEPARTMENTS START
CREATE TABLE DEPARTMENTS
(
  DEPARTMENT_ID    NUMBER(4),
  DEPARTMENT_NAME  VARCHAR2(30 BYTE) CONSTRAINT DEPT_NAME_NN NOT NULL,
  MANAGER_ID       NUMBER(6),
  LOCATION_ID      NUMBER(4)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

COMMENT ON TABLE DEPARTMENTS IS 'Departments table that shows details of departments where employees
work. Contains 27 rows; references with locations, employees, and job_history tables.';

COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of departments table.';

COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting. ';

COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';

COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a department is located. Foreign key to location_id column of locations table.';


CREATE UNIQUE INDEX DEPT_ID_PK ON DEPARTMENTS
(DEPARTMENT_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS
(LOCATION_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE SYNONYM OE.DEPARTMENTS FOR DEPARTMENTS;


ALTER TABLE DEPARTMENTS ADD (
  CONSTRAINT DEPT_ID_PK
 PRIMARY KEY
 (DEPARTMENT_ID)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

ALTER TABLE DEPARTMENTS ADD (
  CONSTRAINT DEPT_LOC_FK 
 FOREIGN KEY (LOCATION_ID) 
 REFERENCES LOCATIONS (LOCATION_ID),
  CONSTRAINT DEPT_MGR_FK 
 FOREIGN KEY (MANAGER_ID) 
 REFERENCES EMPLOYEES (EMPLOYEE_ID));

GRANT SELECT ON DEPARTMENTS TO OE;
-- DEPARTMENTS END

-- JOB_HISTORY START
CREATE TABLE JOB_HISTORY
(
  EMPLOYEE_ID    NUMBER(6) CONSTRAINT JHIST_EMPLOYEE_NN NOT NULL,
  START_DATE     DATE CONSTRAINT JHIST_START_DATE_NN NOT NULL,
  END_DATE       DATE CONSTRAINT JHIST_END_DATE_NN NOT NULL,
  JOB_ID         VARCHAR2(10 BYTE) CONSTRAINT JHIST_JOB_NN NOT NULL,
  DEPARTMENT_ID  NUMBER(4)
)
TABLESPACE EXAMPLE
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOLOGGING 
NOCOMPRESS 
NOCACHE
NOPARALLEL
MONITORING;

COMMENT ON TABLE JOB_HISTORY IS 'Table that stores job history of the employees. If an employee
changes departments within the job or changes jobs within the department,
new rows get inserted into this table with old job information of the
employee. Contains a complex primary key: employee_id+start_date.
Contains 25 rows. References with jobs, employees, and departments tables.';

COMMENT ON COLUMN JOB_HISTORY.EMPLOYEE_ID IS 'A not null column in the complex primary key employee_id+start_date.
Foreign key to employee_id column of the employee table';

COMMENT ON COLUMN JOB_HISTORY.START_DATE IS 'A not null column in the complex primary key employee_id+start_date.
Must be less than the end_date of the job_history table. (enforced by
constraint jhist_date_interval)';

COMMENT ON COLUMN JOB_HISTORY.END_DATE IS 'Last day of the employee in this job role. A not null column. Must be
greater than the start_date of the job_history table.
(enforced by constraint jhist_date_interval)';

COMMENT ON COLUMN JOB_HISTORY.JOB_ID IS 'Job role in which the employee worked in the past; foreign key to
job_id column in the jobs table. A not null column.';

COMMENT ON COLUMN JOB_HISTORY.DEPARTMENT_ID IS 'Department id in which the employee worked in the past; foreign key to deparment_id column in the departments table';


CREATE INDEX JHIST_DEPARTMENT_IX ON JOB_HISTORY
(DEPARTMENT_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE UNIQUE INDEX JHIST_EMP_ID_ST_DATE_PK ON JOB_HISTORY
(EMPLOYEE_ID, START_DATE)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX JHIST_EMPLOYEE_IX ON JOB_HISTORY
(EMPLOYEE_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE INDEX JHIST_JOB_IX ON JOB_HISTORY
(JOB_ID)
NOLOGGING
TABLESPACE EXAMPLE
PCTFREE    10
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            NEXT             1M
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
NOPARALLEL;


CREATE SYNONYM OE.JOB_HISTORY FOR JOB_HISTORY;


ALTER TABLE JOB_HISTORY ADD (
  CONSTRAINT JHIST_DATE_INTERVAL
 CHECK (end_date > start_date),
  CONSTRAINT JHIST_EMP_ID_ST_DATE_PK
 PRIMARY KEY
 (EMPLOYEE_ID, START_DATE)
    USING INDEX 
    TABLESPACE EXAMPLE
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
               ));

ALTER TABLE JOB_HISTORY ADD (
  CONSTRAINT JHIST_DEPT_FK 
 FOREIGN KEY (DEPARTMENT_ID) 
 REFERENCES DEPARTMENTS (DEPARTMENT_ID),
  CONSTRAINT JHIST_EMP_FK 
 FOREIGN KEY (EMPLOYEE_ID) 
 REFERENCES EMPLOYEES (EMPLOYEE_ID),
  CONSTRAINT JHIST_JOB_FK 
 FOREIGN KEY (JOB_ID) 
 REFERENCES JOBS (JOB_ID));

GRANT SELECT ON JOB_HISTORY TO OE;
--JOB_HISTORY END

-- VIEW EMPLOYEE_DETAILS START
/* Formatted on 07.04.2013 15:37:14 (QP5 v5.136.908.31019) */
CREATE OR REPLACE FORCE VIEW EMP_DETAILS_VIEW
(
   EMPLOYEE_ID,
   JOB_ID,
   MANAGER_ID,
   DEPARTMENT_ID,
   LOCATION_ID,
   COUNTRY_ID,
   FIRST_NAME,
   LAST_NAME,
   SALARY,
   COMMISSION_PCT,
   DEPARTMENT_NAME,
   JOB_TITLE,
   CITY,
   STATE_PROVINCE,
   COUNTRY_NAME,
   REGION_NAME
)
AS
   SELECT e.employee_id,
          e.job_id,
          e.manager_id,
          e.department_id,
          d.location_id,
          l.country_id,
          e.first_name,
          e.last_name,
          e.salary,
          e.commission_pct,
          d.department_name,
          j.job_title,
          l.city,
          l.state_province,
          c.country_name,
          r.region_name
     FROM employees e,
          departments d,
          jobs j,
          locations l,
          countries c,
          regions r
    WHERE     e.department_id = d.department_id
          AND d.location_id = l.location_id
          AND l.country_id = c.country_id
          AND c.region_id = r.region_id
          AND j.job_id = e.job_id
   WITH READ ONLY;

 -- VIEW EMPLOYEE_DETAILS END
 
 -- DATA INSERTS
 -- REGIONS
insert into regions values (1,'Europe');
insert into regions values (2,'Americas');
insert into regions values (3,'Asia');
insert into regions values (4,'Middle East and Africa');

-- COUNTRIES
insert into countries values ('AR','Argentina','2');
insert into countries values ('AU','Australia','3');
insert into countries values ('BE','Belgium','1');
insert into countries values ('BR','Brazil','2');
insert into countries values ('CA','Canada','2');
insert into countries values ('CH','Switzerland','1');
insert into countries values ('CN','China','3');
insert into countries values ('DE','Germany','1');
insert into countries values ('DK','Denmark','1');
insert into countries values ('EG','Egypt','4');
insert into countries values ('FR','France','1');
insert into countries values ('IL','Israel','4');
insert into countries values ('IN','India','3');
insert into countries values ('IT','Italy','1');
insert into countries values ('JP','Japan','3');
insert into countries values ('KW','Kuwait','4');
insert into countries values ('ML','Malaysia','3');
insert into countries values ('MX','Mexico','2');
insert into countries values ('NG','Nigeria','4');
insert into countries values ('NL','Netherlands','1');
insert into countries values ('SG','Singapore','3');
insert into countries values ('UK','United Kingdom','1');
insert into countries values ('US','United States of America','2');
insert into countries values ('ZM','Zambia','4');
insert into countries values ('ZW','Zimbabwe','4');

-- LOCATIONS
insert into locations values ('1000','1297 Via Cola di Rie','00989','Roma','','IT');
insert into locations values ('1100','93091 Calle della Testa','10934','Venice','','IT');
insert into locations values ('1200','2017 Shinjuku-ku','1689','Tokyo','Tokyo Prefecture','JP');
insert into locations values ('1300','9450 Kamiya-cho','6823','Hiroshima','','JP');
insert into locations values ('1400','2014 Jabberwocky Rd','26192','Southlake','Texas','US');
insert into locations values ('1500','2011 Interiors Blvd','99236','South San Francisco','California','US');
insert into locations values ('1600','2007 Zagora St','50090','South Brunswick','New Jersey','US');
insert into locations values ('1700','2004 Charade Rd','98199','Seattle','Washington','US');
insert into locations values ('1800','147 Spadina Ave','M5V 2L7','Toronto','Ontario','CA');
insert into locations values ('1900','6092 Boxwood St','YSW 9T2','Whitehorse','Yukon','CA');
insert into locations values ('2000','40-5-12 Laogianggen','190518','Beijing','','CN');
insert into locations values ('2100','1298 Vileparle (E)','490231','Bombay','Maharashtra','IN');
insert into locations values ('2200','12-98 Victoria Street','2901','Sydney','New South Wales','AU');
insert into locations values ('2300','198 Clementi North','540198','Singapore','','SG');
insert into locations values ('2400','8204 Arthur St','','London','','UK');
insert into locations values ('2500','Magdalen Centre, The Oxford Science Park','OX9 9ZB','Oxford','Oxford','UK');
insert into locations values ('2600','9702 Chester Road','09629850293','Stretford','Manchester','UK');
insert into locations values ('2700','Schwanthalerstr. 7031','80925','Munich','Bavaria','DE');
insert into locations values ('2800','Rua Frei Caneca 1360 ','01307-002','Sao Paulo','Sao Paulo','BR');
insert into locations values ('2900','20 Rue des Corps-Saints','1730','Geneva','Geneve','CH');
insert into locations values ('3000','Murtenstrasse 921','3095','Bern','BE','CH');
insert into locations values ('3100','Pieter Breughelstraat 837','3029SK','Utrecht','Utrecht','NL');
insert into locations values ('3200','Mariano Escobedo 9991','11932','Mexico City','Distrito Federal,','MX');

-- JOBS
insert into jobs values ('AD_PRES','President','20080','40000');
insert into jobs values ('AD_VP','Administration Vice President','15000','30000');
insert into jobs values ('AD_ASST','Administration Assistant','3000','6000');
insert into jobs values ('FI_MGR','Finance Manager','8200','16000');
insert into jobs values ('FI_ACCOUNT','Accountant','4200','9000');
insert into jobs values ('AC_MGR','Accounting Manager','8200','16000');
insert into jobs values ('AC_ACCOUNT','Public Accountant','4200','9000');
insert into jobs values ('SA_MAN','Sales Manager','10000','20080');
insert into jobs values ('SA_REP','Sales Representative','6000','12008');
insert into jobs values ('PU_MAN','Purchasing Manager','8000','15000');
insert into jobs values ('PU_CLERK','Purchasing Clerk','2500','5500');
insert into jobs values ('ST_MAN','Stock Manager','5500','8500');
insert into jobs values ('ST_CLERK','Stock Clerk','2008','5000');
insert into jobs values ('SH_CLERK','Shipping Clerk','2500','5500');
insert into jobs values ('IT_PROG','Programmer','4000','10000');
insert into jobs values ('MK_MAN','Marketing Manager','9000','15000');
insert into jobs values ('MK_REP','Marketing Representative','4000','9000');
insert into jobs values ('HR_REP','Human Resources Representative','4000','9000');
insert into jobs values ('PR_REP','Public Relations Representative','4500','10500');

--EMPLOYEES
insert into employees values ('198','Donald','OConnell','DOCONNEL','650.507.9833','21/06/2007','SH_CLERK','2600','','124','50');
insert into employees values ('199','Douglas','Grant','DGRANT','650.507.9844','13/01/2008','SH_CLERK','2600','','124','50');
insert into employees values ('200','Jennifer','Whalen','JWHALEN','515.123.4444','17/09/2003','AD_ASST','4400','','101','10');
insert into employees values ('201','Michael','Hartstein','MHARTSTE','515.123.5555','17/02/2004','MK_MAN','13000','','100','20');
insert into employees values ('202','Pat','Fay','PFAY','603.123.6666','17/08/2005','MK_REP','6000','','201','20');
insert into employees values ('203','Susan','Mavris','SMAVRIS','515.123.7777','07/06/2002','HR_REP','6500','','101','40');
insert into employees values ('204','Hermann','Baer','HBAER','515.123.8888','07/06/2002','PR_REP','10000','','101','70');
insert into employees values ('205','Shelley','Higgins','SHIGGINS','515.123.8080','07/06/2002','AC_MGR','12008','','101','110');
insert into employees values ('206','William','Gietz','WGIETZ','515.123.8181','07/06/2002','AC_ACCOUNT','8300','','205','110');
insert into employees values ('100','Steven','King','SKING','515.123.4567','17/06/2003','AD_PRES','24000','','','90');
insert into employees values ('101','Neena','Kochhar','NKOCHHAR','515.123.4568','21/09/2005','AD_VP','17000','','100','90');
insert into employees values ('102','Lex','De Haan','LDEHAAN','515.123.4569','13/01/2001','AD_VP','17000','','100','90');
insert into employees values ('103','Alexander','Hunold','AHUNOLD','590.423.4567','03/01/2006','IT_PROG','9000','','102','60');
insert into employees values ('104','Bruce','Ernst','BERNST','590.423.4568','21/05/2007','IT_PROG','6000','','103','60');
insert into employees values ('105','David','Austin','DAUSTIN','590.423.4569','25/06/2005','IT_PROG','4800','','103','60');
insert into employees values ('106','Valli','Pataballa','VPATABAL','590.423.4560','05/02/2006','IT_PROG','4800','','103','60');
insert into employees values ('107','Diana','Lorentz','DLORENTZ','590.423.5567','07/02/2007','IT_PROG','4200','','103','60');
insert into employees values ('108','Nancy','Greenberg','NGREENBE','515.124.4569','17/08/2002','FI_MGR','12008','','101','100');
insert into employees values ('109','Daniel','Faviet','DFAVIET','515.124.4169','16/08/2002','FI_ACCOUNT','9000','','108','100');
insert into employees values ('110','John','Chen','JCHEN','515.124.4269','28/09/2005','FI_ACCOUNT','8200','','108','100');
insert into employees values ('111','Ismael','Sciarra','ISCIARRA','515.124.4369','30/09/2005','FI_ACCOUNT','7700','','108','100');
insert into employees values ('112','Jose Manuel','Urman','JMURMAN','515.124.4469','07/03/2006','FI_ACCOUNT','7800','','108','100');
insert into employees values ('113','Luis','Popp','LPOPP','515.124.4567','07/12/2007','FI_ACCOUNT','6900','','108','100');
insert into employees values ('114','Den','Raphaely','DRAPHEAL','515.127.4561','07/12/2002','PU_MAN','11000','','100','30');
insert into employees values ('115','Alexander','Khoo','AKHOO','515.127.4562','18/05/2003','PU_CLERK','3100','','114','30');
insert into employees values ('116','Shelli','Baida','SBAIDA','515.127.4563','24/12/2005','PU_CLERK','2900','','114','30');
insert into employees values ('117','Sigal','Tobias','STOBIAS','515.127.4564','24/07/2005','PU_CLERK','2800','','114','30');
insert into employees values ('118','Guy','Himuro','GHIMURO','515.127.4565','15/11/2006','PU_CLERK','2600','','114','30');
insert into employees values ('119','Karen','Colmenares','KCOLMENA','515.127.4566','10/08/2007','PU_CLERK','2500','','114','30');
insert into employees values ('120','Matthew','Weiss','MWEISS','650.123.1234','18/07/2004','ST_MAN','8000','','100','50');
insert into employees values ('121','Adam','Fripp','AFRIPP','650.123.2234','10/04/2005','ST_MAN','8200','','100','50');
insert into employees values ('122','Payam','Kaufling','PKAUFLIN','650.123.3234','01/05/2003','ST_MAN','7900','','100','50');
insert into employees values ('123','Shanta','Vollman','SVOLLMAN','650.123.4234','10/10/2005','ST_MAN','6500','','100','50');
insert into employees values ('124','Kevin','Mourgos','KMOURGOS','650.123.5234','16/11/2007','ST_MAN','5800','','100','50');
insert into employees values ('125','Julia','Nayer','JNAYER','650.124.1214','16/07/2005','ST_CLERK','3200','','120','50');
insert into employees values ('126','Irene','Mikkilineni','IMIKKILI','650.124.1224','28/09/2006','ST_CLERK','2700','','120','50');
insert into employees values ('127','James','Landry','JLANDRY','650.124.1334','14/01/2007','ST_CLERK','2400','','120','50');
insert into employees values ('128','Steven','Markle','SMARKLE','650.124.1434','08/03/2008','ST_CLERK','2200','','120','50');
insert into employees values ('129','Laura','Bissot','LBISSOT','650.124.5234','20/08/2005','ST_CLERK','3300','','121','50');
insert into employees values ('130','Mozhe','Atkinson','MATKINSO','650.124.6234','30/10/2005','ST_CLERK','2800','','121','50');
insert into employees values ('131','James','Marlow','JAMRLOW','650.124.7234','16/02/2005','ST_CLERK','2500','','121','50');
insert into employees values ('132','TJ','Olson','TJOLSON','650.124.8234','10/04/2007','ST_CLERK','2100','','121','50');
insert into employees values ('133','Jason','Mallin','JMALLIN','650.127.1934','14/06/2004','ST_CLERK','3300','','122','50');
insert into employees values ('134','Michael','Rogers','MROGERS','650.127.1834','26/08/2006','ST_CLERK','2900','','122','50');
insert into employees values ('135','Ki','Gee','KGEE','650.127.1734','12/12/2007','ST_CLERK','2400','','122','50');
insert into employees values ('136','Hazel','Philtanker','HPHILTAN','650.127.1634','06/02/2008','ST_CLERK','2200','','122','50');
insert into employees values ('137','Renske','Ladwig','RLADWIG','650.121.1234','14/07/2003','ST_CLERK','3600','','123','50');
insert into employees values ('138','Stephen','Stiles','SSTILES','650.121.2034','26/10/2005','ST_CLERK','3200','','123','50');
insert into employees values ('139','John','Seo','JSEO','650.121.2019','12/02/2006','ST_CLERK','2700','','123','50');
insert into employees values ('140','Joshua','Patel','JPATEL','650.121.1834','06/04/2006','ST_CLERK','2500','','123','50');
insert into employees values ('141','Trenna','Rajs','TRAJS','650.121.8009','17/10/2003','ST_CLERK','3500','','124','50');
insert into employees values ('142','Curtis','Davies','CDAVIES','650.121.2994','29/01/2005','ST_CLERK','3100','','124','50');
insert into employees values ('143','Randall','Matos','RMATOS','650.121.2874','15/03/2006','ST_CLERK','2600','','124','50');
insert into employees values ('144','Peter','Vargas','PVARGAS','650.121.2004','09/07/2006','ST_CLERK','2500','','124','50');
insert into employees values ('145','John','Russell','JRUSSEL','011.44.1344.429268','01/10/2004','SA_MAN','14000',',4','100','80');
insert into employees values ('146','Karen','Partners','KPARTNER','011.44.1344.467268','05/01/2005','SA_MAN','13500',',3','100','80');
insert into employees values ('147','Alberto','Errazuriz','AERRAZUR','011.44.1344.429278','10/03/2005','SA_MAN','12000',',3','100','80');
insert into employees values ('148','Gerald','Cambrault','GCAMBRAU','011.44.1344.619268','15/10/2007','SA_MAN','11000',',3','100','80');
insert into employees values ('149','Eleni','Zlotkey','EZLOTKEY','011.44.1344.429018','29/01/2008','SA_MAN','10500',',2','100','80');
insert into employees values ('150','Peter','Tucker','PTUCKER','011.44.1344.129268','30/01/2005','SA_REP','10000',',3','145','80');
insert into employees values ('151','David','Bernstein','DBERNSTE','011.44.1344.345268','24/03/2005','SA_REP','9500',',25','145','80');
insert into employees values ('152','Peter','Hall','PHALL','011.44.1344.478968','20/08/2005','SA_REP','9000',',25','145','80');
insert into employees values ('153','Christopher','Olsen','COLSEN','011.44.1344.498718','30/03/2006','SA_REP','8000',',2','145','80');
insert into employees values ('154','Nanette','Cambrault','NCAMBRAU','011.44.1344.987668','09/12/2006','SA_REP','7500',',2','145','80');
insert into employees values ('155','Oliver','Tuvault','OTUVAULT','011.44.1344.486508','23/11/2007','SA_REP','7000',',15','145','80');
insert into employees values ('156','Janette','King','JKING','011.44.1345.429268','30/01/2004','SA_REP','10000',',35','146','80');
insert into employees values ('157','Patrick','Sully','PSULLY','011.44.1345.929268','04/03/2004','SA_REP','9500',',35','146','80');
insert into employees values ('158','Allan','McEwen','AMCEWEN','011.44.1345.829268','01/08/2004','SA_REP','9000',',35','146','80');
insert into employees values ('159','Lindsey','Smith','LSMITH','011.44.1345.729268','10/03/2005','SA_REP','8000',',3','146','80');
insert into employees values ('160','Louise','Doran','LDORAN','011.44.1345.629268','15/12/2005','SA_REP','7500',',3','146','80');
insert into employees values ('161','Sarath','Sewall','SSEWALL','011.44.1345.529268','03/11/2006','SA_REP','7000',',25','146','80');
insert into employees values ('162','Clara','Vishney','CVISHNEY','011.44.1346.129268','11/11/2005','SA_REP','10500',',25','147','80');
insert into employees values ('163','Danielle','Greene','DGREENE','011.44.1346.229268','19/03/2007','SA_REP','9500',',15','147','80');
insert into employees values ('164','Mattea','Marvins','MMARVINS','011.44.1346.329268','24/01/2008','SA_REP','7200',',1','147','80');
insert into employees values ('165','David','Lee','DLEE','011.44.1346.529268','23/02/2008','SA_REP','6800',',1','147','80');
insert into employees values ('166','Sundar','Ande','SANDE','011.44.1346.629268','24/03/2008','SA_REP','6400',',1','147','80');
insert into employees values ('167','Amit','Banda','ABANDA','011.44.1346.729268','21/04/2008','SA_REP','6200',',1','147','80');
insert into employees values ('168','Lisa','Ozer','LOZER','011.44.1343.929268','11/03/2005','SA_REP','11500',',25','148','80');
insert into employees values ('169','Harrison','Bloom','HBLOOM','011.44.1343.829268','23/03/2006','SA_REP','10000',',2','148','80');
insert into employees values ('170','Tayler','Fox','TFOX','011.44.1343.729268','24/01/2006','SA_REP','9600',',2','148','80');
insert into employees values ('171','William','Smith','WSMITH','011.44.1343.629268','23/02/2007','SA_REP','7400',',15','148','80');
insert into employees values ('172','Elizabeth','Bates','EBATES','011.44.1343.529268','24/03/2007','SA_REP','7300',',15','148','80');
insert into employees values ('173','Sundita','Kumar','SKUMAR','011.44.1343.329268','21/04/2008','SA_REP','6100',',1','148','80');
insert into employees values ('174','Ellen','Abel','EABEL','011.44.1644.429267','11/05/2004','SA_REP','11000',',3','149','80');
insert into employees values ('175','Alyssa','Hutton','AHUTTON','011.44.1644.429266','19/03/2005','SA_REP','8800',',25','149','80');
insert into employees values ('176','Jonathon','Taylor','JTAYLOR','011.44.1644.429265','24/03/2006','SA_REP','8600',',2','149','80');
insert into employees values ('177','Jack','Livingston','JLIVINGS','011.44.1644.429264','23/04/2006','SA_REP','8400',',2','149','80');
insert into employees values ('178','Kimberely','Grant','KGRANT','011.44.1644.429263','24/05/2007','SA_REP','7000',',15','149','');
insert into employees values ('179','Charles','Johnson','CJOHNSON','011.44.1644.429262','04/01/2008','SA_REP','6200',',1','149','80');
insert into employees values ('180','Winston','Taylor','WTAYLOR','650.507.9876','24/01/2006','SH_CLERK','3200','','120','50');
insert into employees values ('181','Jean','Fleaur','JFLEAUR','650.507.9877','23/02/2006','SH_CLERK','3100','','120','50');
insert into employees values ('182','Martha','Sullivan','MSULLIVA','650.507.9878','21/06/2007','SH_CLERK','2500','','120','50');
insert into employees values ('183','Girard','Geoni','GGEONI','650.507.9879','03/02/2008','SH_CLERK','2800','','120','50');
insert into employees values ('184','Nandita','Sarchand','NSARCHAN','650.509.1876','27/01/2004','SH_CLERK','4200','','121','50');
insert into employees values ('185','Alexis','Bull','ABULL','650.509.2876','20/02/2005','SH_CLERK','4100','','121','50');
insert into employees values ('186','Julia','Dellinger','JDELLING','650.509.3876','24/06/2006','SH_CLERK','3400','','121','50');
insert into employees values ('187','Anthony','Cabrio','ACABRIO','650.509.4876','07/02/2007','SH_CLERK','3000','','121','50');
insert into employees values ('188','Kelly','Chung','KCHUNG','650.505.1876','14/06/2005','SH_CLERK','3800','','122','50');
insert into employees values ('189','Jennifer','Dilly','JDILLY','650.505.2876','13/08/2005','SH_CLERK','3600','','122','50');
insert into employees values ('190','Timothy','Gates','TGATES','650.505.3876','11/07/2006','SH_CLERK','2900','','122','50');
insert into employees values ('191','Randall','Perkins','RPERKINS','650.505.4876','19/12/2007','SH_CLERK','2500','','122','50');
insert into employees values ('192','Sarah','Bell','SBELL','650.501.1876','04/02/2004','SH_CLERK','4000','','123','50');
insert into employees values ('193','Britney','Everett','BEVERETT','650.501.2876','03/03/2005','SH_CLERK','3900','','123','50');
insert into employees values ('194','Samuel','McCain','SMCCAIN','650.501.3876','01/07/2006','SH_CLERK','3200','','123','50');
insert into employees values ('195','Vance','Jones','VJONES','650.501.4876','17/03/2007','SH_CLERK','2800','','123','50');
insert into employees values ('196','Alana','Walsh','AWALSH','650.507.9811','24/04/2006','SH_CLERK','3100','','124','50');
insert into employees values ('197','Kevin','Feeney','KFEENEY','650.507.9822','23/05/2006','SH_CLERK','3000','','124','50');

-- DEPARTMENTS
insert into departments values ('10','Administration','200','1700');
insert into departments values ('20','Marketing','201','1800');
insert into departments values ('30','Purchasing','114','1700');
insert into departments values ('40','Human Resources','203','2400');
insert into departments values ('50','Shipping','121','1500');
insert into departments values ('60','IT','103','1400');
insert into departments values ('70','Public Relations','204','2700');
insert into departments values ('80','Sales','145','2500');
insert into departments values ('90','Executive','100','1700');
insert into departments values ('100','Finance','108','1700');
insert into departments values ('110','Accounting','205','1700');
insert into departments values ('120','Treasury','','1700');
insert into departments values ('130','Corporate Tax','','1700');
insert into departments values ('140','Control And Credit','','1700');
insert into departments values ('150','Shareholder Services','','1700');
insert into departments values ('160','Benefits','','1700');
insert into departments values ('170','Manufacturing','','1700');
insert into departments values ('180','Construction','','1700');
insert into departments values ('190','Contracting','','1700');
insert into departments values ('200','Operations','','1700');
insert into departments values ('210','IT Support','','1700');
insert into departments values ('220','NOC','','1700');
insert into departments values ('230','IT Helpdesk','','1700');
insert into departments values ('240','Government Sales','','1700');
insert into departments values ('250','Retail Sales','','1700');
insert into departments values ('260','Recruiting','','1700');
insert into departments values ('270','Payroll','','1700');

-- JOB_HISTORY
insert into job_history values ('102','13/01/2001','24/07/2006','IT_PROG','60');
insert into job_history values ('101','21/09/1997','27/10/2001','AC_ACCOUNT','110');
insert into job_history values ('101','28/10/2001','15/03/2005','AC_MGR','110');
insert into job_history values ('201','17/02/2004','19/12/2007','MK_REP','20');
insert into job_history values ('114','24/03/2006','31/12/2007','ST_CLERK','50');
insert into job_history values ('122','01/01/2007','31/12/2007','ST_CLERK','50');
insert into job_history values ('200','17/09/1995','17/06/2001','AD_ASST','90');
insert into job_history values ('176','24/03/2006','31/12/2006','SA_REP','80');
insert into job_history values ('176','01/01/2007','31/12/2007','SA_MAN','80');
insert into job_history values ('200','01/07/2002','31/12/2006','AC_ACCOUNT','90');