주제 : 그룹웨어
설계시 사용 프로그램 : ERD Cloud
사용 DB : Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
팀원들과 회의를 거쳐 설계한 최종 DB이다.
회원가입 테이블 즉 employee테이블이 중심으로 참조키 설정하여
뻗어있는 부수적인 게시판들이 있는 것을 확인 할 수 있고 최종적으로 테이블은 총 11개 이다
sql문
CREATE TABLE `work_history` (
`work_num` number NOT NULL COMMENT '스키마로 자동번호',
`work_in_time` timestamp NOT NULL,
`work_out_time` timestamp NULL,
`status` VARCHAR2(30) NOT NULL COMMENT '출근/퇴근',
`work_reg_date` date NOT NULL COMMENT '출근 날짜',
`work_late` varchar2(30) NULL COMMENT 'null/지각',
`work_status` varchar2(30) NOT NULL COMMENT '근태이상/정상처리/요청중',
`emp_no` number NOT NULL
);
CREATE TABLE `secondhand` (
`no` number(10) NOT NULL,
`emp_id` varchar2(255) NOT NULL,
`title` varchar2(255) NOT NULL,
`file` varchar2(255) NULL,
`refilename` varchar2(255) NULL,
`regdate` Date NOT NULL DEFAULT sysdate,
`price` number(10) NOT NULL,
`views` number(10) NULL DEFAULT 0
);
CREATE TABLE `notice` (
`notice_no` number(10) NOT NULL,
`writer_id` VARCHAR2(255) NOT NULL,
`writer_name` VARCHAR2(255) NOT NULL,
`title` VARCHAR2(500) NOT NULL,
`regdate` date NOT NULL,
`moddate` date NOT NULL,
`read_cnt` number(10) NOT NULL DEFAULT 0,
`isshow` varchar2(1) NULL DEFAULT 'Y',
`emp_no` number NOT NULL
);
CREATE TABLE `chat` (
`chat_no` number NOT NULL,
`emp_no2` number(10) NOT NULL,
`emp_name` varchar2(20) NOT NULL,
`chat_content` varchar2 NULL,
`chat_time` timestamp NOT NULL
);
CREATE TABLE `E_Approval` (
`do_no` number NOT NULL,
`stat_no` number NOT NULL,
`title` varchar2(100) NULL,
`draft_empno` number NOT NULL,
`draft_date` date NULL,
`approval_empno` number NOT NULL,
`approval_date` date NULL,
`emp_kname` varchar2(30) NULL,
`dept_name` VARCHAR(50) NULL,
`emp_position` number NULL
);
CREATE TABLE `notice_data` (
`notice_no` number(10) NOT NULL,
`content` varchar2(4000) NOT NULL
);
CREATE TABLE `E_Status` (
`stat_no` number NOT NULL,
`stat_name` varchar2(30) NULL
);
CREATE TABLE `employee` (
`emp_no` number NOT NULL,
`emp_id` varchar2(50) NOT NULL,
`emp_pw` varchar2(50) NOT NULL,
`emp_kname` varchar2(30) NOT NULL,
`emp_ename` varchar2(30) NOT NULL,
`emp_postcode` number NOT NULL,
`emp_adress` varchar2(255) NOT NULL,
`emp_idnumber` number(13) NOT NULL,
`emp_birthday` varchar2(8) NULL,
`emp_phonenumber` number(11) NOT NULL,
`emp_email` VARCHAR2(255) NOT NULL,
`dept_name` VARCHAR(50) NOT NULL,
`emp_position` number NOT NULL COMMENT '1. 사원 2.선임 3.책임 4.수석 5.대표',
`emp_extnumber` number NULL,
`emp_grade` number(3) NOT NULL DEFAULT 1 COMMENT '1.일반 5.관리자'
);
CREATE TABLE `E_Form` (
`do_no` number NOT NULL,
`form_name` varchar2(30) NOT NULL,
`creat_empno` number NOT NULL,
`create_date` date NULL,
`title` VARCHAR(255) NULL,
`plans` VARCHAR(255) NULL,
`sugg` VARCHAR(255) NULL,
`uniq` VARCHAR(255) NULL,
`comm` VARCHAR(255) NULL
);
CREATE TABLE `secondhand_data` (
`no` int(10) NOT NULL,
`content` VARCHAR(255) NOT NULL
);
CREATE TABLE `w_edit` (
`edit_num` number NOT NULL,
`reg_date` date NOT NULL,
`edit_in_time` timestamp NOT NULL,
`edit_out_time` timestamp NULL,
`edit_emp_name` varchar2(30) NOT NULL,
`edit_req_date` timestamp NOT NULL,
`edit_status` varchar2(30) NOT NULL DEFAULT 요청중,
`reason` varchar2(500) NOT NULL,
`emp_no` number NOT NULL
);
ALTER TABLE `work_history` ADD CONSTRAINT `PK_WORK_HISTORY` PRIMARY KEY (
`work_num`
);
ALTER TABLE `secondhand` ADD CONSTRAINT `PK_SECONDHAND` PRIMARY KEY (
`no`
);
ALTER TABLE `notice` ADD CONSTRAINT `PK_NOTICE` PRIMARY KEY (
`notice_no`
);
ALTER TABLE `chat` ADD CONSTRAINT `PK_CHAT` PRIMARY KEY (
`chat_no`
);
ALTER TABLE `E_Approval` ADD CONSTRAINT `PK_E_APPROVAL` PRIMARY KEY (
`do_no`,
`stat_no`
);
ALTER TABLE `notice_data` ADD CONSTRAINT `PK_NOTICE_DATA` PRIMARY KEY (
`notice_no`
);
ALTER TABLE `E_Status` ADD CONSTRAINT `PK_E_STATUS` PRIMARY KEY (
`stat_no`
);
ALTER TABLE `employee` ADD CONSTRAINT `PK_EMPLOYEE` PRIMARY KEY (
`emp_no`
);
ALTER TABLE `E_Form` ADD CONSTRAINT `PK_E_FORM` PRIMARY KEY (
`do_no`
);
ALTER TABLE `secondhand_data` ADD CONSTRAINT `PK_SECONDHAND_DATA` PRIMARY KEY (
`no`
);
ALTER TABLE `w_edit` ADD CONSTRAINT `PK_W_EDIT` PRIMARY KEY (
`edit_num`
);
ALTER TABLE `work_history` ADD CONSTRAINT `FK_employee_TO_work_history_1` FOREIGN KEY (
`emp_no`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `secondhand` ADD CONSTRAINT `FK_employee_TO_secondhand_1` FOREIGN KEY (
`emp_id`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `notice` ADD CONSTRAINT `FK_employee_TO_notice_1` FOREIGN KEY (
`emp_no`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `chat` ADD CONSTRAINT `FK_employee_TO_chat_1` FOREIGN KEY (
`emp_no2`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `E_Approval` ADD CONSTRAINT `FK_E_Status_TO_E_Approval_1` FOREIGN KEY (
`stat_no`
)
REFERENCES `E_Status` (
`stat_no`
);
ALTER TABLE `E_Approval` ADD CONSTRAINT `FK_employee_TO_E_Approval_1` FOREIGN KEY (
`draft_empno`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `E_Approval` ADD CONSTRAINT `FK_employee_TO_E_Approval_2` FOREIGN KEY (
`approval_empno`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `notice_data` ADD CONSTRAINT `FK_notice_TO_notice_data_1` FOREIGN KEY (
`notice_no`
)
REFERENCES `notice` (
`notice_no`
);
ALTER TABLE `E_Form` ADD CONSTRAINT `FK_E_Approval_TO_E_Form_1` FOREIGN KEY (
`do_no`
)
REFERENCES `E_Approval` (
`do_no`
);
ALTER TABLE `E_Form` ADD CONSTRAINT `FK_employee_TO_E_Form_1` FOREIGN KEY (
`creat_empno`
)
REFERENCES `employee` (
`emp_no`
);
ALTER TABLE `secondhand_data` ADD CONSTRAINT `FK_secondhand_TO_secondhand_data_1` FOREIGN KEY (
`no`
)
REFERENCES `secondhand` (
`no`
);
ALTER TABLE `w_edit` ADD CONSTRAINT `FK_employee_TO_w_edit_1` FOREIGN KEY (
`emp_no`
)
REFERENCES `employee` (
`emp_no`
);
'project' 카테고리의 다른 글
23.02.04 JSTL로 특정 option selected 주기 (0) | 2023.02.04 |
---|---|
23.01.31 ERD cloud PK, FK 제약조건 (0) | 2023.01.31 |