# MongoDB

## Document Store

Document store는 KV의 변형 혹은 또 다른 개념으로 WIki에서는&#x20;

* A **document-oriented database**, or **document store**, is a [computer program](https://en.wikipedia.org/wiki/Computer_program) designed for storing, retrieving and managing document-oriented information, also known as [semi-structured data](https://en.wikipedia.org/wiki/Semi-structured_model).

라고 한다.

semi-structured data의 대표적인 형식은 JSON이고 MongoDB의 주요 포맷이다.

KV와 다른 점은 Value가 보인다는 것이다. 이를 통해 Value의 검색이 가능하다.

## MongoDB 기초

* Document : 데이터의 단위 (저장단위)
* Collection : Document들을 저장하는 공간
* Database : collection의 집합

Database안에 collection, collection안에 Document로 표현하기도 한다.

이렇게 구성되어 있기 때문에 MongoDB는 Database를 먼저 접근하고, 그후에 collection을 접근하여 데이터를 접근할 수 있다. 즉, 계층적 관계를 가진다.

Instance 개념도 있는데 Replication / Sharding에서 다루겠다. --> [Replication](https://koonkim.gitbook.io/mongodb/2.0/undefined/replication) / [Sharding](https://koonkim.gitbook.io/mongodb/2.0/undefined/sharding)

### Document

형식: {key: value}

* e.g.) {\_id: 1, name: "john"}
* MongoDB은 type-sensitive and case-sensitive.
  * {"foo" : 3} / {"foo" : "3"}
  * {"foo" : 3} / {“Foo" : 3}
* Key-value pairs은 순서가 있음.
  * {"x" : 1, "y" : 2}와 {"y" : 2, "x" : 1}는 다름.

### Mongo Shell

* 사용자가 MongoDB에 접근하기 위해 사용하는 기본 client임 (interface).
* JavaScript 언어로 작성.

##

* Document-based Database vs Object-based Database
*

```
* 실습 환경 시작하기 section 또한 넣어야 할 듯 합니다.
```

```
* JSON 개념, Syntax
*
```

* MongoDB란 무엇인가
  * Database 개념, Schema 개념, Collection 개념,
    * 대표적인 예시 (쇼핑몰 혹은 SNS)
