CREATE TABLE MEETING
  (
    ID               NUMBER(10) NOT NULL,
    PROJECT_ID       NUMBER(10) NOT NULL,
    TASK_DATE_START  DATE DEFAULT NULL NULL,
    TASK_DATE_END    DATE DEFAULT NULL NULL,
	 ISSUE_DATE_START DATE DEFAULT NULL NULL,
	 ISSUE_DATE_END   DATE DEFAULT NULL NULL,
    IS_ACTIVE        VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    ORGANIZATION_ID  NUMBER(10) NOT NULL,
    CREATED          DATE DEFAULT SYSDATE NOT NULL,
    CREATED_BY       NUMBER(10) NOT NULL,
    UPDATED          DATE DEFAULT SYSDATE NOT NULL,
    UPDATED_BY       NUMBER(10) NOT NULL,
    CONSTRAINT MEETING_PK PRIMARY KEY(ID)
  )
/
ALTER TABLE MEETING
ADD CONSTRAINT CK_MEETING_IS_ACTIVE CHECK (IS_ACTIVE in ('Y','N','D'))
/
CREATE INDEX MEETING_PROJECT_FK on MEETING (PROJECT_ID asc)
/
CREATE INDEX MEETING_ORG_FK on MEETING (ORGANIZATION_ID asc)
/
CREATE INDEX MEETING_USER_FK1 on MEETING (CREATED_BY asc)
/
CREATE INDEX MEETING_USER_FK2 on MEETING (UPDATED_BY asc)
/
ALTER TABLE MEETING 
ADD CONSTRAINT MEETING_PROJECT_FK FOREIGN KEY (PROJECT_ID) 
REFERENCES PROJECT (ID)
/
ALTER TABLE MEETING 
ADD CONSTRAINT MEETING_ORG_FK FOREIGN KEY (ORGANIZATION_ID) 
REFERENCES ORGANIZATION (ID)
/
ALTER TABLE MEETING 
ADD CONSTRAINT MEETING_USER_FK1 FOREIGN KEY (CREATED_BY) 
REFERENCES ZH_USER (ID)
/
ALTER TABLE MEETING 
ADD CONSTRAINT MEETING_USER_FK2 FOREIGN KEY (UPDATED_BY) 
REFERENCES ZH_USER (ID)
/
CREATE SEQUENCE MEETING_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1
/

CREATE TABLE MEETING_PROJECT
  (
    ID              NUMBER(10) NOT NULL,
    MEETING_ID      NUMBER(10) NOT NULL,
    PROJECT_ID      NUMBER(10) NOT NULL,
    IS_ACTIVE       VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    ORGANIZATION_ID NUMBER(10) NOT NULL,
    CREATED         DATE DEFAULT SYSDATE NOT NULL,
    CREATED_BY      NUMBER(10) NOT NULL,
    UPDATED         DATE DEFAULT SYSDATE NOT NULL,
    UPDATED_BY      NUMBER(10) NOT NULL,
    CONSTRAINT MEETING_PROJECT_PK PRIMARY KEY(ID)
  )
/
ALTER TABLE MEETING_PROJECT
ADD CONSTRAINT CK_MEETING_PROJECT_IS_ACTIVE CHECK (IS_ACTIVE in ('Y','N','D'))
/
CREATE INDEX MEETING_PROJECT_MEETING_FK on MEETING_PROJECT (MEETING_ID asc)
/
CREATE INDEX MEETING_PROJECT_PROJECT_FK on MEETING_PROJECT (PROJECT_ID asc)
/
CREATE INDEX MEETING_PROJECT_ORG_FK on MEETING_PROJECT (ORGANIZATION_ID asc)
/
CREATE INDEX MEETING_PROJECT_USER_FK1 on MEETING_PROJECT (CREATED_BY asc)
/
CREATE INDEX MEETING_PROJECT_USER_FK2 on MEETING_PROJECT (UPDATED_BY asc)
/
ALTER TABLE MEETING_PROJECT 
ADD CONSTRAINT MEETING_PROJECT_MEETING_FK FOREIGN KEY (MEETING_ID) 
REFERENCES MEETING (ID)
/
ALTER TABLE MEETING_PROJECT 
ADD CONSTRAINT MEETING_PROJECT_PROJECT_FK FOREIGN KEY (PROJECT_ID) 
REFERENCES PROJECT (ID)
/
ALTER TABLE MEETING_PROJECT 
ADD CONSTRAINT MEETING_PROJECT_ORG_FK FOREIGN KEY (ORGANIZATION_ID) 
REFERENCES ORGANIZATION (ID)
/
ALTER TABLE MEETING_PROJECT 
ADD CONSTRAINT MEETING_PROJECT_USER_FK1 FOREIGN KEY (CREATED_BY) 
REFERENCES ZH_USER (ID)
/
ALTER TABLE MEETING_PROJECT 
ADD CONSTRAINT MEETING_PROJECT_USER_FK2 FOREIGN KEY (UPDATED_BY) 
REFERENCES ZH_USER (ID)
/
CREATE SEQUENCE MEETING_PROJECT_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 
/

CREATE TABLE MEETING_TASK_STATUS
  (
    ID              NUMBER(10) NOT NULL,
    MEETING_ID      NUMBER(10) NOT NULL,
    TASK_STATUS_ID  NUMBER(10) NOT NULL,
    IS_ACTIVE       VARCHAR2(1) DEFAULT 'Y' NOT NULL,
    ORGANIZATION_ID NUMBER(10) NOT NULL,
    CREATED         DATE DEFAULT SYSDATE NOT NULL,
    CREATED_BY      NUMBER(10) NOT NULL,
    UPDATED         DATE DEFAULT SYSDATE NOT NULL,
    UPDATED_BY      NUMBER(10) NOT NULL,
    CONSTRAINT MEETING_TASK_STATUS_PK PRIMARY KEY(ID)
  )
/
ALTER TABLE MEETING_TASK_STATUS
ADD CONSTRAINT CK_MEETING_TASK_ST_IS_ACTIVE CHECK (IS_ACTIVE in ('Y','N','D'))
/
CREATE INDEX MEETING_TASK_STATUS_MEETING_FK on MEETING_TASK_STATUS (MEETING_ID asc)
/
CREATE INDEX MEETING_TASK_ST_TASK_STATUS_FK on MEETING_TASK_STATUS (TASK_STATUS_ID asc)
/
CREATE INDEX MEETING_TASK_STATUS_ORG_FK on MEETING_TASK_STATUS (ORGANIZATION_ID asc)
/
CREATE INDEX MEETING_TASK_STATUS_USER_FK1 on MEETING_TASK_STATUS (CREATED_BY asc)
/
CREATE INDEX MEETING_TASK_STATUS_USER_FK2 on MEETING_TASK_STATUS (UPDATED_BY asc)
/
ALTER TABLE MEETING_TASK_STATUS 
ADD CONSTRAINT MEETING_TASK_STATUS_MEETING_FK FOREIGN KEY (MEETING_ID) 
REFERENCES MEETING (ID)
/
ALTER TABLE MEETING_TASK_STATUS 
ADD CONSTRAINT MEETING_TASK_ST_TASK_STATUS_FK FOREIGN KEY (TASK_STATUS_ID) 
REFERENCES TASK_STATUS (ID)
/
ALTER TABLE MEETING_TASK_STATUS 
ADD CONSTRAINT MEETING_TASK_STATUS_ORG_FK FOREIGN KEY (ORGANIZATION_ID) 
REFERENCES ORGANIZATION (ID)
/
ALTER TABLE MEETING_TASK_STATUS 
ADD CONSTRAINT MEETING_TASK_STATUS_USER_FK1 FOREIGN KEY (CREATED_BY) 
REFERENCES ZH_USER (ID)
/
ALTER TABLE MEETING_TASK_STATUS 
ADD CONSTRAINT MEETING_TASK_STATUS_USER_FK2 FOREIGN KEY (UPDATED_BY) 
REFERENCES ZH_USER (ID)
/
CREATE SEQUENCE MEETING_TASK_STATUS_ID_SEQ START WITH 1 MINVALUE 1 INCREMENT BY 1 
/
