SQL vs NoSQL
| SQL | NoSQL |
|---|---|
| 규칙에 맞는 데이터 입력 | 자유로운 데이터 입력 |
| 테이블 간 JOIN 지원 | 컬렉션 간 JOIN 미지원 |
| 안전성, 일관성 | 확장성, 가용성 |
| 용어: 테이블, 로우, 컬럼 | 용어: 컬렉션, 다큐먼트, 필드 |
mongoDB 설치는 운영체제마다 다르다. MacOS, 리눅스, 윈도우 셋 다 설치해본 결과 MacOS의 경우가 설치와 실행이 편했으며, 윈도우가 가장 까다로웠다.
윈도우 운영체제에 mongod 를 설치하고 실행한 뒤, 새로운 CLI에서 mongos 를 실행하는 과정에서 몇 가지 오류가 생겼는데, 검색하니 비슷한 문제를 겪은 사람들의 많은 글이 있어서 도움을 얻을 수 있었다.
mongoDB 설치가 완료되면 mongod 로 mongo서버를 실행하고, 새로운 CLI를 열어 mogosh 를 입력하여 mongo shell을 실행한다.
# mongo 서버 실행
$ **mongod**
# mongo shell 실행
$ **mongosh**
Current Mongosh Log ID: 6450f81341e87002c619b106
Connecting to: mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.8.0
Using MongoDB: 6.0.5
Using Mongosh: 1.8.0
For mongosh info see: <https://docs.mongodb.com/mongodb-shell/>
------
The server generated these startup warnings when booting
2023-05-02T20:46:02.400+09:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
2023-05-02T20:46:02.401+09:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
------
...
# 아래 처럼 변한 것을 알 수 있다.
**test>**
test> use nodejs
switched to db nodejs
nodejs>
nodejs> show dbs
admin 132.00 KiB
config 92.00 KiB
local 72.00 KiB
nodejs> db
nodejs