We have a relative large scale application that uses relational DB (MSSQL). After a lot of reading I've decided that I want to examine using MongoDB and not MSSQL, mainly because performance and scale issues.
I read and study about Mongo and couldn't figure out the answer for the following questions:
- Should we do it? Bare in mind we have the time to invest, the only question is "is it good for us?"
- How to model our data?
My problem with mongo is that we have a lot of one to many relations in our DB. After reading this great post (and the second part as well), I've realized a good practice will be to divide the decision into 3 scenarios:
- 1 to few
- 1 to many
- 1 to squillions.
In our db, most of the times we use one-to-many, but the problem is that most of the times it's the same "one".
For example, we have users and transactions tables. Each user can perform a transaction, so basically what I should do is to model the user as following:
{ "name": "John", ..., "Transactions" : [ObjectId("..."), ObjectId("..."),...] }
So far it's fine, the problem is that we have a lot more than just transactions, for example we could have: posts, requests and many more features like transactions, and then, my users collection becomes huge (more then 25 "columns"). And also when I want to retrieve a data set I have to do several queries unlike MSSQL in which I'm just using Join statement.
Another issue is that I'll have to save a lot of extra data, for example, for each transaction I have to save the terminal ID, and in the report I'll have to show the terminal name, in that case (as for my understanding) I have 2 choices, the one is to do 2 queries and the other is to save the terminal name as well. In relational DB this is a simple join.
So maybe for schemes like ours, Mongo(or any other document based DB) is not the best choice?
- I know those are a newbie questions :)
- We use c# for our server side (ASP.Net Web API)
Thanks in advance!