MongoDB tutorial

MongoDB is a cross-platform, document oriented database that provides.

Database
Database is a physical container for collections. (DB는 collection을 담는 물리적 container이다.)
Each database gets its own set of files on the file system. A single MongoDB server typically has multiple databases. (각 DB는 itw own files을 얻는다. 단일 DB server는 여러개의 db를 갖게 된다)

Collection
Collection is a group of MongoDB documents. It is the equivalent of an RDBMS table. (Collection이란 MongoDB documents의 모음으로, RDBMS 의 table와 같은 것이다. ) 
 A collection exists within a single database. Collections do not enforce a schema. Documents within a collection can have different fields. Typically, all documents in a collection are of similar or related purpose. (하나의 collection = 하나의 DB. 하나의 collection 안에 있는 documents들은 서로 다른 field를 가진다. 이 모든 documents들은 비슷한 목적을 갖고 모여있다.)

Document
A document is a set of key-value pairs. (키-값 : map와 비슷하다?)
Documents have dynamic schema. Dynamic schema means that documents in the same collection do not need to have the same set of fields or structure, and common fields in a collection's documents may hold different types of data. (같은 collection 안에 있는 서로 다른 documents는 같은 DB구조를 유지할 필요가 없다. 또한 여러 documents들이 갖고 있는 공통된 field는 서로 다른 타입의 data를 갖고 있을 수 있다.)

RDBMSMongoDB
DatabaseDatabase
TableCollection
Tuple/RowDocument
columnField
Table JoinEmbedded Documents
Primary KeyPrimary Key (Default key _id provided by mongodb itself)
Database Server and Client
Mysqld/Oraclemongod
mysql/sqlplusmongo



Below is basic document structure. _id is hexadecimal number which is unique, and it's given automatically by MongoDB.


{
   _id: ObjectId(7df78ad8902c)
   title: 'MongoDB Overview', 
   description: 'MongoDB is no sql database',
   by: 'tutorials point',
   url: 'http://www.tutorialspoint.com',
   tags: ['mongodb', 'database', 'NoSQL'],
   likes: 100, 
   comments: [ 
      {
         user:'user1',
         message: 'My first comment',
         dateCreated: new Date(2011,1,20,2,15),
         like: 0 
      },
      {
         user:'user2',
         message: 'My second comments',
         dateCreated: new Date(2011,1,25,7,45),
         like: 5
      }
   ]

Relationships in MongoDB represent how various documents are logically related to each other. Relationships can be modeled via Embedded and Referenced approaches. Such relationships can be either 1:1, 1: N, N: 1 or N: N.  (Relationship 이란 documents들의 관계로, 1:1에서 다:다 까지 가능.)










Previous
Next Post »