Blog

Mongo DB

January 9, 2014

Mongo DB

Mongo DB

Node.js 를 써야하는데, MySQL은 싫고 Oracle 은 돈내야 하며 MariaDB는 그놈이 그놈이라 Mongo를 고름 JSON 매핑이 잘 되서 고른 이유도 있음

살펴보니 http://www.mongodb.org/ 사이트 타이틀이 Agile and Scalable 이다. 잡다한 특징으로는

  • Document-Oriented Storage
  • Full Index Support
  • Auto-Sharding
  • Grid FS
  • Map/Reduce

등이 있다는데 나한테 와 닿는건 단 하나도 없다 -_-; 그래서 다른 문서를 찾아 보았으니 MongoDB에 대한 한탄 이 되시겠다. 240GB 정도의 데이터를 이용해 6개월 정도 Mongo 를 다뤄 보신 분이 이야기인데

좋은 부분은 Schemaless 등 자유롭다는 거고. 단점은 성능이 좀 안나오나 보다. 나는 조그만 사이트를 사용할거고 유연한 스키마를 원하므로 패스!

NoSQL 의 특징이나 CAP 이론, Document / Key and Value 등의 구조는 마이크로소프트웨어 – NOSQL 를 참고하자.

Mgmt Tools

  1. A Roundup of MongoDB Management Tools
  2. Admin UIs

Tutorial

  1. Slide Share : 몽고DB 소개
  2. MongoDB Shell
  3. Slide Share : 몽고DB의 역습

Installation

설치 후 실행이 안됌. Config 나 Data 폴더 설정인 듯

.\bin\mongod --dbpath mongodb-win32-x86_64-2.4.3/data 로 데몬 실행 후 mongo 커맨드로 클라이언트 실행시켜야 됌. http://localhost:28017/ 로 들어가면 Web Console 이 뜬다.

Path 추가 해도 편하다.

Getting Started

일단 용어 정의부터 하자

RDBMS MongoDB
Table Collection
Record Document
Column Filed
Type SQL Mongo
insert insert into users (“name”,”city”) values(“terry”,”seoul”) db.users.insert({_id:”terry”,city:”seoul”})
select select * from users where id=”terry” db.users.find({_id:”terry”})
update update users set city=”busan” where _id=”terry” db.users.update( {_id:”terry”}, {$set :{ city:”Busan” } } )
delete delete from users where _id=”terry” db.users.remove({_id:”terry”})

데이터 형태가 JSON 이고 PK 컬럼(Mongo에선 Field) 이름이 _id 인 것만 빼면 별 다른게 없다.

이것 진행중. 나머지는 내일 http://jabsiri.tistory.com/78

References

  1. http://bcho.tistory.com/742
Array