wyc
wyc

Reputation: 55273

Some questions about mongodb that have me puzzled

I just installed mongodb from Synaptic (Using ubuntu 11.10).

I'm following this tutorial: http://howtonode.org/express-mongodb to build a simple blog using node.js, express.js and mongodb.

I reached the part where you can actually store post in the mongodb. It worked for me but I'm not sure how. I didn't even start the mongodb (just installed it). The second thing that has me puzzled is: where is that data going?

Does anyone have any clue?

EDIT:

I think I found where is the data going:

var/lib/

Where are some files that are apparently written in binary code.

Upvotes: 0

Views: 165

Answers (1)

Mark Grey
Mark Grey

Reputation: 10257

MongoDB stores all your data as BSON within the directory you found. The internal Mongo processes handle the sharding of the data when necessary following your specific setup, accomodating you if you have setup distribution across several servers.

One of the most confusing things about coming over to Mongo from RDBMS is the nature of collections vs tables.

http://www.mongodb.org/display/DOCS/MongoDB%2C+CouchDB%2C+MySQL+Compare+Grid

Of Note: A Mongo collection does not need to have any schema designed, it is assumed that the client application will validate and enforce any particular scheme. The way the data comes in and is serialized is the way it will be saved in its BSON representation. It is entirely possible to have missing keys and and totally different docs in the same collection, which is why robust data checking in your app becomes so important.

Mongo collections also do not need to be saved. There isn't anything that approximates the CREATE TABLE syntax from MySQL, since there's no schema there isn't much such a command would have to describe. Your collection will be created with the first document inserted, and every document inserted will be given a unique hashed '_id' key (assuming you don't define this key in your objects using your own methodology.'

Here's a helpful resource with the basic commands. http://cheat.errtheblog.com/s/mongo

Mongo, and NoSQL in general, is a developer lead movement trying to bridge the gap between the object-oriented application layer and the persistency layer in an app, which would traditionally have been represented by an RDBMS. Developers just would much rather work within one paradigm, and OOP has become predominant especially in the web environment.

If you're coming over from LAMP and used PhpMyAdmin in the past, I really must suggest RockMongo. This tool makes it so much easier to observe and understand the actual structure of the BSON documents stored in your server.

http://code.google.com/p/rock-php/wiki/rock_mongo

Best of luck!

Upvotes: 2

Related Questions