벌써 시험기간이라고? 나 분명 열심히 살았는데 뭐하다가 시간이 지나간거지 ... 잘못 살았나
매일매일 시간을 쪼개며 살았던 것 같은데 학교 CS수업은 제대로 소화하지도 못하고 있다.부끄러운 줄 알아야지. 나는 지금 우선순위를 명확하게 딴 곳에 두고 거기에 몰입하고 있다고 할 수 있는 걸까?아니면 해야 하는 일이 있는데, 단지 하고 싶은 일을 우선순위라고 합리화하고 있는 걸까?
이번 달은 ... 시험공부나 열심히 해봐야지
*** 지금부터 정리하는 내용은 모두 Avil Silberschatz, Henry F.Kroth, S.Sudarshan의 "Database System Concepts 7th edition"이라는 교재와, 고려대학교 정순영 교수님의 2023년 1학기 "데이터베이스" 강의를 기반으로 하고 있다. 모든 강의자료 캡쳐본은 정순영 교수님께서 권한을 갖고 있다. ***
1) Database Design Process 전체적인 데이터베이스 설계 과정에 대해
Conceptual Design:
해당 단계에서 내가 설계한 것을 다른 사람들도 잘 이해할 수 있도록 하기 위해 정리된 방식을 사용하는데,
이때 E-R Model과 같은 모델을 활용한다.
물리적인 저장효율을 따지는 것보다, - 현실의 데이터를 어떻게 효율적으로 논리적인 구성을 할 것인가 - 에 대해 고민하는 단계로 이해했다. 이를 위해서 모델을 활용하는군
p271 ( the desinger chooses a data model and, by applying the concepts of the chosen data model, translates the requeirements into a conceptual schema of the database. ~~ Typically, the conceptual-design phase results in the creatioin of an entity-relationship diagram that provides a graphic representation of the schema. ~~ Her focus at this point is on describing the data and their relationships, rather than on specifying physical storage details. )
Logical Design:
해당 단계에서 E-R Model을 Relational Model로 변환한다.
conceptual design이후 추상적인 데이터 모델을 ➡️ 데이터베이스로 구현하는 2가지 단계가 존재 = logical-design phase / physical-design phase
logical-design phase: the designer maps the high-level concpetual schema onto the implementation data model of the database system what will be used (typically the relational data model ... )
physical-design phase: the physical features of the database are specified _ the form of file organization, choice of index structures, ... etc.
** Logical Design단계는 과정은 거의 공식화가 되어있어서 쉽지만, conceptual design단계에서 대부분의 오류가 일어난다 **
DBMS에 대해:
어떤 DBMS를 사용할 것인가?
오라클, mariaDB, mySQL 등등이 있고, DBMS도 파이썬이나 자바처럼 객체지향형이 존재하여 이럴 경우 E-R Model을 Object-Oriented Model로 변환해서 사용해야 한다.
2) Database Design Process 전체적인 데이터베이스 설계 과정에 대해
위의 제시했던 각각의 단계에서 활용하는 것들을 정리해보자면 이와 같다!
3) Data Models의 정의
이전 글에서는 Database가 무엇인지 정의했었는데 핵심 키워드는
'조직'이 활용하는 '어플리케이션 시스템'에서 쓰이는 'persistent / interrelated / integrated한' '데이터 집합'이었다.
이번에는 database가 아닌, data model의 정의다!
[ 정의 ]
데이터 요소를 organize하고 / 현실 entities 또는 서로서로가 어떻게 연관되는지 표준화하는 / 추상적 모델
A data model is an abstract model that organizes elements of data and standardizes how they relate to one another and to properties of the real world entities - Wikipedia -
좀더 중요하게는 다음 4가지를 설명할 수 있는 도구의 집합으로서의 정의다.
A collection of tools for describing
- Data (structures)
- Data relationships
- Data semantics
- Consistency constraints
요거 정의 암기하라고 하셨당 ...
🤔 근데 저 4개 각각이 무엇인지 설명을 하셨던가 ... 또 내가 놓친 거? 교재에는 없는 것 같은데 ㅠㅠ
🔎 예시
- relational model
- object-based data models
- semistructured data model (ex. XML)
cf) insert 추가 / search 조회 / updatae 수정 / delete 삭제, 4가지 작업 외에 다른 작업을 할 수 있도록 하는 operators가 있는데, relational model이 operator를 갖고 있다
4) Relational DB Design & Implementation
위의 다양한 종류 중 우리는 Logical Design단계에서 Relational Model을 사용하고, Relational DBMS를 다룰 것!
우리가 DB에 접근할 때 항상 DBMS를 거쳐야하는데,
이때 DBMS에 DDL Interpreter가 있다. 이 인터프리터에 RDB implementation을 진행해야하는데, 이때 사용하는 것이 바로 SQL!
🔎 DDL에 대해
Data Definnition Language의 약자다 SQL은 DDL에 해당하고 뒤에서 database language의 3가지 종류에 대해서 더 자세히 다루겠다!
5) Database Language에 대해 알아보자
user 또는 application은 DBMS와 어떻게 상호작용할 수 있을까?
➡️ DB language를 통해 가능하다, 아래의 귀여운 그림을 보자.
이때 사용하는 DB Language를 크게 3가지로 나눌 수 있다
(1) DDL (2) DML (3) DCL
하나씩 차근차근 고고
✅ Database-Definition Language ( DDL )
[ 정의 ]
DDL로 표현된 definitions의 집합을 통해 우리는 database schema를 지정한다
DDL은 또한, 데이터의 추가적인 속성들을 지정하는데, 다음 3가지가 있다.
(1) Domain Constraints
타입 지정과 유사한데, attribute가 특정 도메인이 되도록 선언하여, value를 제한할 수 있다
(2) Integrity constraints
- Referential integrity: 하나의 relation에 있는 attribute의 값들이 다른 relation에 참조되기도 하는데, 이때 통합된 상태를 유지해야 한다, 가령 수정 시에 충돌이 발생해서는 안된다 ( = references constraint in SQL )
ex. dept_name value in any instructor tuple must apper in department relation
(3) Authorization
권한 부여를 다르게 할 수 있어야 하는데, 가령 read만 하거나 또는 insert까지, 수정하는 update까지, delete까지 등등
[ 예시 ]
create table instructor(
ID char(5) primary key,
name varchar(20),
dept_name varchar(20),
salary numeric(8,2))
✅ Database Manipulation Laguage ( DML )
[ 정의 ]
적절한 데이터 모델로 organized된 데이터 접근하고, 이를 조작하기 위한 언어다
query language라고도 알려져있다
여기서의 '조작'은 insert / delete / update / retrieval 4가지를 가리킨다
[ 종류 ]
크게 2가지가 있는데 (1) Procedural user specifies what data is required and how to get those data사용자가 직접 어떠한 데이터가 필요하고 그것을 어떻게 얻을 것인지 지정한다 (2) Declarative (nonprocedural)user specifies what data is required without specifying how to get those data
사용자가 직접 어떠한 데이터가 필요한 것인지 지정하지만 어떻게 얻을 것인지는 지정하지 않는다
cf) declarative DMLs are usually easier to learn and use than are procedural DMLS /
However, since a user does not have to specify how to get the data, the database system has to figure out an efficient means of accessing data.
( SQL이 가장 많이 쓰임 )
[ 예시 ]
select 캠퍼스, 학수번호, 분반 ...
from 개설과목
where 년도='2022' and 학기='2' and 캠퍼스='서울' and 대학='정보대학' and 학과='컴퓨터학과'
order by 학수번호;
6) Storage Management에 대해 간략하게 알아보자
Storage Management란 무엇일까?
[ 정의 ]
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
데이터베이스에 저장되어 있는 low level 데이터와 - 어플리케이션 프로그램과 - 시스템에 제출된 쿼리들 사이의 '인터페이스'를 제공해주는 프로그램 모듈
[ 역할 ]
file manager와 상호작용하는 것
데이터를 효율적으로 storing / retrieving / updating 하는 것
[ 관련 Issues ]
- Storage access
- File organization
- Indexing and hashing
( 인덱싱 메커니즘을 통해 효율성을 주로 높인다고 언급하셨다)
7) Storage Architecture에 대해 간략하게 알아보자
응용 프로그램 (program application)이 요구하면 ➡️ DBMS는 사용자가 원하는 프로그램이 무엇인지 확인하고 ➡️ 디스크에서 가져와서 DB버퍼에 저장한 후 ➡️ 데이터를 가져온 주소를 storage architecture에게 알려준다
아주 간략하게 들은 내용이라 틀릴 수도 있을 것 같다 . . . 추후에 세부 토픽으로 다시 다루면서 더 정확히 공부해야겠따 - 그때 다시 수정도 하고 . . .🥲
8) Storage는 어떻게 생겼을까
storage의 구성을 매우 간략하게 표현해주신 것인데, 이때의 핵심내용은 Databse Buffer와 Header에서 데이터가 이동하는 단위가 'block'이라는 점이었다.
물리적인 단위가 아닌 논리적 단위이므로, 실질적인 size는 직접 지정이 가능하다.
이때 고려하는 몇 가지 상황들이 있는데 다음과 같다,
💬상황1: 읽어들이는 속도가 빨라지려면 / 적은 block들을 읽으면 될 것이고 / 그러면 block크기를 크게하면 구현할 수 있을 것인데 효율적일까?
💬상황2
: 만약 한 명만 (낱개) 조회하는 경우가 많다면 / 매번 작은 block을 불러오는 것이 더 효율적일텐데 / block크기를 크게하면 오히려 성능이 떨어지는 것 아닐까?
위의 물음에 대한 것도 추후에 storage를 다루면서 직접 생각 해봐야겠다 🤔
9) Relational DBMS와 Query Processing
위의 그림과 같은 구조에서, DBMS는 SQL query로 들어온 request에 대해서
어디서 어떻게 데이터를 찾을지 절차를 생성하는데, 이때 사용되는 것이 relational operators다
Query Processing / Concurrent Access by Multiple Users (Uncontrolled sharing problems / whati f transaction or system failure? 등의 토픽은 아주 금방 ^_^ ... 자세히 다뤄야하므로 생략한다.
이렇게 다룰 예정인데 .. 벌써 Relational Model CH2했고 ... Query Processor CH12도 했고 ... Transcation Manager CH14를 나가고 있으니... 어우 빠르게 따라가자 - 배울 때 제대로 배우자!
'CS전공강의 > 데이터베이스' 카테고리의 다른 글
데이터베이스 Chapter2: Intro to Relational Model (3회차) (0) | 2023.04.11 |
---|---|
데이터베이스 Chapter15: Query Processing (N회차) (0) | 2023.04.06 |
데이터베이스 Chapter1: Introduction (1회차) (1) | 2023.03.20 |