Ok, I understand NoSQL databases are all about not using joints for their querying, but I simply can't wrap my head around some concepts. For example, lets say I want to have blog that will have multiple authors and articles that would be related to the authors, in MySQL I'd create table of users:
Users: id, name, surname, nickname, password...
Articles: id, user_id, title, content, date, tags...
But I'm not sure what would be the best way to set this up properly in MongoDB. Should I just say:
db.users.insert({
id:1,
name: "Author name",
...
articles: [{id:1, article:1, title:"Article title", ...}, {...}, ...]
});
Should I maybe do something like this?:
db.articles.insert(
{
...
article related stuff
...
user related stuff: {...}
);
Or maybe I should have separate database for articles and separate database for users?
If I have homepage that will display 10 most recent article excerpts along with author data, in MySQL, I'd just do a joint query to get author nick name from authors table, and title and excerpt from article table.
I'm really unsure how to represent my data in an document oriented database. Maybe I should store author data in each of his articles, but than If author changes his info all articles from that author needs to be updated.
It seems logical to me to create separate documents in MongoDB. One that will hold all author documents, and one that will hold all article documents, but that again would require some kind of joint operation that will get first 10 articles and get the author data from authors document.
Ok, maybe some map reduce operation, but I'm not sure how it would look.
I'd appreciate your thoughts, and advices on this problem of mine. Thanks!
[EDIT] Also, if I hold all articles in one document there's limit of 16 mb per one document if I'm correct, and that would be a problem in case of large website, so I guess there should be separate database for articles?