{"regions": {"columns": [[0, "REGION_ID", "decimal(5,0)", 1, null, 1], [1, "REGION_NAME", "varchar(25)", 0, "NULL", 0]], "primary_keys": ["REGION_ID"], "foreign_keys": [], "unique_constraints": [[[0, 0, "REGION_ID"]]], "check_constraints": []}, "countries": {"columns": [[0, "COUNTRY_ID", "varchar(2)", 1, null, 1], [1, "COUNTRY_NAME", "varchar(40)", 0, "NULL", 0], [2, "REGION_ID", "decimal(10,0)", 0, "NULL", 0]], "primary_keys": ["COUNTRY_ID"], "foreign_keys": [[0, 0, "regions", "REGION_ID", "REGION_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "COUNTRY_ID"]]], "check_constraints": []}, "departments": {"columns": [[0, "DEPARTMENT_ID", "decimal(4,0)", 1, "'0'", 1], [1, "DEPARTMENT_NAME", "varchar(30)", 1, null, 0], [2, "MANAGER_ID", "decimal(6,0)", 0, "NULL", 0], [3, "LOCATION_ID", "decimal(4,0)", 0, "NULL", 0]], "primary_keys": ["DEPARTMENT_ID"], "foreign_keys": [], "unique_constraints": [[[0, 0, "DEPARTMENT_ID"]]], "check_constraints": []}, "jobs": {"columns": [[0, "JOB_ID", "varchar(10)", 1, "''", 1], [1, "JOB_TITLE", "varchar(35)", 1, null, 0], [2, "MIN_SALARY", "decimal(6,0)", 0, "NULL", 0], [3, "MAX_SALARY", "decimal(6,0)", 0, "NULL", 0]], "primary_keys": ["JOB_ID"], "foreign_keys": [], "unique_constraints": [[[0, 0, "JOB_ID"]]], "check_constraints": []}, "employees": {"columns": [[0, "EMPLOYEE_ID", "decimal(6,0)", 1, "'0'", 1], [1, "FIRST_NAME", "varchar(20)", 0, "NULL", 0], [2, "LAST_NAME", "varchar(25)", 1, null, 0], [3, "EMAIL", "varchar(25)", 1, null, 0], [4, "PHONE_NUMBER", "varchar(20)", 0, "NULL", 0], [5, "HIRE_DATE", "date", 1, null, 0], [6, "JOB_ID", "varchar(10)", 1, null, 0], [7, "SALARY", "decimal(8,2)", 0, "NULL", 0], [8, "COMMISSION_PCT", "decimal(2,2)", 0, "NULL", 0], [9, "MANAGER_ID", "decimal(6,0)", 0, "NULL", 0], [10, "DEPARTMENT_ID", "decimal(4,0)", 0, "NULL", 0]], "primary_keys": ["EMPLOYEE_ID"], "foreign_keys": [[0, 0, "jobs", "JOB_ID", "JOB_ID", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "departments", "DEPARTMENT_ID", "DEPARTMENT_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "EMPLOYEE_ID"]]], "check_constraints": []}, "job_history": {"columns": [[0, "EMPLOYEE_ID", "decimal(6,0)", 1, null, 1], [1, "START_DATE", "date", 1, null, 2], [2, "END_DATE", "date", 1, null, 0], [3, "JOB_ID", "varchar(10)", 1, null, 0], [4, "DEPARTMENT_ID", "decimal(4,0)", 0, "NULL", 0]], "primary_keys": ["EMPLOYEE_ID", "START_DATE"], "foreign_keys": [[0, 0, "jobs", "JOB_ID", "JOB_ID", "NO ACTION", "NO ACTION", "NONE"], [1, 0, "departments", "DEPARTMENT_ID", "DEPARTMENT_ID", "NO ACTION", "NO ACTION", "NONE"], [2, 0, "employees", "EMPLOYEE_ID", "EMPLOYEE_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "EMPLOYEE_ID"], [1, 1, "START_DATE"]]], "check_constraints": []}, "locations": {"columns": [[0, "LOCATION_ID", "decimal(4,0)", 1, "'0'", 1], [1, "STREET_ADDRESS", "varchar(40)", 0, "NULL", 0], [2, "POSTAL_CODE", "varchar(12)", 0, "NULL", 0], [3, "CITY", "varchar(30)", 1, null, 0], [4, "STATE_PROVINCE", "varchar(25)", 0, "NULL", 0], [5, "COUNTRY_ID", "varchar(2)", 0, "NULL", 0]], "primary_keys": ["LOCATION_ID"], "foreign_keys": [[0, 0, "countries", "COUNTRY_ID", "COUNTRY_ID", "NO ACTION", "NO ACTION", "NONE"]], "unique_constraints": [[[0, 0, "LOCATION_ID"]]], "check_constraints": []}}
CREATE TABLE regions (
    REGION_ID decimal(5,0) NOT NULL  PRIMARY KEY,
    REGION_NAME varchar(25)  DEFAULT NULL,
    UNIQUE (REGION_ID)
);

CREATE TABLE countries (
    COUNTRY_ID varchar(2) NOT NULL  PRIMARY KEY,
    COUNTRY_NAME varchar(40)  DEFAULT NULL,
    REGION_ID decimal(10,0)  DEFAULT NULL,
    UNIQUE (COUNTRY_ID),
    FOREIGN KEY (REGION_ID) REFERENCES regions(REGION_ID)
);

CREATE TABLE departments (
    DEPARTMENT_ID decimal(4,0) NOT NULL DEFAULT '0' PRIMARY KEY,
    DEPARTMENT_NAME varchar(30) NOT NULL,
    MANAGER_ID decimal(6,0)  DEFAULT NULL,
    LOCATION_ID decimal(4,0)  DEFAULT NULL,
    UNIQUE (DEPARTMENT_ID)
);

CREATE TABLE jobs (
    JOB_ID varchar(10) NOT NULL DEFAULT '' PRIMARY KEY,
    JOB_TITLE varchar(35) NOT NULL,
    MIN_SALARY decimal(6,0)  DEFAULT NULL,
    MAX_SALARY decimal(6,0)  DEFAULT NULL,
    UNIQUE (JOB_ID)
);

CREATE TABLE employees (
    EMPLOYEE_ID decimal(6,0) NOT NULL DEFAULT '0' PRIMARY KEY,
    FIRST_NAME varchar(20)  DEFAULT NULL,
    LAST_NAME varchar(25) NOT NULL,
    EMAIL varchar(25) NOT NULL,
    PHONE_NUMBER varchar(20)  DEFAULT NULL,
    HIRE_DATE date NOT NULL,
    JOB_ID varchar(10) NOT NULL,
    SALARY decimal(8,2)  DEFAULT NULL,
    COMMISSION_PCT decimal(2,2)  DEFAULT NULL,
    MANAGER_ID decimal(6,0)  DEFAULT NULL,
    DEPARTMENT_ID decimal(4,0)  DEFAULT NULL,
    UNIQUE (EMPLOYEE_ID),
    FOREIGN KEY (JOB_ID) REFERENCES jobs(JOB_ID),
    FOREIGN KEY (DEPARTMENT_ID) REFERENCES departments(DEPARTMENT_ID)
);

CREATE TABLE job_history (
    EMPLOYEE_ID decimal(6,0) NOT NULL  PRIMARY KEY,
    START_DATE date NOT NULL  PRIMARY KEY,
    END_DATE date NOT NULL,
    JOB_ID varchar(10) NOT NULL,
    DEPARTMENT_ID decimal(4,0)  DEFAULT NULL,
    PRIMARY KEY (EMPLOYEE_ID, START_DATE),
    UNIQUE (EMPLOYEE_ID, START_DATE),
    FOREIGN KEY (JOB_ID) REFERENCES jobs(JOB_ID),
    FOREIGN KEY (DEPARTMENT_ID) REFERENCES departments(DEPARTMENT_ID),
    FOREIGN KEY (EMPLOYEE_ID) REFERENCES employees(EMPLOYEE_ID)
);

CREATE TABLE locations (
    LOCATION_ID decimal(4,0) NOT NULL DEFAULT '0' PRIMARY KEY,
    STREET_ADDRESS varchar(40)  DEFAULT NULL,
    POSTAL_CODE varchar(12)  DEFAULT NULL,
    CITY varchar(30) NOT NULL,
    STATE_PROVINCE varchar(25)  DEFAULT NULL,
    COUNTRY_ID varchar(2)  DEFAULT NULL,
    UNIQUE (LOCATION_ID),
    FOREIGN KEY (COUNTRY_ID) REFERENCES countries(COUNTRY_ID)
);