﻿/* Sequence 저장테이블 */
CREATE TABLE COMTECOPSEQ
(
	TABLE_NAME            VARCHAR(20) NOT NULL,
	NEXT_ID               NUMERIC(30) NULL,
	 PRIMARY KEY (TABLE_NAME)
)
;

CREATE UNIQUE INDEX COMTECOPSEQ_PK ON COMTECOPSEQ
(
	TABLE_NAME
)
;



/* 공통분류코드 */
CREATE TABLE COMTCCMMNCLCODE
(
	CL_CODE               CHAR(3) NOT NULL,
	CL_CODE_NM            VARCHAR(60) NULL,
	CL_CODE_DC            VARCHAR(200) NULL,
	USE_AT                CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (CL_CODE)
)
;

CREATE UNIQUE INDEX COMTCCMMNCLCODE_PK ON COMTCCMMNCLCODE
(
	CL_CODE
)
;



/* 공통코드 */
CREATE TABLE COMTCCMMNCODE
(
	CODE_ID               VARCHAR(6) NOT NULL,
	CODE_ID_NM            VARCHAR(60) NULL,
	CODE_ID_DC            VARCHAR(200) NULL,
	USE_AT                CHAR(1) NULL,
	CL_CODE               CHAR(3) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (CODE_ID),
	FOREIGN KEY COMTCCMMNCODE_FK1 (CL_CODE) REFERENCES COMTCCMMNCLCODE(CL_CODE)
)
;

CREATE UNIQUE INDEX COMTCCMMNCODE_PK ON COMTCCMMNCODE
(
	CODE_ID
)
;
CREATE INDEX COMTCCMMNCODE_i01 ON COMTCCMMNCODE
(
	CL_CODE
)
;



/* 공통상세코드 */
CREATE TABLE COMTCCMMNDETAILCODE
(
	CODE_ID               VARCHAR(6) NOT NULL,
	CODE                  VARCHAR(15) NOT NULL,
	CODE_NM               VARCHAR(60) NULL,
	CODE_DC               VARCHAR(200) NULL,
	USE_AT                CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (CODE_ID,CODE),
	FOREIGN KEY COMTCCMMNDETAILCODE_FK1 (CODE_ID) REFERENCES COMTCCMMNCODE(CODE_ID)
)
;

CREATE UNIQUE INDEX COMTCCMMNDETAILCODE_PK ON COMTCCMMNDETAILCODE
(
	CODE_ID,
	CODE
)
;
CREATE INDEX COMTCCMMNDETAILCODE_i01 ON COMTCCMMNDETAILCODE
(
	CODE_ID
)
;



/* 권한그룹정보 */
CREATE TABLE COMTNAUTHORGROUPINFO
(
	GROUP_ID              CHAR(20) NOT NULL,
	GROUP_NM              VARCHAR(60) NOT NULL,
	GROUP_CREAT_DE        CHAR(20) NOT NULL,
	GROUP_DC              VARCHAR(100) NULL,
	 PRIMARY KEY (GROUP_ID)
)
;

CREATE UNIQUE INDEX COMTNAUTHORGROUPINFO_PK ON COMTNAUTHORGROUPINFO
(
	GROUP_ID
)
;



/* 일반회원 */
CREATE TABLE COMTNGNRLMBER
(
	MBER_ID               VARCHAR(20) NOT NULL,
	PASSWORD              VARCHAR(200) NOT NULL,
	PASSWORD_HINT         VARCHAR(100) NULL,
	PASSWORD_CNSR         VARCHAR(100) NULL,
	IHIDNUM               VARCHAR(200) NULL,
	MBER_NM               VARCHAR(50) NOT NULL,
	ZIP                   VARCHAR(6) NOT NULL,
	ADRES                 VARCHAR(100) NOT NULL,
	AREA_NO               VARCHAR(4) NOT NULL,
	MBER_STTUS            VARCHAR(15) NULL,
	DETAIL_ADRES          VARCHAR(100) NULL,
	END_TELNO             VARCHAR(4) NOT NULL,
	MBTLNUM               VARCHAR(20) NOT NULL,
	GROUP_ID              CHAR(20) NULL,
	MBER_FXNUM            VARCHAR(20) NULL,
	MBER_EMAIL_ADRES      VARCHAR(50) NULL,
	MIDDLE_TELNO          VARCHAR(4) NOT NULL,
	SBSCRB_DE             DATETIME NULL,
	SEXDSTN_CODE          CHAR(1) NULL,
	ESNTL_ID              CHAR(20) NOT NULL,
	 PRIMARY KEY (MBER_ID),
	FOREIGN KEY COMTNGNRLMBER_FK1 (GROUP_ID) REFERENCES COMTNAUTHORGROUPINFO(GROUP_ID)
		ON DELETE SET NULL
)
;

CREATE UNIQUE INDEX COMTNGNRLMBER_PK ON COMTNGNRLMBER
(
	MBER_ID
)
;
CREATE INDEX COMTNGNRLMBER_i01 ON COMTNGNRLMBER
(
	GROUP_ID
)
;



/* 조직정보 */
CREATE TABLE COMTNORGNZTINFO
(
	ORGNZT_ID             CHAR(20) NOT NULL,
	ORGNZT_NM             VARCHAR(20) NOT NULL,
	ORGNZT_DC             VARCHAR(100) NULL,
	 PRIMARY KEY (ORGNZT_ID)
)
;

CREATE UNIQUE INDEX COMTNORGNZTINFO_PK ON COMTNORGNZTINFO
(
	ORGNZT_ID
)
;



/* 업무사용자정보 */
CREATE TABLE COMTNEMPLYRINFO
(
	EMPLYR_ID             VARCHAR(20) NOT NULL,
	ORGNZT_ID             CHAR(20) NULL,
	USER_NM               VARCHAR(60) NOT NULL,
	PASSWORD              VARCHAR(200) NOT NULL,
	EMPL_NO               VARCHAR(20) NULL,
	IHIDNUM               VARCHAR(200) NULL,
	SEXDSTN_CODE          CHAR(1) NULL,
	BRTHDY                CHAR(20) NULL,
	FXNUM                 VARCHAR(20) NULL,
	HOUSE_ADRES           VARCHAR(100) NOT NULL,
	PASSWORD_HINT         VARCHAR(100) NOT NULL,
	PASSWORD_CNSR         VARCHAR(100) NOT NULL,
	HOUSE_END_TELNO       VARCHAR(4) NOT NULL,
	AREA_NO               VARCHAR(4) NOT NULL,
	DETAIL_ADRES          VARCHAR(100) NULL,
	ZIP                   VARCHAR(6) NOT NULL,
	OFFM_TELNO            VARCHAR(20) NULL,
	MBTLNUM               VARCHAR(20) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	OFCPS_NM              VARCHAR(60) NULL,
	HOUSE_MIDDLE_TELNO    VARCHAR(4) NOT NULL,
	GROUP_ID              CHAR(20) NULL,
	PSTINST_CODE          CHAR(8) NULL,
	EMPLYR_STTUS_CODE     CHAR(1) NOT NULL,
	ESNTL_ID              CHAR(20) NOT NULL,
	CRTFC_DN_VALUE        VARCHAR(100) NULL,
	SBSCRB_DE             DATETIME NULL,
	 PRIMARY KEY (EMPLYR_ID),
	FOREIGN KEY COMTNEMPLYRINFO_FK2 (ORGNZT_ID) REFERENCES COMTNORGNZTINFO(ORGNZT_ID)
		ON DELETE SET NULL,
	FOREIGN KEY COMTNEMPLYRINFO_FK1 (GROUP_ID) REFERENCES COMTNAUTHORGROUPINFO(GROUP_ID)
		ON DELETE SET NULL
)
;

CREATE UNIQUE INDEX COMTNEMPLYRINFO_PK ON COMTNEMPLYRINFO
(
	EMPLYR_ID
)
;
CREATE INDEX COMTNEMPLYRINFO_i01 ON COMTNEMPLYRINFO
(
	ORGNZT_ID
)
;
CREATE INDEX COMTNEMPLYRINFO_i02 ON COMTNEMPLYRINFO
(
	GROUP_ID
)
;



/* 기업회원 */
CREATE TABLE COMTNENTRPRSMBER
(
	ENTRPRS_MBER_ID       VARCHAR(20) NOT NULL,
	ENTRPRS_SE_CODE       CHAR(8) NULL,
	BIZRNO                VARCHAR(10) NULL,
	JURIRNO               VARCHAR(13) NULL,
	CMPNY_NM              VARCHAR(60) NOT NULL,
	CXFC                  VARCHAR(50) NULL,
	ZIP                   VARCHAR(6) NOT NULL,
	ADRES                 VARCHAR(100) NOT NULL,
	ENTRPRS_MIDDLE_TELNO  VARCHAR(4) NOT NULL,
	FXNUM                 VARCHAR(20) NULL,
	INDUTY_CODE           CHAR(1) NULL,
	APPLCNT_NM            VARCHAR(50) NOT NULL,
	APPLCNT_IHIDNUM       VARCHAR(200) NULL,
	SBSCRB_DE             DATETIME NULL,
	ENTRPRS_MBER_STTUS    VARCHAR(15) NULL,
	ENTRPRS_MBER_PASSWORD  VARCHAR(200) NULL,
	ENTRPRS_MBER_PASSWORD_HINT  VARCHAR(100) NOT NULL,
	ENTRPRS_MBER_PASSWORD_CNSR  VARCHAR(100) NOT NULL,
	GROUP_ID              CHAR(20) NULL,
	DETAIL_ADRES          VARCHAR(100) NULL,
	ENTRPRS_END_TELNO     VARCHAR(4) NOT NULL,
	AREA_NO               VARCHAR(4) NOT NULL,
	APPLCNT_EMAIL_ADRES   VARCHAR(50) NOT NULL,
	ESNTL_ID              CHAR(20) NOT NULL,
	 PRIMARY KEY (ENTRPRS_MBER_ID),
	FOREIGN KEY COMTNENTRPRSMBER_FK1 (GROUP_ID) REFERENCES COMTNAUTHORGROUPINFO(GROUP_ID)
		ON DELETE SET NULL
)
;

CREATE UNIQUE INDEX COMTNENTRPRSMBER_PK ON COMTNENTRPRSMBER
(
	ENTRPRS_MBER_ID
)
;
CREATE INDEX COMTNENTRPRSMBER_i01 ON COMTNENTRPRSMBER
(
	GROUP_ID
)
;



/* 파일속성 */
CREATE TABLE COMTNFILE
(
	ATCH_FILE_ID          CHAR(20) NOT NULL,
	CREAT_DT              DATETIME NOT NULL,
	USE_AT                CHAR(1) NULL,
	 PRIMARY KEY (ATCH_FILE_ID)
)
;

CREATE UNIQUE INDEX COMTNFILE_PK ON COMTNFILE
(
	ATCH_FILE_ID
)
;



/* 파일상세정보 */
CREATE TABLE COMTNFILEDETAIL
(
	ATCH_FILE_ID          CHAR(20) NOT NULL,
	FILE_SN               NUMERIC(10) NOT NULL,
	FILE_STRE_COURS       VARCHAR(2000) NOT NULL,
	STRE_FILE_NM          VARCHAR(255) NOT NULL,
	ORIGNL_FILE_NM        VARCHAR(255) NULL,
	FILE_EXTSN            VARCHAR(20) NOT NULL,
	FILE_CN               MEDIUMTEXT NULL,
	FILE_SIZE             NUMERIC(8) NULL,
	 PRIMARY KEY (ATCH_FILE_ID,FILE_SN),
	FOREIGN KEY COMTNFILEDETAIL_FK1 (ATCH_FILE_ID) REFERENCES COMTNFILE(ATCH_FILE_ID)
)
;

CREATE UNIQUE INDEX COMTNFILEDETAIL_PK ON COMTNFILEDETAIL
(
	ATCH_FILE_ID,
	FILE_SN
)
;
CREATE INDEX COMTNFILEDETAIL_i01 ON COMTNFILEDETAIL
(
	ATCH_FILE_ID
)
;



/* 메일발신관리 */
CREATE TABLE COMTHEMAILDSPTCHMANAGE
(
	MSSAGE_ID             VARCHAR(20) NOT NULL,
	EMAIL_CN              MEDIUMTEXT NULL,
	SNDR                  VARCHAR(50) NOT NULL,
	RCVER                 VARCHAR(50) NOT NULL,
	SJ                    VARCHAR(60) NOT NULL,
	SNDNG_RESULT_CODE     CHAR(1) NULL,
	DSPTCH_DT             CHAR(20) NOT NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	 PRIMARY KEY (MSSAGE_ID),
	FOREIGN KEY COMTHEMAILDSPTCHMANAGE_FK1 (ATCH_FILE_ID) REFERENCES COMTNFILE(ATCH_FILE_ID)
)
;

CREATE UNIQUE INDEX COMTHEMAILDSPTCHMANAGE_PK ON COMTHEMAILDSPTCHMANAGE
(
	MSSAGE_ID
)
;
CREATE INDEX COMTHEMAILDSPTCHMANAGE_i01 ON COMTHEMAILDSPTCHMANAGE
(
	SNDR
)
;
CREATE INDEX COMTHEMAILDSPTCHMANAGE_i02 ON COMTHEMAILDSPTCHMANAGE
(
	ATCH_FILE_ID
)
;



/* 사용자보안설정 */
CREATE TABLE COMTNEMPLYRSCRTYESTBS
(
	SCRTY_DTRMN_TRGET_ID  VARCHAR(20) NOT NULL,
	MBER_TY_CODE          CHAR(5) NULL,
	AUTHOR_CODE           VARCHAR(30) NOT NULL,
	 PRIMARY KEY (SCRTY_DTRMN_TRGET_ID)
)
;

CREATE UNIQUE INDEX COMTNEMPLYRSCRTYESTBS_PK ON COMTNEMPLYRSCRTYESTBS
(
	SCRTY_DTRMN_TRGET_ID
)
;
CREATE INDEX COMTNEMPLYRSCRTYESTBS_i04 ON COMTNEMPLYRSCRTYESTBS
(
	AUTHOR_CODE
)
;



/* 사용자정보뷰 */
CREATE  VIEW COMVNUSERMASTER ( ESNTL_ID,USER_ID,PASSWORD,USER_NM,USER_ZIP,USER_ADRES,USER_EMAIL,GROUP_ID, USER_SE, ORGNZT_ID ) 
AS  
		SELECT ESNTL_ID, MBER_ID,PASSWORD,MBER_NM,ZIP,ADRES,MBER_EMAIL_ADRES,' ','GNR' AS USER_SE, ' ' ORGNZT_ID
		FROM COMTNGNRLMBER
		
	UNION ALL
		SELECT ESNTL_ID,EMPLYR_ID,PASSWORD,USER_NM,ZIP,HOUSE_ADRES,EMAIL_ADRES,GROUP_ID ,'USR' AS USER_SE, ORGNZT_ID
		FROM COMTNEMPLYRINFO
	UNION ALL
		SELECT ESNTL_ID,ENTRPRS_MBER_ID,ENTRPRS_MBER_PASSWORD,CMPNY_NM,ZIP,ADRES,APPLCNT_EMAIL_ADRES,' ' ,'ENT' AS USER_SE, ' ' ORGNZT_ID
		FROM COMTNENTRPRSMBER 
ORDER BY ESNTL_ID;


/* 권한정보 */
CREATE TABLE COMTNAUTHORINFO
(
	AUTHOR_CODE           VARCHAR(30) NOT NULL,
	AUTHOR_NM             VARCHAR(60) NOT NULL,
	AUTHOR_DC             VARCHAR(200) NULL,
	AUTHOR_CREAT_DE       CHAR(20) NOT NULL,
	 PRIMARY KEY (AUTHOR_CODE)
)
;

CREATE UNIQUE INDEX COMTNAUTHORINFO_PK ON COMTNAUTHORINFO
(
	AUTHOR_CODE
)
;



/* 롤 계층구조 */
CREATE TABLE COMTNROLES_HIERARCHY
(
	PARNTS_ROLE           VARCHAR(30) NOT NULL,
	CHLDRN_ROLE           VARCHAR(30) NOT NULL,
	 PRIMARY KEY (PARNTS_ROLE,CHLDRN_ROLE),
	FOREIGN KEY COMTNROLES_HIERARCHY_FK1 (PARNTS_ROLE) REFERENCES COMTNAUTHORINFO(AUTHOR_CODE)
		ON DELETE CASCADE,
	FOREIGN KEY COMTNROLES_HIERARCHY_FK2 (CHLDRN_ROLE) REFERENCES COMTNAUTHORINFO(AUTHOR_CODE)
		ON DELETE CASCADE
)
;

CREATE UNIQUE INDEX COMTNROLES_HIERARCHY_PK ON COMTNROLES_HIERARCHY
(
	PARNTS_ROLE,
	CHLDRN_ROLE
)
;
CREATE UNIQUE INDEX COMTNROLES_HIERARCHY_i01 ON COMTNROLES_HIERARCHY
(
	PARNTS_ROLE
)
;
CREATE INDEX COMTNROLES_HIERARCHY_i02 ON COMTNROLES_HIERARCHY
(
	CHLDRN_ROLE
)
;



/* 롤정보 */
CREATE TABLE COMTNROLEINFO
(
	ROLE_CODE             VARCHAR(50) NOT NULL,
	ROLE_NM               VARCHAR(60) NOT NULL,
	ROLE_PTTRN            VARCHAR(300) NULL,
	ROLE_DC               VARCHAR(200) NULL,
	ROLE_TY               VARCHAR(80) NULL,
	ROLE_SORT             VARCHAR(10) NULL,
	ROLE_CREAT_DE         CHAR(20) NOT NULL,
	 PRIMARY KEY (ROLE_CODE)
)
;

CREATE UNIQUE INDEX COMTNROLEINFO_PK ON COMTNROLEINFO
(
	ROLE_CODE
)
;



/* 권한롤관계 */
CREATE TABLE COMTNAUTHORROLERELATE
(
	AUTHOR_CODE           VARCHAR(30) NOT NULL,
	ROLE_CODE             VARCHAR(50) NOT NULL,
	CREAT_DT              DATETIME NULL,
	 PRIMARY KEY (AUTHOR_CODE,ROLE_CODE),
	FOREIGN KEY COMTNAUTHORROLERELATE_FK1 (AUTHOR_CODE) REFERENCES COMTNAUTHORINFO(AUTHOR_CODE)
		ON DELETE CASCADE,
	FOREIGN KEY COMTNAUTHORROLERELATE_FK2 (ROLE_CODE) REFERENCES COMTNROLEINFO(ROLE_CODE)
		ON DELETE CASCADE
)
;

CREATE UNIQUE INDEX COMTNAUTHORROLERELATE_PK ON COMTNAUTHORROLERELATE
(
	AUTHOR_CODE,
	ROLE_CODE
)
;
CREATE INDEX COMTNAUTHORROLERELATE_i01 ON COMTNAUTHORROLERELATE
(
	AUTHOR_CODE
)
;
CREATE INDEX COMTNAUTHORROLERELATE_i02 ON COMTNAUTHORROLERELATE
(
	ROLE_CODE
)
;



/* 템플릿 */
CREATE TABLE COMTNTMPLATINFO
(
	TMPLAT_ID             CHAR(20) NOT NULL,
	TMPLAT_NM             VARCHAR(255) NULL,
	TMPLAT_COURS          VARCHAR(2000) NULL,
	USE_AT                CHAR(1) NULL,
	TMPLAT_SE_CODE        CHAR(6) NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	 PRIMARY KEY (TMPLAT_ID)
)
;

CREATE UNIQUE INDEX COMTNTMPLATINFO_PK ON COMTNTMPLATINFO
(
	TMPLAT_ID
)
;



/* 게시판마스터 */
CREATE TABLE COMTNBBSMASTER
(
	BBS_ID                CHAR(20) NOT NULL,
	BBS_NM                VARCHAR(255) NOT NULL,
	BBS_INTRCN            VARCHAR(2400) NULL,
	BBS_TY_CODE           CHAR(6) NOT NULL,
	REPLY_POSBL_AT        CHAR(1) NULL,
	FILE_ATCH_POSBL_AT    CHAR(1) NOT NULL,
	ATCH_POSBL_FILE_NUMBER  NUMERIC(2) NOT NULL,
	ATCH_POSBL_FILE_SIZE  NUMERIC(8) NULL,
	USE_AT                CHAR(1) NOT NULL,
	TMPLAT_ID             CHAR(20) NULL,
	CMMNTY_ID			CHAR(20) NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	 PRIMARY KEY (BBS_ID)
)
;

CREATE UNIQUE INDEX COMTNBBSMASTER_PK ON COMTNBBSMASTER
(
	BBS_ID
)
;



/* 게시판 */
CREATE TABLE COMTNBBS
(
	NTT_ID                NUMERIC(20) NOT NULL,
	BBS_ID                CHAR(20) NOT NULL,
	NTT_NO                NUMERIC(20) NULL,
	NTT_SJ                VARCHAR(2000) NULL,
	NTT_CN                MEDIUMTEXT NULL,
	ANSWER_AT             CHAR(1) NULL,
	PARNTSCTT_NO          NUMERIC(10) NULL,
	ANSWER_LC             NUMERIC(8) NULL,
	SORT_ORDR             NUMERIC(8) NULL,
	RDCNT                 NUMERIC(10) NULL,
	USE_AT                CHAR(1) NOT NULL,
	NTCE_BGNDE            CHAR(20) NULL,
	NTCE_ENDDE            CHAR(20) NULL,
	NTCR_ID               VARCHAR(20) NULL,
	NTCR_NM               VARCHAR(20) NULL,
	PASSWORD              VARCHAR(200) NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	NOTICE_AT				CHAR(1) NULL,
	SJ_BOLD_AT				CHAR(1) NULL,
	SECRET_AT				CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (NTT_ID,BBS_ID),
	FOREIGN KEY COMTNBBS_FK1 (BBS_ID) REFERENCES COMTNBBSMASTER(BBS_ID)
)
;

CREATE UNIQUE INDEX COMTNBBS_PK ON COMTNBBS
(
	NTT_ID,
	BBS_ID
)
;
CREATE INDEX COMTNBBS_i01 ON COMTNBBS
(
	BBS_ID
)
;



/* 커뮤니티 속성 */
CREATE TABLE COMTNCMMNTY
(
	CMMNTY_ID             CHAR(20) NOT NULL,
	CMMNTY_NM             VARCHAR(255) NOT NULL,
	CMMNTY_INTRCN         VARCHAR(2400) NULL,
	USE_AT                CHAR(1) NOT NULL,
	REGIST_SE_CODE        CHAR(6) NULL,
	TMPLAT_ID             CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (CMMNTY_ID)
)
;

CREATE UNIQUE INDEX COMTNCMMNTY_PK ON COMTNCMMNTY
(
	CMMNTY_ID
)
;



/* 댓글 */
CREATE TABLE COMTNCOMMENT
(
	NTT_ID                NUMERIC(20) NOT NULL,
	BBS_ID                CHAR(20) NOT NULL,
	ANSWER_NO             NUMERIC(20) NOT NULL,
	WRTER_ID              VARCHAR(20) NULL,
	WRTER_NM              VARCHAR(20) NULL,
	ANSWER                VARCHAR(200) NULL,
	USE_AT                CHAR(1) NOT NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	PASSWORD              VARCHAR(200) NULL,
	 PRIMARY KEY (NTT_ID,BBS_ID,ANSWER_NO),
	FOREIGN KEY COMTNCOMMENT_FK1 (NTT_ID,BBS_ID) REFERENCES COMTNBBS(NTT_ID,BBS_ID)
)
;

CREATE UNIQUE INDEX COMTNCOMMENT_PK ON COMTNCOMMENT
(
	NTT_ID,
	BBS_ID,
	ANSWER_NO
)
;
CREATE INDEX COMTNCOMMENT_i01 ON COMTNCOMMENT
(
	NTT_ID,
	BBS_ID
)
;



/* 스크랩 */
CREATE TABLE COMTNSCRAP
(
	SCRAP_ID              CHAR(20) NOT NULL,
	NTT_ID                NUMERIC(20) NOT NULL,
	BBS_ID                CHAR(20) NOT NULL,
	SCRAP_NM              VARCHAR(100) NOT NULL,
	USE_AT                CHAR(1) NOT NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (SCRAP_ID)
)
;

CREATE UNIQUE INDEX COMTNSCRAP_PK ON COMTNSCRAP
(
	SCRAP_ID
)
;



/* 게시판활용 */
CREATE TABLE COMTNBBSUSE
(
	BBS_ID                CHAR(20) NOT NULL,
	TRGET_ID              CHAR(20) NOT NULL,
	USE_AT                CHAR(1) NOT NULL,
	REGIST_SE_CODE        CHAR(6) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (BBS_ID,TRGET_ID),
	FOREIGN KEY COMTNBBSUSE_FK1 (BBS_ID) REFERENCES COMTNBBSMASTER(BBS_ID)
)
;

CREATE UNIQUE INDEX COMTNBBSUSE_PK ON COMTNBBSUSE
(
	BBS_ID,
	TRGET_ID
)
;
CREATE INDEX COMTNBBSUSE_i01 ON COMTNBBSUSE
(
	BBS_ID
)
;



/* 커뮤니티사용자 */
CREATE TABLE COMTNCMMNTYUSER
(
	CMMNTY_ID             CHAR(20) NOT NULL,
	EMPLYR_ID             VARCHAR(20) NOT NULL,
	MNGR_AT               CHAR(1) NOT NULL,
	MBER_STTUS			VARCHAR(15) NULL,
	SBSCRB_DE             DATETIME NULL,
	SECSN_DE              CHAR(20) NULL,
	USE_AT                CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (CMMNTY_ID,EMPLYR_ID),
	FOREIGN KEY COMTNCMMNTYUSER_FK1 (CMMNTY_ID) REFERENCES COMTNCMMNTY(CMMNTY_ID)
)
;

CREATE UNIQUE INDEX COMTNCMMNTYUSER_PK ON COMTNCMMNTYUSER
(
	CMMNTY_ID,
	EMPLYR_ID
)
;
CREATE INDEX COMTNCMMNTYUSER_i01 ON COMTNCMMNTYUSER
(
	CMMNTY_ID
)
;



/* 일정정보 */
CREATE TABLE COMTNSCHDULINFO
(
	SCHDUL_ID             CHAR(20) NOT NULL,
	SCHDUL_SE             CHAR(1) NULL,
	SCHDUL_DEPT_ID        VARCHAR(20) NULL,
	SCHDUL_KND_CODE       CHAR(1) NULL,
	SCHDUL_BGNDE          CHAR(20) NULL,
	SCHDUL_ENDDE          CHAR(20) NULL,
	SCHDUL_NM             VARCHAR(255) NULL,
	SCHDUL_CN             VARCHAR(2500) NULL,
	SCHDUL_PLACE          VARCHAR(255) NULL,
	SCHDUL_IPCR_CODE      CHAR(1) NULL,
	SCHDUL_CHARGER_ID     VARCHAR(20) NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	REPTIT_SE_CODE        CHAR(1) NULL,
	 PRIMARY KEY (SCHDUL_ID)
)
;

CREATE UNIQUE INDEX COMTNSCHDULINFO_PK ON COMTNSCHDULINFO
(
	SCHDUL_ID
)
;



/* 일지정보 */
CREATE TABLE COMTNDIARYINFO
(
	SCHDUL_ID             CHAR(20) NOT NULL,
	DIARY_ID              CHAR(20) NOT NULL,
	DIARY_PROGRSRT        NUMERIC(3) NULL,
	DIARY_NM              VARCHAR(255) NULL,
	DRCT_MATTER           VARCHAR(2500) NULL,
	PARTCLR_MATTER        VARCHAR(2500) NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (SCHDUL_ID,DIARY_ID),
	FOREIGN KEY COMTNDIARYINFO_FK1 (SCHDUL_ID) REFERENCES COMTNSCHDULINFO(SCHDUL_ID)
)
;

CREATE UNIQUE INDEX COMTNDIARYINFO_PK ON COMTNDIARYINFO
(
	SCHDUL_ID,
	DIARY_ID
)
;
CREATE INDEX COMTNDIARYINFO_i01 ON COMTNDIARYINFO
(
	SCHDUL_ID
)
;



/* 명함정보속성 */
CREATE TABLE COMTNNCRD
(
	NCRD_ID               CHAR(20) NOT NULL,
	NCRD_TRGTER_ID        VARCHAR(20) NULL,
	NM                    VARCHAR(50) NOT NULL,
	TELNO                 VARCHAR(20) NULL,
	NATION_NO             VARCHAR(10) NULL,
	AREA_NO               VARCHAR(4) NULL,
	MIDDLE_TELNO          VARCHAR(4) NULL,
	END_TELNO             VARCHAR(4) NULL,
	MBTLNUM               VARCHAR(20) NULL,
	IDNTFC_NO             VARCHAR(10) NULL,
	MIDDLE_MBTLNUM        VARCHAR(4) NULL,
	END_MBTLNUM           VARCHAR(4) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	CMPNY_NM              VARCHAR(60) NULL,
	DEPT_NM               VARCHAR(60) NULL,
	ADRES                 VARCHAR(100) NULL,
	DETAIL_ADRES          VARCHAR(100) NULL,
	OFCPS_NM              VARCHAR(60) NULL,
	CLSF_NM               VARCHAR(60) NULL,
	EXTRL_USER_AT         CHAR(1) NULL,
	OTHBC_AT              CHAR(1) NOT NULL,
	RM                    VARCHAR(2500) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (NCRD_ID)
)
;

CREATE UNIQUE INDEX COMTNNCRD_PK ON COMTNNCRD
(
	NCRD_ID
)
;



/* 주소록관리 */
CREATE TABLE COMTNADBKMANAGE
(
	ADBK_ID               CHAR(20) NOT NULL,
	ADBK_NM               VARCHAR(50) NOT NULL,
	OTHBC_SCOPE           VARCHAR(20) NOT NULL,
	USE_AT                CHAR(1) NOT NULL,
	WRTER_ID              VARCHAR(20) NULL,
	TRGET_ORGNZT_ID       CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (ADBK_ID)
)
;

CREATE UNIQUE INDEX COMTNADBKMANAGE_PK ON COMTNADBKMANAGE
(
	ADBK_ID
)
;



/* 주소록 */
CREATE TABLE COMTNADBK
(
	EMPLYR_ID             VARCHAR(20) NULL,
	NCRD_ID               CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	ADBK_CONSTNT_ID       CHAR(20) NOT NULL,
	NM                    VARCHAR(50) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	MBTLNUM               VARCHAR(20) NULL,
	FXNUM                 VARCHAR(20) NULL,
	OFFM_TELNO            VARCHAR(20) NULL,
	HOUSE_TELNO           VARCHAR(20) NULL,
	ADBK_ID               CHAR(20) NOT NULL,
	 PRIMARY KEY (ADBK_CONSTNT_ID,ADBK_ID),
	FOREIGN KEY COMTNADBK_FK1 (ADBK_ID) REFERENCES COMTNADBKMANAGE(ADBK_ID)
		ON DELETE CASCADE
)
;

CREATE UNIQUE INDEX COMTNADBK_PK ON COMTNADBK
(
	ADBK_CONSTNT_ID,
	ADBK_ID
)
;
CREATE INDEX COMTNADBK_i01 ON COMTNADBK
(
	ADBK_ID
)
;



/* 약관정보 */
CREATE TABLE COMTNSTPLATINFO
(
	USE_STPLAT_ID         CHAR(20) NOT NULL,
	USE_STPLAT_NM         VARCHAR(100) NULL,
	USE_STPLAT_CN         MEDIUMTEXT NULL,
	INFO_PROVD_AGRE_CN    MEDIUMTEXT NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (USE_STPLAT_ID)
)
;

CREATE UNIQUE INDEX COMTNSTPLATINFO_PK ON COMTNSTPLATINFO
(
	USE_STPLAT_ID
)
;



/* 업무사용자정보변경내역 */
CREATE TABLE COMTHEMPLYRINFOCHANGEDTLS
(
	EMPLYR_ID             VARCHAR(20) NOT NULL,
	CHANGE_DE             CHAR(20) NOT NULL,
	ORGNZT_ID             CHAR(20) NULL,
	GROUP_ID              CHAR(20) NULL,
	EMPL_NO               VARCHAR(20) NULL,
	SEXDSTN_CODE          CHAR(1) NULL,
	BRTHDY                CHAR(20) NULL,
	FXNUM                 VARCHAR(20) NULL,
	HOUSE_ADRES           VARCHAR(100) NULL,
	HOUSE_END_TELNO       VARCHAR(4) NULL,
	AREA_NO               VARCHAR(4) NULL,
	DETAIL_ADRES          VARCHAR(100) NULL,
	ZIP                   VARCHAR(6) NULL,
	OFFM_TELNO            VARCHAR(20) NULL,
	MBTLNUM               VARCHAR(20) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	HOUSE_MIDDLE_TELNO    VARCHAR(4) NULL,
	PSTINST_CODE          CHAR(8) NULL,
	EMPLYR_STTUS_CODE     CHAR(1) NULL,
	ESNTL_ID              CHAR(20) NULL,
	 PRIMARY KEY (EMPLYR_ID,CHANGE_DE),
	FOREIGN KEY COMTHEMPLYRINFOCHANGEDTLS_FK1 (EMPLYR_ID) REFERENCES COMTNEMPLYRINFO(EMPLYR_ID)
)
;

CREATE UNIQUE INDEX COMTHEMPLYRINFOCHANGEDTLS_PK ON COMTHEMPLYRINFOCHANGEDTLS
(
	EMPLYR_ID,
	CHANGE_DE
)
;
CREATE INDEX COMTHEMPLYRINFOCHANGEDTLS_i01 ON COMTHEMPLYRINFOCHANGEDTLS
(
	EMPLYR_ID
)
;



/* 마이페이지 컨텐츠 */
CREATE TABLE COMTNINDVDLPGECNTNTS
(
	CNTNTS_ID             VARCHAR(20) NOT NULL,
	CNTNTS_NM             VARCHAR(100) NOT NULL,
	CNTC_URL              VARCHAR(255) NOT NULL,
	CNTNTS_USE_AT         CHAR(1) NOT NULL,
	CNTNTS_LINK_URL       VARCHAR(1000) NULL,
	CNTNTS_DC             VARCHAR(250) NULL,
	 PRIMARY KEY (CNTNTS_ID)
)
;

CREATE UNIQUE INDEX COMTNINDVDLPGECNTNTS_PK ON COMTNINDVDLPGECNTNTS
(
	CNTNTS_ID
)
;



/* 마이페이지 설정 */
CREATE TABLE COMTNINDVDLPGEESTBS
(
	EMPLYR_ID             VARCHAR(20) NOT NULL,
	UPEND_IMAGE           VARCHAR(1024) NULL,
	TITLEBAR_COLOR        CHAR(7) NULL,
	ALGN_MTHD             CHAR(1) NULL,
	ALGN_CO               NUMERIC(10) NULL,
	 PRIMARY KEY (EMPLYR_ID)
)
;

CREATE UNIQUE INDEX COMTNINDVDLPGEESTBS_PK ON COMTNINDVDLPGEESTBS
(
	EMPLYR_ID
)
;



/* 도움말정보 */
CREATE TABLE COMTNHPCMINFO
(
	HPCM_ID               CHAR(20) NOT NULL,
	HPCM_SE_CODE          CHAR(1) NULL,
	HPCM_DFN              VARCHAR(1000) NULL,
	HPCM_DC               VARCHAR(2500) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (HPCM_ID)
)
;

CREATE UNIQUE INDEX COMTNHPCMINFO_PK ON COMTNHPCMINFO
(
	HPCM_ID
)
;



/* 용어사전정보 */
CREATE TABLE COMTNWORDDICARYINFO
(
	WORD_ID               CHAR(20) NOT NULL,
	WORD_NM               VARCHAR(255) NULL,
	ENG_NM                VARCHAR(60) NULL,
	WORD_DC               VARCHAR(4000) NULL,
	SYNONM                VARCHAR(100) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (WORD_ID)
)
;

CREATE UNIQUE INDEX COMTNWORDDICARYINFO_PK ON COMTNWORDDICARYINFO
(
	WORD_ID
)
;



/* FAQ정보 */
CREATE TABLE COMTNFAQINFO
(
	FAQ_ID                CHAR(20) NOT NULL,
	QESTN_SJ              VARCHAR(255) NULL,
	QESTN_CN              VARCHAR(2500) NULL,
	ANSWER_CN             VARCHAR(2500) NULL,
	RDCNT                 NUMERIC(10) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NOT NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NOT NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	QNA_PROCESS_STTUS_CODE  CHAR(1) NULL,
	 PRIMARY KEY (FAQ_ID),
	FOREIGN KEY COMTNFAQINFO_FK1 (ATCH_FILE_ID) REFERENCES COMTNFILE(ATCH_FILE_ID)
)
;

CREATE UNIQUE INDEX COMTNFAQINFO_PK ON COMTNFAQINFO
(
	FAQ_ID
)
;
CREATE INDEX COMTNFAQINFO_i01 ON COMTNFAQINFO
(
	ATCH_FILE_ID
)
;



/* QA정보 */
CREATE TABLE COMTNQAINFO
(
	QA_ID                 CHAR(20) NOT NULL,
	QESTN_SJ              VARCHAR(255) NULL,
	QESTN_CN              VARCHAR(2500) NULL,
	WRITNG_DE             CHAR(20) NULL,
	RDCNT                 NUMERIC(10) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	QNA_PROCESS_STTUS_CODE  CHAR(1) NULL,
	WRTER_NM              VARCHAR(20) NULL,
	ANSWER_CN             VARCHAR(2500) NULL,
	WRITNG_PASSWORD       VARCHAR(20) NULL,
	ANSWER_DE             CHAR(20) NULL,
	EMAIL_ANSWER_AT       CHAR(1) NULL,
	AREA_NO               VARCHAR(4) NULL,
	MIDDLE_TELNO          VARCHAR(4) NULL,
	END_TELNO             VARCHAR(4) NULL,
	 PRIMARY KEY (QA_ID)
)
;

CREATE UNIQUE INDEX COMTNQAINFO_PK ON COMTNQAINFO
(
	QA_ID
)
;



/* 행정용어사전관리 */
CREATE TABLE COMTNADMINISTRATIONWORD
(
	ADMINIST_WORD_ID      CHAR(20) NOT NULL,
	ADMINIST_WORD_NM      VARCHAR(255) NULL,
	ADMINIST_WORD_ENG_NM  VARCHAR(255) NULL,
	ADMINIST_WORD_ABRV_NM  VARCHAR(255) NULL,
	THEMA_RELM            VARCHAR(255) NULL,
	WORD_SE               VARCHAR(255) NULL,
	RELATE_STD_WORD       VARCHAR(255) NULL,
	ADMINIST_WORD_DFN     VARCHAR(2500) NULL,
	ADMINIST_WORD_DC      VARCHAR(4000) NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	 PRIMARY KEY (ADMINIST_WORD_ID)
)
;

CREATE UNIQUE INDEX COMTNADMINISTRATIONWORD_PK ON COMTNADMINISTRATIONWORD
(
	ADMINIST_WORD_ID
)
;



/* 온라인메뉴얼 */
CREATE TABLE COMTNONLINEMANUAL
(
	ONLINE_MNL_ID         CHAR(20) NOT NULL,
	ONLINE_MNL_SE_CODE    CHAR(3) NULL,
	ONLINE_MNL_DFN        MEDIUMTEXT NULL,
	ONLINE_MNL_DC         MEDIUMTEXT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	ONLINE_MNL_NM         VARCHAR(255) NULL,
	 PRIMARY KEY (ONLINE_MNL_ID)
)
;

CREATE UNIQUE INDEX COMTNONLINEMANUAL_PK ON COMTNONLINEMANUAL
(
	ONLINE_MNL_ID
)
;



/* 상담내역 */
CREATE TABLE COMTNCNSLTLIST
(
	CNSLT_ID              CHAR(20) NOT NULL,
	CNSLT_SJ              VARCHAR(255) NULL,
	OTHBC_AT              CHAR(1) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	CNSLT_CN              VARCHAR(2500) NULL,
	MANAGT_CN             VARCHAR(2500) NULL,
	MANAGT_DE             CHAR(20) NULL,
	RDCNT                 NUMERIC(10) NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	AREA_NO               VARCHAR(4) NULL,
	MIDDLE_TELNO          VARCHAR(4) NULL,
	END_TELNO             VARCHAR(4) NULL,
	FRST_MBTLNUM          VARCHAR(4) NULL,
	MIDDLE_MBTLNUM        VARCHAR(4) NULL,
	END_MBTLNUM           VARCHAR(4) NULL,
	WRITNG_DE             CHAR(20) NULL,
	WRTER_NM              VARCHAR(20) NULL,
	EMAIL_ANSWER_AT       CHAR(1) NULL,
	QNA_PROCESS_STTUS_CODE  CHAR(1) NULL,
	WRITNG_PASSWORD       VARCHAR(20) NULL,
	 PRIMARY KEY (CNSLT_ID)
)
;

CREATE UNIQUE INDEX COMTNCNSLTLIST_PK ON COMTNCNSLTLIST
(
	CNSLT_ID
)
;



/* 온라인POLL관리 */
CREATE TABLE COMTNONLINEPOLLMANAGE
(
	POLL_ID               CHAR(20) NOT NULL,
	POLL_NM               VARCHAR(255) NULL,
	POLL_BGNDE            CHAR(10) NULL,
	POLL_ENDDE            CHAR(10) NULL,
	POLL_KND              CHAR(3) NULL,
	POLL_DSUSE_ENNC       CHAR(1) NULL,
	POLL_ATMC_DSUSE_ENNC  CHAR(1) NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	 PRIMARY KEY (POLL_ID)
)
;

CREATE UNIQUE INDEX COMTNONLINEPOLLMANAGE_PK ON COMTNONLINEPOLLMANAGE
(
	POLL_ID
)
;



/* 온라인POLL항목 */
CREATE TABLE COMTNONLINEPOLLIEM
(
	POLL_IEM_NM           VARCHAR(255) NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	POLL_IEM_ID           CHAR(20) NOT NULL,
	POLL_ID               CHAR(20) NOT NULL,
	 PRIMARY KEY (POLL_ID,POLL_IEM_ID),
	FOREIGN KEY COMTNONLINEPOLLIEM_FK1 (POLL_ID) REFERENCES COMTNONLINEPOLLMANAGE(POLL_ID)
)
;

CREATE UNIQUE INDEX COMTNONLINEPOLLIEM_PK ON COMTNONLINEPOLLIEM
(
	POLL_ID,
	POLL_IEM_ID
)
;
CREATE INDEX COMTNONLINEPOLLIEM_i01 ON COMTNONLINEPOLLIEM
(
	POLL_ID
)
;



/* 온라인POLL결과 */
CREATE TABLE COMTNONLINEPOLLRESULT
(
	POLL_RESULT_ID        CHAR(20) NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	POLL_IEM_ID           CHAR(20) NOT NULL,
	POLL_ID               CHAR(20) NOT NULL,
	 PRIMARY KEY (POLL_RESULT_ID,POLL_IEM_ID,POLL_ID),
	FOREIGN KEY COMTNONLINEPOLLRESULT_FK1 (POLL_ID,POLL_IEM_ID) REFERENCES COMTNONLINEPOLLIEM(POLL_ID,POLL_IEM_ID)
)
;

CREATE UNIQUE INDEX COMTNONLINEPOLLRESULT_PK ON COMTNONLINEPOLLRESULT
(
	POLL_RESULT_ID,
	POLL_IEM_ID,
	POLL_ID
)
;
CREATE INDEX COMTNONLINEPOLLRESULT_i01 ON COMTNONLINEPOLLRESULT
(
	POLL_IEM_ID,
	POLL_ID
)
;



/* 뉴스정보 */
CREATE TABLE COMTNNEWSINFO
(
	NEWS_ID               CHAR(20) NOT NULL,
	NEWS_SJ               VARCHAR(100) NULL,
	NEWS_CN               VARCHAR(2500) NULL,
	NEWS_ORIGIN           VARCHAR(250) NULL,
	NTCE_AT               CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NOT NULL,
	FRST_REGISTER_ID      VARCHAR(20) NOT NULL,
	LAST_UPDT_PNTTM       DATETIME NOT NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NOT NULL,
	NTCE_DE               CHAR(20) NULL,
	ATCH_FILE_ID          CHAR(20) NULL,
	 PRIMARY KEY (NEWS_ID),
	FOREIGN KEY COMTNNEWSINFO_FK1 (ATCH_FILE_ID) REFERENCES COMTNFILE(ATCH_FILE_ID)
		ON DELETE SET NULL
)
;

CREATE UNIQUE INDEX COMTNNEWSINFO_PK ON COMTNNEWSINFO
(
	NEWS_ID
)
;
CREATE INDEX COMTNNEWSINFO_i01 ON COMTNNEWSINFO
(
	ATCH_FILE_ID
)
;



/* 사이트목록 */
CREATE TABLE COMTNSITELIST
(
	SITE_ID               CHAR(20) NOT NULL,
	SITE_NM               VARCHAR(100) NULL,
	SITE_URL              VARCHAR(100) NULL,
	SITE_DC               VARCHAR(1000) NULL,
	SITE_THEMA_CL_CODE    VARCHAR(2) NULL,
	ACTVTY_AT             CHAR(1) NULL,
	USE_AT                CHAR(1) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (SITE_ID)
)
;

CREATE UNIQUE INDEX COMTNSITELIST_PK ON COMTNSITELIST
(
	SITE_ID
)
;



/* 추천사이트정보 */
CREATE TABLE COMTNRECOMENDSITEINFO
(
	RECOMEND_SITE_ID      CHAR(20) NOT NULL,
	RECOMEND_SITE_NM      VARCHAR(100) NULL,
	RECOMEND_SITE_URL     VARCHAR(255) NULL,
	RECOMEND_SITE_DC      VARCHAR(1000) NULL,
	RECOMEND_RESN_CN      VARCHAR(1000) NULL,
	RECOMEND_CONFM_AT     CHAR(1) NULL,
	CONFM_DE              CHAR(20) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (RECOMEND_SITE_ID)
)
;

CREATE UNIQUE INDEX COMTNRECOMENDSITEINFO_PK ON COMTNRECOMENDSITEINFO
(
	RECOMEND_SITE_ID
)
;



/* 행사/이벤트정보 */
CREATE TABLE COMTNEVENTINFO
(
	EVENT_ID              CHAR(20) NOT NULL,
	BSNS_YEAR             CHAR(4) NULL,
	BSNS_CODE             VARCHAR(2) NULL,
	EVENT_CN              VARCHAR(1000) NULL,
	EVENT_SVC_BGNDE       CHAR(20) NULL,
	SVC_USE_NMPR_CO       NUMERIC(10) NULL,
	CHARGER_NM            VARCHAR(50) NULL,
	PRPARETG_CN           VARCHAR(2500) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	EVENT_SVC_ENDDE       CHAR(20) NULL,
	EVENT_TY_CODE         CHAR(1) NULL,
	EVENT_CONFM_AT        CHAR(1) NULL,
	EVENT_CONFM_DE        CHAR(20) NULL,
	 PRIMARY KEY (EVENT_ID)
)
;

CREATE UNIQUE INDEX COMTNEVENTINFO_PK ON COMTNEVENTINFO
(
	EVENT_ID
)
;



/* 외부인사정보 */
CREATE TABLE COMTNEXTRLHRINFO
(
	EVENT_ID              CHAR(20) NOT NULL,
	EXTRL_HR_ID           CHAR(20) NOT NULL,
	SEXDSTN_CODE          CHAR(1) NULL,
	EXTRL_HR_NM           VARCHAR(60) NULL,
	OCCP_TY_CODE          CHAR(1) NULL,
	PSITN_INSTT_NM        VARCHAR(100) NULL,
	BRTHDY                CHAR(20) NULL,
	AREA_NO               VARCHAR(4) NULL,
	MIDDLE_TELNO          VARCHAR(4) NULL,
	END_TELNO             VARCHAR(4) NULL,
	EMAIL_ADRES           VARCHAR(50) NULL,
	FRST_REGIST_PNTTM     DATETIME NULL,
	FRST_REGISTER_ID      VARCHAR(20) NULL,
	LAST_UPDT_PNTTM       DATETIME NULL,
	LAST_UPDUSR_ID        VARCHAR(20) NULL,
	 PRIMARY KEY (EVENT_ID,EXTRL_HR_ID),
	FOREIGN KEY COMTNEXTRLHRINFO_FK1 (EVENT_ID) REFERENCES COMTNEVENTINFO(EVENT_ID)
)
;

CREATE UNIQUE INDEX COMTNEXTRLHRINFO_PK ON COMTNEXTRLHRINFO
(
	EVENT_ID,
	EXTRL_HR_ID
)
;
CREATE INDEX COMTNEXTRLHRINFO_i01 ON COMTNEXTRLHRINFO
(
	EVENT_ID
)
;



