Content

Board ID 915
Writer 허진경
Write Date 2018-10-11 14:38:47
Subject 모델링 샘플 테이블 작성
Content /* 카테고리 */ DROP TABLE BOARD_CATEGORY CASCADE CONSTRAINTS; /* 게시판 */ DROP TABLE BOARD CASCADE CONSTRAINTS; /* 첨부파일 */ DROP TABLE BOARD_FILE CASCADE CONSTRAINTS; /* 코멘트 */ DROP TABLE BOARD_COMMENT CASCADE CONSTRAINTS; /* 카테고리 */ CREATE TABLE BOARD_CATEGORY ( CATEGORY_ID NUMBER NOT NULL, /* 카테고리아이디 */ CATEGORY_NAME VARCHAR2(100) NOT NULL, /* 카테고리이름 */ CATEGORY_CLASS1 VARCHAR2(100) NOT NULL, /* 카테고리분류1 */ CATEGORY_CLASS2 VARCHAR2(100) NOT NULL, /* 카테고리분류2 */ CATEGORY_DESCRIPTION VARCHAR2(255) /* 카테고리설명 */ ); ALTER TABLE BOARD_CATEGORY ADD CONSTRAINT PK_BOARD_CATEGORY PRIMARY KEY ( CATEGORY_ID ); /* 게시판 */ CREATE TABLE BOARD ( BOARD_ID NUMBER NOT NULL, /* 게시글아이디 */ CATEGORY_ID NUMBER NOT NULL, /* 카테고리아이디 */ WRITER VARCHAR2(50) NOT NULL, /* 작성자이름 */ EMAIL VARCHAR2(40) NOT NULL, /* 작성자이메일 */ TITLE VARCHAR2(255) NOT NULL, /* 제목 */ CONTENT VARCHAR2(4000), /* 내용 */ WRITE_DATE TIMESTAMP NOT NULL, /* 작성일자 */ PASSWORD VARCHAR2(255) NOT NULL, /* 비밀번호 */ MASTER_ID NUMBER, /* 메인글아이디 */ REPLY_NUMBER NUMBER, /* 댓글순서 */ REPLY_STEP NUMBER, /* 댓글단계 */ READ_COUNT NUMBER /* 조회수 */ ); ALTER TABLE BOARD ADD CONSTRAINT PK_BOARD PRIMARY KEY ( BOARD_ID ); /* 첨부파일 */ CREATE TABLE BOARD_FILE ( FILE_ID NUMBER NOT NULL, /* 파일아이디 */ BOARD_ID NUMBER NOT NULL, /* 게시글아이디 */ FILE_NAME VARCHAR2(255) NOT NULL, /* 파일이름 */ FILE_SIZE NUMBER NOT NULL, /* 파일크기 */ FILE_CONTENT_TYPE VARCHAR2(255) NOT NULL, /* 파일타입 */ FILE_DATA BLOB NOT NULL /* 파일데이터 */ ); ALTER TABLE BOARD_FILE ADD CONSTRAINT PK_BOARD_FILE PRIMARY KEY ( FILE_ID ); /* 코멘트 */ CREATE TABLE BOARD_COMMENT ( COMMENT_ID NUMBER NOT NULL, /* 코멘트아이디 */ BOARD_ID NUMBER NOT NULL, /* 게시글아이디 */ COMMENT_CONTENT VARCHAR2(4000) NOT NULL, /* 코멘트내용 */ COMMENT_WRITER VARCHAR2(50) NOT NULL, /* 코멘트작성자 */ COMMENT_DATETIME TIMESTAMP NOT NULL /* 코멘트작성일시 */ ); ALTER TABLE BOARD_COMMENT ADD CONSTRAINT PK_BOARD_COMMENT PRIMARY KEY ( COMMENT_ID ); ALTER TABLE BOARD ADD CONSTRAINT FK_BOARD_CATEGORY_TO_BOARD FOREIGN KEY ( CATEGORY_ID ) REFERENCES BOARD_CATEGORY ( CATEGORY_ID ); ALTER TABLE BOARD_FILE ADD CONSTRAINT FK_BOARD_TO_BOARD_FILE FOREIGN KEY ( BOARD_ID ) REFERENCES BOARD ( BOARD_ID ); ALTER TABLE BOARD_COMMENT ADD CONSTRAINT FK_BOARD_TO_BOARD_COMMENT FOREIGN KEY ( BOARD_ID ) REFERENCES BOARD ( BOARD_ID );