Overview: In this section we'll see how
to start the Mongo DB engine, create database and basic CRUD operations
Starting Mongo DB
The two "most
important" applications are the mongo and mongod
applications.
The mongo application allows you
to use the database shell; this shell enables you to
accomplish
practically anything you'd want to do with MongoDB.
The mongod application starts the
service or daemon, as it's also called. There are also many flags you can set
when launching the MongoDB applications
executing the
mongod.exe from command prompt (Tips: Set the path in the environment
variables, so that you don't need to navigate to the actual folders)
There is a nice
comparison between Mongo DB and Oracle & My SQL in Mongo web site, a
helpful tip for newbies http://www.mongodb.org/display/DOCS/SQL+to+Mongo+Mapping+Chart
I've listed down a
key comparison between Mongo and other RDBMS
RDBMS
|
MONGO
|
Database
|
Database
|
Tables
|
Collections
|
Rows
|
Documents
|
In MongoDB, a
document is an item that contains the actual data, comparable to a row in SQL.
Important Note:
Mongo DB is case-sensitive
$ symbol is reserved for many built-in
functions
DATATYPES
String
|
Text values
|
Integer (32b and
64b)
|
Numerical values
|
Boolean
|
True or False
|
Double
|
Floating point
values
|
Min/Max
|
Comparing values
against Lowest and Highest BSON
elements
|
Arrays
|
Store array of
values
|
Timestamp
|
Store Time stamp
|
Object
|
Object type values
|
Null
|
Null values
|
Date*
|
Current Date
|
ObjectID*
|
Documents unique
ID
|
Binary Data*
|
Binary format data
|
JavaScript Code*
|
Store JavaScript
code
|
Regex*
|
Regular Expression
type
|
*denotes
BSON data types
CRUD Operations
Before i dive in to
CRUD operation with example, there are few important commands to do the basic
operations like Listing all databases, connecteing to database, listing
all documents, etc...
One interesting
command to remember is : 'Show' this is almost a replacement for 'Select
* from'
use
|
To switch to a db
library
|
show dbs
|
To view available
databases and collections
|
show collections
|
To view all
available collections for your current database
|
system.indexes
|
All the indexed are stored here
|
db.
|
Renaming a
Collection
|
db.
|
Getting distinct
data collection
|
No comments:
Post a Comment