> For the complete documentation index, see [llms.txt](https://koseungbin.gitbook.io/wiki/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koseungbin.gitbook.io/wiki/books/undefined-1/dbms/undefined.md).

# 관계형 데이터베이스의 계층

## 데이터베이스는 계층으로 나뉘어 있다

데이터베이스를 사용한다는 것은 DBMS에 저장된 테이블을 SQL을 사용해서 조작하는 것이다.&#x20;

데이터베이스 내부의 테이블은 1개가 아닌 몇 개의 그룹으로 나뉘어서 관리되고 있다. PC에서 파일을 분류하기 위해 사용하는 '폴더(디렉토리)'에 해당하는 것이 데이터베이스에도 있다고 생각하면 된다.

## 폴더에 해당하는 스키마

데이터베이스에서 폴더에 해당하는 것이 **'스키마(Schema)'** 이다. 테이블은 몇 개의 스키마 속에 저장되는 형식을 취하고 있다. 사용자가 스키마 자유롭게 만들 수 있어서 용도 별로 나누거나, 보여주고 싶지 않은 사용자에게는 접근할 수 없도록 제한을 거는 스키마를 만드는 등의 권한 관리를 수행할 수 있다.

스키마의 상위에는 또 하나의 계층으로 '데이터베이스(Database)' 가 있다.

## 최상위에 있는 인스턴스

마지막으로 데이터베이스보다 한 층 더 위에 **'인스턴스(Instance)'** 란 개념이 있다. 이것은 물리적 개념으로 DBMS가 동작할 때의 단위이다. 그래서 OS 입장에서는 '프로세스' 라고도 부른다.

1개의 인스턴스 아래에는 복수 개의 데이터베이스가 존재할 수 있고, 1개의 데이터베이스 아래에는 복수의 스키마가 존재할 수 있으며, 1개의 스키마 아래에는 복수 개의 테이블이 존재하는 것이 가능한 트리 구조이다.

![](/files/-LbYKy9xZYoUXhMKgqHJ)

{% hint style="info" %}
4계층에 있는 것

최하위 계층인 **4계층**에는 테이블 이외의 **'인덱스(Index)'**, **'저장 프로시저(Stored Procdure)'** 등이 있다. 이런 데이터베이스에 보존된 것들을 총칭해서 '오브젝트(Object)' 라고 한다. 또한, 인스턴스도 복수로 존재할 수 있으며, '멀티 인스턴스' 라는 구성을 사용한다.
{% endhint %}

## 계층 구조가 이해하기 어려운 이유

현재까지 설명한 계층 구조는 원칙이고, 현실에서는 구현되는 것마다 조금씩 차이가 있다.&#x20;

계층의 원칙을 충실히 지키는 DBMS는 PostgreSQL, SQL Server, DB2 이고, 스키마와 데이터베이스 한 계층을 생략한 것이 MySQL 과 Oracle 이다.

## MySQL과 Oracle의 계층 구조

MySQL은 데이터베이스와 스키마를 동일한 것으로 간주해서 계층 차이를 두지 않으므로 데이터베이스와 스키마는 MySQL에서는 동의어이다. 따라서 MySQL은 3계층 구조이다.

![](/files/-LbYNAIX-xjNdN2SWQWz)

Oracle은 조금 달라서 4계층 구조로 되어 있지만, '인스턴스 아래에 데이터베이스를 한 개만 만들 수 있다' 는 독자적 제약이 있다. 따라서, 실질적으로 데이터베이스를 의식하지 않고 3계층 구조로 바뀌지도 않는다. 실제 Oracle을 사용해 보면, 데이터베이스 계층이 얇아서 마치 인스턴스 바로 아래에 스키마 층이 존재하는 듯한 인상을 받는다.

![](/files/-LbYOAoExoluLeZozSwb)

정리해보면 데이터베이스 계층 구조는 두 가지로 나뉜다.

* **3계층** Oracle, MySQL
* **4계층** SQL Server, DB2, PostgreSQL

## 3계층과 4계층 어느 쪽이 맞는가&#x20;

3계층과 4계층 중 어느 쪽이 맞는지 묻는다면 답은 4계층이다. 이는 ANSI 가 정한 표준 SQL 로 결정되었기 때문이다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://koseungbin.gitbook.io/wiki/books/undefined-1/dbms/undefined.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
