CREATE TABLE COUNTRIES ( COUNTRY_ID CHAR(2) NOT NULL, COUNTRY_NAME VARCHAR2(40), REGION_ID NUMBER, CONSTRAINT COUNTRY_C_ID_PK PRIMARY KEY (COUNTRY_ID) ) ORGANIZATION INDEX TABLESPACE HR_DATA_TS02 NOMAPPING;
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 TABLE DEPARTMENTS ( DEPARTMENT_ID NUMBER(4), DEPARTMENT_NAME VARCHAR2(30) NOT NULL, MANAGER_ID NUMBER(6), LOCATION_ID NUMBER(4) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS ENABLE ROW MOVEMENT;
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 TABLE EMPLOYEES ( EMPLOYEE_ID NUMBER(6) NOT NULL, FIRST_NAME VARCHAR2(20), LAST_NAME VARCHAR2(25) NOT NULL, EMAIL VARCHAR2(25) NOT NULL, PHONE_NUMBER VARCHAR2(20), HIRE_DATE DATE NOT NULL, JOB_ID VARCHAR2(10) NOT NULL, SALARY NUMBER(8,2), COMMISSION_PCT NUMBER(2,2), MANAGER_ID NUMBER(6), DEPARTMENT_ID NUMBER(4) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS CACHE;
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 TABLE JOBS ( JOB_ID VARCHAR2(10), JOB_TITLE VARCHAR2(35) NOT NULL, MIN_SALARY NUMBER(6), MAX_SALARY NUMBER(6) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS ENABLE ROW MOVEMENT;
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 TABLE JOB_HISTORY ( EMPLOYEE_ID NUMBER(6) NOT NULL, START_DATE DATE NOT NULL, END_DATE DATE NOT NULL, JOB_ID VARCHAR2(10) NOT NULL, DEPARTMENT_ID NUMBER(4) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS;
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 TABLE LOCATIONS ( LOCATION_ID NUMBER(4), STREET_ADDRESS VARCHAR2(40), POSTAL_CODE VARCHAR2(12), CITY VARCHAR2(30) NOT NULL, STATE_PROVINCE VARCHAR2(25), COUNTRY_ID CHAR(2) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS ENABLE ROW MOVEMENT;
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 TABLE REGIONS ( REGION_ID NUMBER NOT NULL, REGION_NAME VARCHAR2(25) ) TABLESPACE HR_DATA_TS02 NOCOMPRESS;
|