/* THIS IS SMALL PART OF IMPLEMENTATION 
FOR DATA MODEL GIVEN IN TUTORIAL*/

CREATE TABLE EMPLOYEES
(
EMP_ID INTEGER NOT NULL,
FIRST_NAME VARCHAR(25) NOT NULL ,
SURNAME VARCHAR(25) NOT NULL,
COUNTRY_OF_ORIGIN VARCHAR(20),
BIRTH-DATE DATE,
PRIMARY KEY(EMP_ID)
);

ALTER TABLE EMPLOYEES ADD MANAGER INTEGER;

ALTER TABLE EMPLOYEES ADD FOREIGN KEY(MANAGER) 
    REFERENCES EMPLOYEES(EMP_ID);

CREATE TABLE PAYCHECKS
(ORDER_DATE DATE NOT NULL,
EMP_ID INTEGER NOT NULL,
GROSSAMOUNT DOUBLE PRECISION,
NETAMOUNT DOUBLE PRECISION );

ALTER TABLE PAYCHECKS 
  ADD CONSTRAINT PK_EMPLOYEES 
     PRIMARY KEY(EMP_ID,ORDER_DATE);

ALTER TABLE PAYCHECKS ADD CONSTRAINT FK_EMPLOYEES_PAYCHECKS
   FOREIGN KEY(EMP_ID) REFERENCES EMPLOYEES;

ALTER TABLE PAYCHECKS 
   DROP CONSTRAINT FK_EMPLOYEES_PAYCHECKS;

ALTER TABLE PAYCHECKS 
   DROP CONSTRAINT PK_EMPLOYEES;








