0

I am planning to re-build my database using mongoDB instead of a RDBMS.

I currently have some tables in my database. I am just wondering.. each table will be a mongodb document?

I mean, will table with user/email/password be just something like this?

{list_of_users: [{email: "value", pass: "value", user: "value"}, {...}, ...]}

And i am also wondering... these documents which includes arrays have limit of storage or can be used just like common tables in database, and i can add as many "rows" (elements of an array) as i want?

Thank in advance !!

1
  • No, it's very unlikely that you'd have a document represent a table. More likely, a document would represent a row. But, note there are no joins in MongoDd, which makes many efforts to translate a traditional RDBMS app, difficult. Commented Jan 17, 2014 at 11:45

1 Answer 1

1

First off some good reference for you to look through:

Now to basically sum up in relation to your question.

You will normally design MongoDB collections around entities (think of an ERD diagram in UML). This means that it is actually quite similar to designing a relational model except you will nested certain detail tables that would normally be separatede out in SQLs flat structure.

A good example is a "many-many" relationship. Normally this would be split out into a normalised table but in the case of MongoDB it would be nested within the parent relation document.

As an example: "A user can manage many videos and a video can be managed by many users"

Such a relationship would normally be designed by embedding a managers field into the video document containing a list of user IDs.

and i can add as many "rows" (elements of an array) as i want?

No, the maximum size of a BSON document is 16MB.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you but i didn't get.. How can i store for example all my users if maximum size for a bson document is 16mb?
@Morrisda one user per document
Thank you guy but i can't still understand one thing. Assuming that in user table i want to put posts by each users (i ain't do this, but it is just an example) i'll have a document like: {username: "value", pass: "value", "email": value, posts: {..}} So each time that user publish a post i'll put there. but what when this document reach 16mb? This is what i am wondering!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.