티스토리 뷰

데이터베이스 요점정리 중간고사



데이터베이스 중간고사 범위 정리한 것 공유합니다.

시험 들어가기 전에 보는 용도로 만들었던 거라 오타가 많을 수 있습니다..ㅎㅋㅋ

sql query문 전까지 시험범위였고, 책은 Database system concept 6th edition 입니다.


Drawbacks of using file systems to store data

Data redundancy and inconsistency : 같은 data가 여러 곳에 저장되어 있을 수 있음. 이게 redundancy고 접근 비용과 많은 용량을 요구. 그리고 inconsistency는 그 같은 여러 개의 데이터의 일부분이 서로 다를 수 있음. 한 곳에선 1을 가르키고 한 곳에서는 0을 가르키는 등.

Difficulty in accessing data : 여러 개를 다 뒤져야 한다. 특정 조건에 맞는 것을 찾아주는 그런 프로그램은 없음

Data isolation : 여러 데이터 파일과 형식들로 인해 데이터를 찾는 프로그램 작성조차 어려움

Integrity problems : consistency constraints를 만족해야 하는데, 이런걸 처리하기 힘듦. 막 나이가 1000살 넘고 그럼. 그리고 이런 제약이 코드 안에 숨겨져 있어서 추가하거나 수정이 어려움

Atomicity of updates : 한 프로그램이 실행 실패하면 아예 실행이 취소되어야 하는데, 즉 한 번 실행하면 완전히 취소하거나 완벽히 끝내야 함.

Concurrent access by multiple users : 여러 유저가 동시에 접근하면 순서를 잘 정해줘야 하는데 어려움

Security Problems : 각 유저에 대한 각각의 권한을 부여하기 어려움

 

Purpose of database : provide users with an abstract view of the data.

 

Data Abstraction

Physical level : how the data are actually stored. 접근, 위치, 작성자

Logical level : what data are stored in the database and what relationships exist among those data. logical에 새로운 structure를 넣게 되면 physical level structure가 복잡해지는데 이걸 사용자들은 고려할 필요가 없음. 이것을 “Physical data independence”라고 한다. 어떤 값으로 데이터가 구성되어 있는지. 데이터의 관계성.

View level : describes only part of the entire database. Simplify their interaction with the system. 각 사용자마다 알맞은 접근 권한을 부여한다.

논리적 데이터 독립성 : 사용자가 접근하는 view단계는 logical layer가 변해도 아무 상관이 없다. (3-level)

 

Instance : 특정 시점의 database 상태 -> value of variable

Schema : 구조화를 위한 도면 (잘 변하지 않는다.) -> variable declaration

 

Data model : provides a way to describe the design of a database at the physical, logical, and view levels.

Relational Model : 대부분의 DB base 모델. value가 무엇인지 알아야 data가 될 수 있다. 두 개 이상의 metadata 필요. -> 관계

Entity-Relationship model : 가장 먼저 이용. 모든 data 구조를 entity에 넣고 entity끼리의 관계.

Object-Based Data Model : class, methodinstance화 후 dataobject화 한다.

 

DDL : Data definition language -> DDL compiler generates a set of table templates stored in a data dictionary. 표의 모양을 잡는다. 어떤 데이터의 정보가 필요한지. 데이터의 구조를 조작. outputdata dictionary(=system catalog)에 저장되고 여기선 metadate를 저장하고 있음.

domain constraints = reference integrity. 어떤 값이 가질 수 있는 제약 조건.

referential integrity : relation에 있는 값이 다른 relation에도 등장할 때 서로 같아야 한다. (값에서 차이가 발생하면 맞지 않는 것)

assertion : domain constraints, referential integrityassertion. 규제.

authorization : 각각의 사람마다 read, insert, update, delete 등 개별적인 권한을 부여

DML : Data manipulation language -> language for accessing and manipulating the data organized by the appropriate data model. = query language. 원하는 형태로 데이터를 출력 가능.

    Pure : relational algebra, tuple relational calculus, domain relational calculus. providing properties about computational power and for optimization

    Commercial : used in commercial systems.

    Procedural DML : require a user to specify what data are needed and how to get those data -> 각 절차를 저장할 수 있으나 명령이 복잡해진다.

    Declarative DML : require a user to specify what data are needed without specifying how to get those data. -> 사용이 쉬우나 사용자의 모든 요구를 구체적으로 표현할 수 없다.

 

Design process의 3단계

conceptual-design : Entity-Relation model. provides detailed overview of the enterprise.

logical-design : 의미적 datagrouping

physical-design : 논리적 부분의 서술. form of file organization and the internal storage structures.

 

Database engine의 3가지

Storage manager : physical level이라는 낮은 단계의 data 관리. 권한 관리.

Query processing : 요청을 처리한다. optimizer, evaluation.

Transaction manager : 여러 동시의 사용자가 있을 때 consistency를 유지한다.

    concurrency-control manager가 이 역할을 한다. (명령이 꼬여서 문제가 발생하지 않도록. 은행같은 업무에 특히 중요)

 

atomicity : transaction이 실행되지 않았다면 원상복구 시키는 것.

durability : transaction이 완성되면 무슨 일이 있어도 상태를 유지시키는 것.

 

arity : column의 갯수,

compatible : column의 순서와 의미. (집합 연산자를 적용하려면 두 relationarity가 같아야 한다.)

atomic : 한 내용을 분할하려면 column을 추가해야 한다.

Superkey : key가 될 수 있는 attribute집합의 집합

primary key : key로 가장 적합한 candidate key 중 하나. (자주 바뀌지 않아야 한다.)

1. unique한지

2. 축소시킬 수 없는지.

foreign key : 하나의 기본 key 값을 다른 relation에 참조할 수 있을 때. 중복이 가능함.

candidate key : superkeyirreducible한 것.

 

referential integrity constraint : reference할 값이 항상 존재해야 한다.

 

relational algebra : procedural language. 6 basic operator (select, project, union, set difference, cartesian product, rename)

additional operation으로 query를 간단하게 수정할 수 있다. (set intersection, natural join, division, assignment, outer join)

inner join은 정보에 정보를 덧붙이면서 누락이 생길 수 있다. 만약 key가 겹치지 않는다면 아예 사라지기 때문이다. 그래서 outer join이 등장하였고 열린 방향을 기준으로 반대의 relationnull이 생길 수 있다.

wheregroup 생성 전에 이용하고, having은 그룹 생성 이후에 이용한다.

correlated subquery : sub querymain querytable 이름이 나왔을 때

scalar subquery : one which is used where a single value is expected

 

view 만든 이유

1. table에서 몇 attr만 필요하거나 특정 attr만 공개해야 할 때

2. 단순 보안 문제가 아니고, table에서 계속 attr을 추출하는 것보다(똑같은 table이 계속 필요할 때) attr만 가진 테이블을 만들어주면 query문이 훨씬 짧아진다.

3. 가상 테이블이지만, 실제 테이블 역할을 한다.

4. 실질 데이터를 담아둔 것이 아니고 정의를 담아둔 것이라 물리적으로 존재하진 않는다.

5. viewdatawhere절의 조건을 만족한다면 들어가고 update도 가능하며 실제 테이블에 반영된다.

6. 그러나 새로운 column의 값 추가는 불가능하다.

7. 이렇게 좋은데 실행 속도 향상엔 도움이 안 된다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함