Reputation: 2187
I'm struggling to choose between MySQL and MongoDB. I'm creating a rating/review system on my products and I should be able to calculate overall rating by calculating the average of ratings. my design is like this:
table products_review
Assuming that I have a large (millions) dataset of products and in future large dataset of rating/reviews [for example something like Yelp], which database should I choose MongoDB or MySQL?
Upvotes: 1
Views: 469
Reputation: 2647
Is it realist that you will have milions of reviews, or you are just over exagerating?
In your case I would go for mySQL. What do you have there is close to a relational schema therefore I would go relational. If you think the data is too much, you can have a table for February reviews, another for March reviews and so on; you can also do the partitioning by product category or something else.
If you want to go mongoDB you do have to modify the schema and fully denormalize it. You must not be aware, but on mongoDB you do not have the join therefore, you will not be able to join that the products table, therefore you have to store the product name and description together with the rating (or don't you want to do something like a group by product name?). Hence, on mongoDB it would look something like this:
_id
productId
productName,
product description,
product category,
product
rating
comment
dateCreated
userId
username,
userGenger (male/female/unknow)
userAge
userRegisteredDate
In this particular use case, I don't see much benefit in use a database that is schema-less (mongodb), if your problem is scalability you can achieve it by purchasing better hardware (your site will be a success with millions of reviews, therefore you can afford it), or by performing proper data partitioning.
Upvotes: 1