동물병원 데이터베이스 설계

Download Report

Transcript 동물병원 데이터베이스 설계

데이터베이스 설계 및 구축
동물병원 데이터베이스 설계
작성자 : 20078580 송영민
[email protected]
동물병원 데이터베이스 구축
 목차
 소개
 요구 조건 분석
 개념적 설계
 논리적 설계
 오라클 설계
 JSP 설계
20078580 송영민
2
소개
동물병원 데이터베이스 설계(1)
 제목 : 동물병원 데이터베이스
 동물병원의 업무 관계 정보를 표현
 목적
 동물병원도 일반병원과 마찬가지로 전산화 필요
 효율적인 업무
 데이터 관리
 웹 어플리케이션을 이용한 편리성
 병원 업무
 필수 요소

고객정보
•

동물정보
•

치료 대상인 동물이 존재한다.
의사정보
•

동물병원을 이용하는 고객이 존재한다.
치료를 담당하는 의사가 존재한다.
진료정보
•
20078580 송영민
치료에 대한 진료 내용이 존재한다.
3
요구사항 명세
동물병원 데이터베이스 설계(2)
 요구 조건 분석
 사용자 요구사항의 명세




회원정보
•
회원의 기본적인 정보를 저장
•
회원 ID는 유일하게 식별
동물정보
•
동물의 기본적인 정보를 저장
•
동물 번호는 유일하게 식별
의사정보
•
회원정보에 포함되어 있어야 함
•
의사의 기본적인 정보를 별도로 저장
•
의사 번호는 유일하게 식별
진료정보
•
진료에 대한 기본적인 정보를 저장
•
진료명과 처방에 대한 내용은 별도로 저장
20078580 송영민
4
개념적 설계(1)
동물병원 데이터베이스 설계(3)
 개체(엔티티,entity)
 회원정보(customer)











회원ID
성명
비밀번호
전화번호
주소
이 메일
동물번호
동물이름
동물종류
동물나이
상태
 진료내역









동물번호
진료번호
동물이름
날짜
담당의사
진료명
처방
상태
비용
 의사정보
의사번호
 의사이름
 전화번호
 이 메일

20078580 송영민
5
개념적 설계(2)
동물병원 데이터베이스 설계(3)
 초기 모델 설계
 엔티티 설계
 기본 키

회원정보는 회원ID를 기본 키로 한다.

의사정보는 의사번호를 기본 키로 한다.

진료내역은 동물번호와 진료번호를 기본 키로 한다.
20078580 송영민
6
개념적 설계(3)
동물병원 데이터베이스 설계(3)
 초기 모델 설계
 제1정규화
20078580 송영민
7
개념적 설계(4)
동물병원 데이터베이스 설계(3)
 초기 모델 설계
 제2정규화

부분함수적 종속성을 제거하는 과정

복합키 애트리뷰트의 부분함수적 종속성을 분리

새로운 엔티티를 생성
 설명

동물정보 엔티티의 동물번호와 동물이름은 복합키로 구
성된 애트리뷰트는 동물종류, 동물나이, 주인이름, 상태
등에 종속된다.

동물번호 애트리뷰트는 동물종류, 동물나이, 주인이름 등
을 종속 관계에 있다.

이를 분리하여 엔티티를 새로 생성한다.
20078580 송영민
8
개념적 설계(5)
동물병원 데이터베이스 설계(3)
 초기 모델 설계
 제3정규화

이행적 종속성을 제거하는 과정

기본키 외의 애트리뷰트에 종속되는 애트리뷰트를 제거
 설명

진료상세 엔티티의 진료번호 애트리뷰트는 진료명과 처
방 애트리뷰트를 종속하고 있다.

진료번호 애트리뷰트와 진료명은 이행적 종속성을 가지
고 있다.

종속되는 애트리뷰트를 제거하여 새로운 엔티티 생성
20078580 송영민
9
논리적 설계(1)
동물병원 데이터베이스 설계(4)
 테이블
 회원정보(customer)
성명
회원ID
c_name
c_id
c_password
char(20)
char(15)
char(20)
비밀번호 전화번호
c_phone
char(20)
주소
이메일
c_addres
c_email
char(20)
char(20)
 동물정보(animal)
동물번호
동물종류
동물나이
주인ID
a_number
a_classification
a_age
a_id
char(20)
number(3)
char(20)
number(10)
 동물상세(animal2)
동물번호
동물이름
상태
a2_number
a2_name
a2_condition
char(20)
char(10)
number(10)
20078580 송영민
10
논리적 설계(2)
동물병원 데이터베이스 설계(4)
 의사정보(doctor)
의사번호
의사이름
전화번호
이메일
d_number
d_name
d_phone
d_email
number(10)
char(20)
char(20)
char(20)
 진료내역(treatment)
동물번호
동물이름
담당의사
상태
날짜
t_number
t_name
t_dname
t_condition
t_date
number(10)
char(20)
char(20)
char(20)
char(20)
 진료상세(i_treatment)
동물번호
동물종류
i_number
i_classification
number(10)
char(20)
 진료상세(i_treatment2)
진료명
처방
비용
i2_name
i2_ricipe
i2_price
char(20)
number(10)
char(10)
20078580 송영민
11
오라클 설계(1)
동물병원 데이터베이스 설계(5)
 회원정보(customer)

create table customer(

c_name varchar(20) not null,

c_id

c_password varchar(15) not null,

c_phone

c_email varchar(20),

CONSTRAINT cu_id_pk PRIMARY KEY(c_id));
varchar(20) not null,
varchar(20),
 동물정보(animal)

create table animal(

a_number
number(10) not null,

a_classfication
varchar(20),

a_age
number(3),

a_id
varchar(20) not null,

CONSTRAINT an_nu_pk PRIMARY KEY(a_number),

CONSTRAINT an_cu_id_fk FOREIGN KEY(a_id)
REFERENCES customer(c_id));
20078580 송영민
12
오라클 설계(1)
동물병원 데이터베이스 설계(5)
 동물상세(animal2)

create table animal2(

a2_number

a2_name

a2_condition

CONSTRAINT an2_an_nu_fk
number(10) not null,
varchar(20),
varchar(10),
FOREIGN
KEY(a2_number) REFERENCES animal(a_number));
 의사정보(doctor)

create table doctor(

d_number
number(10) not null,

d_name
varchar(20) not null,

d_phone

d_email

CONSTRAINT do_nu_pk PRIMARY KEY(d_number));
20078580 송영민
varchar(20),
varchar(20),
13
오라클 설계(1)
동물병원 데이터베이스 설계(5)
 진료내역(treatment)

create table treatment(

t_number
number(10) not null,

t_name
varchar(20),

t_dname

t_condition
varchar(20),

t_date
varchar(20),

CONSTRAINT tr_an_nu_fk FOREIGN KEY(t_number)
varchar(20) not null,
REFERENCES animal(a_number));
 진료상세(i_treatment)

create table i_treatment(

i_number
number(10) not null,

i_classfication
varchar(20),

CONSTRAINT it_an_nu_fk FOREIGN KEY(i_number)
REFERENCES animal(a_number));
 진료상세2(i_treatment2)

create table i_treatment2(

i2_name

i2_ricipe

i2_price number(10));
20078580 송영민
varchar(10) not null,
varchar(20) not null,
14
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 회원정보(customer)
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Kim Do Hwan', 'ID1', 'password1', '010-1111-1111',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Park Ha Ni', 'ID2', 'password2', '010-3333-2222',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Go Gil Dong', 'ID3', 'password3', '010-3333-3333',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Choi Go Man', 'ID4', 'password4', '010-4444-4444',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Lee Seung Pil', 'ID5', 'password5', '010-5555-5555',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Choi Woo In', 'ID6', 'password6', '010-6666-6666',
'[email protected]');
insert into customer(c_name, c_id, c_password, c_phone, c_email)
values('Song Young Min', 'ID7', 'password7', '010-7777-7777',
'[email protected]');
20078580 송영민
15
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 동물정보(animal)
insert into animal(a_number, a_classfication, a_age,
values('00001', 'maltese', '2', 'ID1');
insert into animal(a_number, a_classfication, a_age,
values('00002', 'maltese', '4', 'ID3');
insert into animal(a_number, a_classfication, a_age,
values('00003', 'maltese', '6', 'ID4');
insert into animal(a_number, a_classfication, a_age,
values('00004', 'shihtzu', '3', 'ID5');
insert into animal(a_number, a_classfication, a_age,
values('00005', 'shihtzu', '2', 'ID5');
insert into animal(a_number, a_classfication, a_age,
values('00006', 'bulldog', '8', 'ID6');
insert into animal(a_number, a_classfication, a_age,
values('00007', 'chihuahua', '1', 'ID6');
insert into animal(a_number, a_classfication, a_age,
values('00008', 'chihuahua', '10', 'ID7');
insert into animal(a_number, a_classfication, a_age,
values('00009', 'doberman', '5', 'ID7');
20078580 송영민
a_id)
a_id)
a_id)
a_id)
a_id)
a_id)
a_id)
a_id)
a_id)
16
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 동물상세(animal2)
insert into animal2(a2_number, a2_name,
values('00002', 'bob', 'good');
insert into animal2(a2_number, a2_name,
values('00004', 'babo', 'good');
insert into animal2(a2_number, a2_name,
values('00005', 'smith', 'good');
insert into animal2(a2_number, a2_name,
values('00008', 'james', 'good');
insert into animal2(a2_number, a2_name,
values('00009', 'boksil', 'good');
20078580 송영민
a2_condition)
a2_condition)
a2_condition)
a2_condition)
a2_condition)
17
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 의사정보(doctor)
insert into doctor(d_number, d_name, d_phone, d_email)
values('01', 'Da Go Chim', '033-646-1111',
'[email protected]');
insert into doctor(d_number, d_name, d_phone, d_email)
values('02', 'Song Ya Mae', '033-646-2222',
'[email protected]');
insert into doctor(d_number, d_name, d_phone, d_email)
values('03', 'Su Jeun Jeung', '033-646-3333',
'[email protected]');
20078580 송영민
18
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 진료내역(treatment)
insert into treatment(t_number, t_name, t_dname, t_condition,
t_date)
values('00002', 'bob', 'Su Jeun Jeung', 'good', '2012/06/15');
insert into treatment(t_number, t_name, t_dname, t_condition,
t_date)
values('00004', 'babo', 'Su Jeun Jeung', 'bed', '2012/06/16');
insert into treatment(t_number, t_name, t_dname, t_condition,
t_date)
values('00005', 'smith', 'Da Go Chim', 'good', '2012/06/17');
insert into treatment(t_number, t_name, t_dname, t_condition,
t_date)
values('00008', 'james', 'Su Jeun Jeung', 'bed', '2012/06/17');
insert into treatment(t_number, t_name, t_dname, t_condition,
t_date)
values('00009', 'boksil', 'Song Ya Mae', 'good', '2012/06/18');
20078580 송영민
19
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 진료상세(i_treatment)
insert into i_treatment(i_number, i_classfication)
values('00002', 'maltese');
insert into i_treatment(i_number, i_classfication)
values('00004', 'shihtzu');
insert into i_treatment(i_number, i_classfication)
values('00005', 'shihtzu');
insert into i_treatment(i_number, i_classfication)
values('00008', 'chihuahua');
insert into i_treatment(i_number, i_classfication)
values('00009', 'doberman');
20078580 송영민
20
오라클 설계(2)
동물병원 데이터베이스 설계(5)
 진료상세2(i_treatment2)
insert into i_treatment2(i2_name, i2_ricipe, i2_price)
values('fracture', 'operation', '300000');
insert into i_treatment2(i2_name, i2_ricipe, i2_price)
values('dislocation', 'operation', '100000');
insert into i_treatment2(i2_name, i2_ricipe, i2_price)
values('filaria', 'vaccination', '50000');
insert into i_treatment2(i2_name, i2_ricipe, i2_price)
values('hwa byung', 'medicine', '20000');
20078580 송영민
21
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 메인 화면
<html>
<head>
<title>Animal Hospital by 20078580 SongYoungMin</title>
</head>
<body bgcolor=white>
<table border="0">
<tr>
<td>
</td>
<td>
<h1><span style="font-family:gothic; color:blue"> 동물병원 데이터
베이스 시스템</font></h1>
<HR>
<BR>
</td>
</tr>
</table>
<ul>
<li><A href="selecttable.html">관리자 전용</A><BR>
<BR>
<li><A href="customer_update.jsp">회원정보 수정</A><BR>
<BR>
<li><A href="customer_delete.jsp">회원 탈퇴</A><BR>
<BR>
<li><A href="register.jsp">회원 가입</A><BR>
<BR>
</ul>
</body>
</html>
20078580 송영민
22
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 메인 화면
20078580 송영민
23
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 테이블 확인 소스
Statement stmt = con.createStatement();
ResultSet rs =
stmt.executeQuery("SELECT * FROM customer"); out.println("<table
border=1>"); out.println("<tr>");
out.println("<td bgcolor=#cccccc, align=center>" + "NAME" +
"</td>");
out.println("<td bgcolor=#cccccc,
align=center>" + "ID" + "</td>");
out.println("<td bgcolor=#cccccc, align=center>" + "PASSWORD"
+ "</td>");
out.println("<td bgcolor=#cccccc,
align=center>" + "PHONE" + "</td>");
out.println("<td bgcolor=#cccccc, align=center>" + "EMAIL" +
"</td>");
while(rs.next()) {
out.println("<tr>");
out.println("<td>" +
rs.getString(1) + "</td>");
out.println("<td>" +
rs.getString(2) + "</td>");
out.println("<td>" +
rs.getString(3) + "</td>");
out.println("<td>" +
rs.getString(4) + "</td>");
out.println("<td>" +
rs.getString(5) + "</td>");
out.println("</tr>");
}
20078580 송영민
24
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 테이블 종류 목록
20078580 송영민
25
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 고객 테이블 화면
20078580 송영민
26
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 수정 소스
String name =
request.getParameter("name");
String id =
request.getParameter("id");
String password =
request.getParameter("password"); String cname =
request.getParameter("cname");
String cid =
request.getParameter("cid");
String cpassword =
request.getParameter("cpassword"); String cphone =
request.getParameter("cphone"); String cemail =
request.getParameter("cemail"); //POST로 register.jsp로부터 입력받은 내용을
변수화
String sql = "update customer set c_name = ?, c_id = ?,
c_password = ?, c_phone = ?, c_email = ? where c_name = ? and c_id = ?
and c_password = ?";
PreparedStatement pstmt =
con.prepareStatement(sql);
pstmt.setString(1, cname);
pstmt.setString(2, cid); pstmt.setString(3, cpassword);
pstmt.setString(4, cphone);
pstmt.setString(5, cemail);
pstmt.setString(6, name);
pstmt.setString(7, id);
pstmt.setString(8, password); int n =
pstmt.executeUpdate(); pstmt.close();
con.close();
20078580 송영민
27
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 수정 입력
20078580 송영민
28
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 가입 소스
String name =
request.getParameter("name");
String id =
request.getParameter("id");
String password =
request.getParameter("password"); String phone =
request.getParameter("phone"); String email =
request.getParameter("email"); //POST로 register.jsp로부터 입력받은 내용을 변
수화
String sql = "INSERT INTO customer(c_name, c_id, c_password,
c_phone, c_email)"+"values(?, ?, ?, ?, ?)";
PreparedStatement pstmt =
con.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setString(2, id);
pstmt.setString(3, password);
pstmt.setString(4, phone);
pstmt.setString(5, email);
int n = pstmt.executeUpdate(); pstmt.close();
con.close();
20078580 송영민
29
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 가입 입력
20078580 송영민
30
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 가입 완료
20078580 송영민
31
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 탈퇴 소스
String name =
request.getParameter("name");
String id
=
request.getParameter("id");
String password =
request.getParameter("password"); String phone =
request.getParameter("phone"); String email =
request.getParameter("email"); //POST로 register.jsp로부터 입력받
은 내용을 변수화
String sql = "delete from customer where
c_name = ? and c_id = ? and c_password = ?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setString(2, id);pstmt.setString(3, password); int
n = pstmt.executeUpdate(); pstmt.close(); con.close();
20078580 송영민
32
JSP 설계(1)
동물병원 데이터베이스 설계(6)
 회원 탈퇴
20078580 송영민
33
The End
20078580 송영민
동물병원 데이터베이스 설계(5)
34