Study/Etc.

Database System Implementation - chapter 1

빨간당무 2011. 4. 20. 23:48
Data Processing System : Data -> Processor -> Information
Information Retrieval System : 정보관점

DataBase(DB) :
- A shared collection of logically related persistent data as part of the information system of an organisation
- 어느 특정조직의 응용업무에 공동 사용하기 위하여 운영상에 필요한 데이터를 완벽화, 비중복화, 구조화하여 컴퓨터 기억장치에 저장한 데이터의 집합체(C.J.Date) 

DataBase Management System(DBMS) :
- A software that provides a set of primitives for defining, accessing and manipulating data

DataBase System
- Database + H/W + S/W(DBMD) + Users

Core Terminology Reviews
- entity : objects, record, tuple
- attribute : entity, field
- domain : atomic value, type
- relationship : entity sets
- schema/intension : description of the database -> 구조, schema = data dictional = metadata = system catalog
- instance/occurrence/extension : the raw data -> 구현물
- degree : attributes, static, 필드 개수
- cardinality : tuples, dynamic, 레코드 개수 
- union compatible : operation에 대한 호환성, 연산하려는 두 object는 type이 같아야 함 

Megatron 2000 :
가상의 DBMS, Directory file (ASCII) 로 구성됨

What's wrong with the Megatron 2000 DBMS?
- Tuple layout on disk : 데이터 길이 변화시 모두 재기록해야 됨 -> 이로 인해 비용 발생
- Search expensive; no indexes : 인덱스가 없기 때문에 검색시 큰 비용이 발생
- Brute force query processing : 질의처리 성능이 좋지 않음, Join 연산시 어떤 테이블을 먼저 select 할지와 효율적인 join의 여부가 문제됨
- No buffer manager : 캐쉬가 필요함
- No concurrency control : 다수 사용자 접근시 제어 되지 않음
- No reliability : 언제든지 Data를 잃을 수 있음
- No security : 정상적인 경로가 아닌 파일 시스템을 통해 접근 가능
- No application program interface (API) / No GUI : API가 없기 때문에 다른 프로그램에서 접근할 수 있음
- Poor dictionary facilities : 데이터 베이스 구조의 저장이 없음 (System Catalog : DB의 모든 구조를 관리함 (3단계 구조를 보장함))

Problems of File System
- Data Redundancy -> Data Inconsistency : Data 변화시 다른 쪽은 변화 되지 않음 -> 불일치성 -> 원인은 Data 중복
- Data is Program Dependent : 데이터의 프로그램 의존성
- Lack of Concurrency : 동시 작업 없음
- Security Problem : 보안 문제
- Data Integrity Problem : 무결성 문제

Advantages of File System
- No Resource Overhead : 쉽게 개발이 가능함
- No Cost Overhead : 적은 비용

Advantages of DataBase System
- Non(Minimal) Redundancy -> Consistency : Data 중복을 제거(최소화)함
- Data is Program Independent : 데이터의 프로그램 비의존성 -> DB구조를 몰라도 사용가능 -> SQL로 Interface가 가능함
- Concurrency(sharing) : 공유 가능
- Data Integrity : 데이터 완전성
- Security
- Standardization : 표준화할 수 있음

Domain-Constrained Comparison (속성 강제된 비교)
- ex) SELECT ... FROM P, SP WHERE P.WEIGHT = SP.QTY;
위에서 p.weight와 sp.qty는 서로 다른 속성(Domain)으로 잘못된 질의임
그러나 도메인 개념이 지원되지 않는다면 위 질의는 합법적인 것인 된다. -> 시스템이 사용자의 실수를 방지 할 수 있다.
- 실제 상용 시스템들은 대부분 도메인 개념을 지원하지 않기 때문에 위의 질의는 정당한 것으로 처리된다. (그러나 질의 결과는 의미 없는 것이 된다.)
- 도메인 개념을 지원하지 않는 이유는 아래 경우를 보면 알 수 있다.
- ex) P.WEIGHT * SP.QTY / P.WEIGHT + SP.QTY
- 위 질의는 도메인 지원하는 경우 수행이 불가능하게 된다. 그러므로 상용시스템에서는 도메인 개념을 지원하지 않는다. (융통성)

Core Terminology Reviews - Key
- Super key : 슈퍼키, 키 값이 될 수 있는 모든 집합
- Candidate key : 후보키, 최소의 Attribute 만으로 구성된 키
- Primary key : 주키, Null 값을 가질 수 없음
- Alternate key : 대체키
- Foreign key : 외래키, 다른 Table에서는 PK임
- Super key { Candidate key { Primary key { 1개 }, Alternate key { Candidate key에서 Primary key를 제외한 모든 key } } }

Data Independence (데이터 독립성)
- Physical Data Independence (물리 데이터 독립성) : View(end user/virtual table)와 Conceptual 중간의 독립성
- Logical Data Independence (논리 데이터 독립성) : Conceptual와 Internal(stored database) 중간의 독립성

Schemas and mappings
- Schemas (3-level database architecture)
- mappings : external / conceptual, conceptual / internal

DBMS Major Functions
- Definition facility (정의 기능) : DDL(Data Definition Language), Data Dictionary = System Catalog
- Manipulation facility (조작(연산)기능) : DML (Data Manipulation Language), Query Language
- Constraint(Control) facility (제약조건 기능) : DCL (Data Control Language)

Catalog
- All of the various schemas(external, conceptual, internal) and all of the corresponding(대응하는) mappings are kept
-- relation names, attribute names, attribute domains (data types)
-- description of constraints : primary keys, foreign keys, NULL/Not-NULL, constraints, ...
-- views, storage structure, indexes
-- security, authorization, owner of each relation
- the catalog itself consists of tables (system table, dictionary, meta DB)

DBA - 역할
- 1. Defining the conceptual schema
- 2. Defining the internal schema
- 3. Liaising with users
- 4. Defining security and intergrity rules
- 5. Defining backup and recovery procedures
- 6. Monitoring performance and responding to changing requirements

Data Model
- Structure (DDL) + Manipulation (DML) + Integrity (Constraint) (DCL)

Relational Data Model 
- Structure (DDL)
-- domains (atomic values)
- n-ary releations (attirbutes, tuples)
- Manipulation (DML)
-- relational algebra (관계대수) (or relational calculus) : union, intersection, difference, product, select, project, join, divide
--- 이중 union, difference, product, select, project 는 기본적인 관계 연산자 (이것 들만 있으면 그 외에 것은 구현 가능)
- Integrity (DCL)
-- entity integrity : primary key values not be null
-- referential integrity : foreign key value must match primary key values (or be null values)

E-R Model
- Entity-Relationship Data Model(ER Model) : P. Chen
- Entity : rectangular box
- Relationship : diamond box
- participant to relationship : line
- ex) [Customer] --1-- <Sales> --n-- [Product]

Relational Operations
- Relational algebra (과정)
- Relational Calculus (골설정) -> 사용자가 선호하는 방법 (대부분의 DBMS가 사용함)

SQL 
- SELECT <attribute list>
- FROM <relation list>
- WHERE <condition>
- GROUP BY <attribute list>
- HAVING <condition>
- ORDER BY <attribute list>

View... 이후로 현재 미정리