1 / 17

1 . 데이터베이스 기초

1 . 데이터베이스 기초. 서울시립대학교 전자전기컴퓨터공학부 김한준. Data & Database. 데이터 ( data) 정형화되고 기록할 만한 가치가 있다고 판단되는 어떤 현상이나 사건 , 아이디어에 대한 묘사 데이터베이스 ( database) 조직이나 개인이 사용하는 조작 가능한 , 저장된 데이터의 모임

sanura
Download Presentation

1 . 데이터베이스 기초

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 1. 데이터베이스 기초 서울시립대학교 전자전기컴퓨터공학부 김한준

  2. Data & Database • 데이터 (data) • 정형화되고 기록할 만한 가치가 있다고 판단되는 어떤 현상이나 사건, 아이디어에 대한 묘사 • 데이터베이스 (database) • 조직이나 개인이 사용하는 조작 가능한, 저장된 데이터의 모임 • An integrated collection of persistent data representing the information of interest for various programs that compose the computerized information system of an organization • Data are separated from the programs that use them • 체계성 (Model) • 조작성(SQL) • 공유성(Distribution) • 안전성 (Safety) • 보안성(Security) • etc Database ?

  3. Database Management System & Information System • 데이타베이스관리시스템(database management system, DBMS) • 데이타베이스의 효율적이고 편리한 사용을 가능토록 해주는 프로그램들의 집합체. (일반 컴퓨터환경에서의 OS의 기능과 유사) • DB2, Oracle, Informix, CODA, dBase, FoxPro • 정보시스템 (information system) • 조직이나 개인이 필요로 하는 결과를 제공하는 시스템으로서 데이타베이스와DBMS, 이들을 이용하는 응용프로그램 및 지원소프트웨어(support software) 등으로 이루어진 SW system. • 도서관 시스템, 항공예약 시스템, 은행시스템 • 일반적으로 어떤 조직의 「데이타베이스 시스템」이라 하면 이 정보시스템을 말하는 경우가 많다. • DB + DBMS + 응용프로그램 + 지원SW ====> 완성된 해결책 • 강의 주요 포인트 • DBMS의 구성과 기능, 그 바탕이 되는 이론과 아이디어들 • DB 설계 방법론 및 관련 이론적 이슈

  4. File System과의 비교 1234 홍길동 95 86 75 2357 김철수 65 97 77 ‥‥‥‥‥‥‥‥‥ [EOB] • File System • COBOL,C등의 프로그램에서 데이터 file이용 • Data redundancy and inconsistency 문제 발생 • 프로그램 이외의 방법으로도 데이터 조작가능 : 아래한글, vi, emacs등의 에디터 이용 • 각 프로그램마다 그 고유의 데이터 format: 공유하기 어려움 • 만약 share했을 경우에 concurrency문제 • System failure시 recovery문제: atomicity problem • 보안 문제 • DBMS의 필요성 • File System의 한계를 극복 • data sharing 곤란, concurrency 문제 • recovery 문제 • security 문제 • 실세계를 표현하는 틀인 data model을 제공 • 효율적인 자원 (메모리 및 디스크) 관리 • 복잡한 질의를 통한 데이터 검색 • 역사 : 공통적인 데이터 관리 기능을 DBMS로 수용 예: 주소록 화일 시작된 DB연산은 반드시 종료 되어함. 중도에 문제가 생길 시 undo 처리

  5. Database Management System (DBMS) • DBMS의 기능 • Data model제공 • 사용자가 저장 관리하고자 하는 데이터의 구조를 정의할 수 있는 기반 마련 (Entity들과 그들 사이의 관계표현방식 제공 • Data sharing 제공 • Query Language (질의언어) 제공 • 사용자가 데이터 조작을 쉽게 하기 위한 언어 제공 • Data integrity (데이터 무결성)을 유지 • 데이터의 복구 시스템 • 다중 사용자를 지원 • 동일한 데이터를 접근할 시 Locking 메커니즘 작동 • 효율적인 자원 (disk, memory) 관리 • 보안성 제공 • Permission을 가진 사용자만이 데이터에 접근 • Database를 다루는데 필요한 “공통”기능들을 제공 • 언제 DBMS를 사용해야 하나 ? • 여러 사람이 사용 • OLTP 처리시 • mission critical application 개발 • 은행 구좌 관리 • 항공사의 예약 관리 • 학교 수강신청/성적 관리 • 특수한 데이터 타입을 가지는 데이터의 효율적인 검색 • 문헌정보 검색 시스템 • 지리정보 시스템 • 대용량의 데이터를 효율적으로 관리 • Application 개발의 용이성 내부구조가 복잡한 객체데이터 타입으로서, 공간정보, 문서정보 등이며, 보통 계층적 포함관계를 가짐

  6. DBMS의 기능: 무결성, 다중사용자지원 • 무결성 (Integrity) • 결함이 없는 데이터가 저장되도록 여러 형태의 내부 규약을 정의할 수있음 • Domain Integrity • Referential Integrity • 예) • 학생 테이블에서 갖은 학번이 두 번 이상 나타나면 안됨 • 학생의 학번은 97이나 98로 시작 • 교수번호는 3자리의 숫자만이 허용 • 지도 테이블의 모든 학번은 학생테이블의 학번에 존재 • 다중사용자지원 • 여러 사용자가 동시에 하나의 데이터에 대한 연산을 수행하도록 지원 • 다중 사용자로 인한 문제점 • 예) 은행에서 A와 B란 사람이 100만원이 입금된 C구좌에서 50만원 씩 동시에 출금할 때 B A Read C Read C C = C-50 C = C-50 Write C Write C • 원래는 0원, 그러나 50만원이 남아 있음. • 동시에 수행된다 하더라도 A와 B가 순차적으로 수행한 결과와 같음을 보장해야 함 => Serializability

  7. DBMS의 기능: 트랜잭션, 보안성 지원 • Transaction (트랜잭션) • a collection of operations that performs a single logical function in a database application • programmer is responsible for writing “correct” transactions • DBMS는 atomicity와 durability를 보장 • atomicity : “all-or-nothing” • 하나의 transaction이 시작되면 반드시 완료(commit)되어야 함. • durability : “The effect of DB operations should be persistent.” • DB연산의 결과는 반드시 DB에 저장되어야 함 • 보안성 • 허용되지 않은 사용자로부터 데이터의 검색이나 삽입 삭제를 방지 • 예) • 학생들은 학생 테이블 만을 검색할 수 있으며 모든 테이블에 대한 수정이 불가능 • 교수는 모든 테이블에 대한 검색이 가능하나 수정이 불가능 • 전산 직원은 모든 테이블에 대한 검색과 수정이 가능

  8. DBMS의 기능: 데이터 복구 (Recovery) • 은행에서 A계좌에서 B계좌로 100만원을 이체해라 • A = A - 100 • B = B + 100 • 이때 A계좌에서 100만원을 뺀 후 B 계좌에 넣기 직전 시스템이 멈추면 결과는? • 데이터베이스 서버의 물리적 손상이 가해진 경우 • 해결방법 • 복사본 DB 생성 • RAID (Redundant Arrays of Inexpensive Disks) 활용 • 복사본 DB 생성 방법 • 두 개 이상의 디스크에 자료를 중복 저장 • 현재까지 갱신된 기록 (log) 을 별도의 disk에 저장 보관 • Log 기록을 보고 원래의 상태로 복구 데이타A 이전 데이타 변경 데이타 변경 시간 500 400 1:00 400 300 1:01 Database 사용자 or 프로그램 Copied 데이터 A가 변경된 history를 보관 데이터 자동 copy 자동 오류검출 기능

  9. 관계형(Relational)DBMS 장점 - 수학적 기반: Relational Data Model - 간단한 형태로 인한 사용의 편이성: table & value based 단점 - Join연산으로 인한 성능저하 - Flat relation: tree & graph 표현의 어려움 • 1970년대 후반에서 80년대 초반 • 창시: E.F.Codd, 1970 CACM Paper, “The Relational Data Model” • DB연산의 기초: Relational Algebra & Calculus • 질의언어: SQL (Structured Query Language) • 초기 DBMS • System/R - 1976, 최초의 상업용 RDBMS • Ingres - 1976, 최초의 연구용 RDBMS “Bronx”시에 거주하는 고객 “Shiver”의 예금 총액 Database 질의언어: SQL select sum(amount) from customer where customer.name = “Shiver” and customer.city=“Bronx”;

  10. Database에서 data의 여러 관점의 Views • Data Abstraction • Physical Level: 실제 저장소에 저장된 모습 • Conceptual Level: 실제로 저장된 data • (User) View Level: 필요한 부분만 보여줌 View 1 ‥‥ View n 가능한 한 구체적인 사항들을 몰라도 응용할 수 있도록, “independence” 개념을 지원해야 함 Conceptual Level Physical Level

  11. Data Independence 개념 • Data Independence • ability to modify a schema in one level without affecting a schema definition in the next higher level • physical data independence : physical level - conceptual level • logical data independence : conceptual level - view level View 1 ‥‥ View n Logical data independence Conceptual Level Physical data independence Physical Level

  12. Database Scheme vs. Instance • Scheme : DB의 구조(골격) 고객 예금구좌 이름 주소 전화# 번호 종류 잔고 • Instance: 특정한 시점에서 DB의 상태 (data값들의 상태) DB state라고도 함 1993/5/20/12:00 고객 1993/6/20/12:00 고객

  13. Data Models • Data Model • 데이타와 그들간의 관계, 서로의 의미, 제약조건 등을 어떻게 나타낼 것인가에 대한 개념적인(논리적인) 틀 A. Relational model (관계형모델) • 모든 정보를(entity, relationship)를 표(table)의 형태로 표현 B. Entity-Relationship (ER) model (개체-관계형 모델) • 모든 것을 entity와 그들 간의 relationship으로만 표현 • Entity (개체): 실세계에존재하는 것을 DB에 저장하기 위해 추상화한 개념이며, 속성(attribute)을 가짐 • Relationship (관계): entity들이 상호 연결된 관계 C. Object-oriented model (객체지향 모델) • Object: entity와 비슷한 개념이나 좀더 능동적인 개념 • Attribute (속성): 변수(variable) 개념과 유사 • Message (메시지) : 상호대화 • Method (메소드) : message에 답하는 procedure * 개체-관계형 모델은 구현 모델이 아님 - 즉, 관계형 DB, 객체지향 DB는 있으나, 개체-관계형 DB 는없음

  14. Database Languages : SQL (Structured Query Language) • Procedural vs. nonprocedural languages • procedural • specify what data are needed and how to get those data • nonprocedural • declarative • specify only what data are needed • * SQL은 non-procedural lang. 임 • Query • 정보 검색을 요청하는 문장을 칭함 • Query language: part of DML • Sometimes “query language = DML” • Data Definition Language (DDL) • DB Schema를 정의하는 언어 • CREATE TABLE • DROP TABLE/COLUMN • ALTER TABLE • Data Manipulation Language (DML) • DB의 data를 조작(schema는 불변) • Retrieve -> SELECT 문 • Insert -> INSERT 문 • Delete -> DELETE 문 • Change -> UPDATE 문

  15. Transaction/Storage Management • Transaction Management • Transaction • A collection of operations that performs a single logical function in a database application • Programmer is responsible for writing “correct”transactions • DBMS must ensure the atomicity and durability of each transaction • Atomicity: all-or-nothing • Durability: effect should be persistent • Storage Management • DBMS must effectively and efficiently manage storage (disk) space • Storage manager : a program module that provides the interface between the low-level data stored in the database and the application programs and queries submitted to the system

  16. DBMS and Users • DBA (Database Administrator): DB 관리일을 관장하는 사람 • schema 정의 • storage structure, access method 정의 • schema & physical organization • 권한 부여 • backup 및 recovery 조정 • Application Programmers • DB내의 데이타를 이용하여 출력을 내는 프로그램 작성 • C, Java 등으로 작성된 프로그램 내부에 DML(SQL) embedding • 숙련 User • SQL 중 DML 직접 사용 • 일반 User • Application program이 제공하는 interface 사용 사용자 응용 프로그램 DBMS Database

  17. Database Management System 구조 SQL언어를 사용한 질의 DBMS 사용자 naive users application programmers casual users database administrator DB 관리자 application programs system calls query database scheme 응용 프로그램 data manipulation language pre-compiler query processor data definition language compiler application programs object DBMS database manager file manager Database Disk storage 실제 데이터 테이블을 포함 Database의 구조, 통계적 정보 등을 포함

More Related