DROP TABLE EMPLOYEE;
DROP TABLE DEPARTMENT;
DROP TABLE LOGRECORD;

CREATE TABLE LOGRECORD (ID INTEGER  NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), 
                        EMPNO INTEGER, ACTION VARCHAR(255), PRIMARY KEY (ID));
CREATE TABLE DEPARTMENT (ID INTEGER NOT NULL, NAME VARCHAR(255), PRIMARY KEY (ID));
CREATE TABLE EMPLOYEE (ID INTEGER NOT NULL, NAME VARCHAR(255), STARTDATE DATE, SALARY BIGINT, 
                       DEPARTMENT_ID INTEGER, PRIMARY KEY (ID),
                       CONSTRAINT DEPARTMENT_FK FOREIGN KEY (DEPARTMENT_ID) REFERENCES DEPARTMENT (ID));

INSERT INTO DEPARTMENT (ID, NAME) VALUES (1, 'Engineering');
INSERT INTO DEPARTMENT (ID, NAME) VALUES (2, 'CA13');
INSERT INTO DEPARTMENT (ID, NAME) VALUES (3, 'CA19');

INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (1, 'Joan', 59000, {d '2003-04-16'},  1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (2, 'Sarah', 52000, {d '2002-04-26'}, 2);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (3, 'John', 55000, {d '2001-01-01'}, 2);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (4, 'Roberts', 53000, {d '2001-05-23'}, 2);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (5, 'Peter', 50000, {d '2002-08-06'}, 2);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (6, 'Frank', 51000, {d '2003-02-17'}, 1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (7, 'Scott', 60000, {d '2004-11-14'}, 1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (8, 'Sue', 62000, {d '2005-08-18'}, 1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (9, 'Stephanie', 54000, {d '2006-06-07'}, 1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (10, 'Jennifer', 55000, {d '1999-08-11'}, 1);
INSERT INTO EMPLOYEE (ID, NAME, SALARY, STARTDATE, DEPARTMENT_ID) VALUES (11, 'Marcus', 35000, {d '1995-07-22'}, NULL);