Is mongoDB right for discussion forum

Hi Everyone,

I am a newbie developer. I created a simple CRUD app in the MERN stack. It’s a discussion forum. But most people suggest I should have used a relational database, as there are a lot of relations like the post, comments, sub comments. Any suggestion is it doable with MongoDB, or should I switch to SQL.

Thank you.

Everything is doable @Norma_Moras . Most people opt for relational databases as they see everything in a relational schema. You can obviously use Mongo, but your data model would look a bit different (having some stuff embedded) and some things still sort of relational. You can follow these for data modelling - https://docs.mongodb.com/manual/core/data-modeling-introduction/

2 Likes

I second what @shrey_batra said. MongoDB is a general purpose database and fits with most use cases. You can definitely build a discussion forum using MongoDB.

When people use the term non-relational to describe MongoDB, it doesn’t mean MongoDB doesn’t support relationships. MongoDB just handles them in a different way. In fact, many people consider the way MongoDB handles relationships to be more natural than the way a relational database handles them.

As you begin modeling your data, consider how you will be accessing (displaying or updating) your data. Data this accessed together should be stored together.

I hope you enjoy trying out MongoDB!

3 Likes

Hello @Norma_Moras

It is great that you want to utilize the strong features of MongoDB. In a first step it might help to change the wording. As mentioned from @shrey_batra and @Lauren_Schaefer MongoDB models relations as well as other databases. Maybe we should say tabular vs. natural approach to store data and with them relations.

To get the most out of an noSQL Setup, you need to change the way of thinking about schema design. Your first goal will no longer be to get the maximal normalized Schema, Denormalization is not bad, the requirement of your queries will drive your design. The story will start to think about a good schema design. In case you move the SQL normalized Data Model 1:1 to MongoDB you will not have much fun or benefit.

You can find further information on the Transitioning from Relational Databases to MongoDB in the linked blog post. Please note also the links at the bottom of this post, and the referenced migration guide .

Since you are new to MongoDB and noSQL I highly recommend to take some of great and free classes from the MongoDB Univerity:

Generally data modelling is a broad topic to discuss, this is due to many factors that may affect the design decision. One major factor is the application requirements, knowing how the application is going to interact with the database. With MongoDB flexible schema characteristic, developers can focus on the application design and let the database design conform for the benefit of the application. See also :

MongoDB

Building with Patterns: A Summary | MongoDB Blog

A summary of all the patterns we’ve looked at in this series

You may also can checkout:

This is just a sample which can get you started very well. In case this is going to be a mission critical project
I’d recommend getting Professional Advice to plan a deployment There are many considerations, and an experienced consultant can provide better advice with a more holistic understanding of your requirements. Some decisions affecting scalability (such as shard key selection) are more difficult to course correct once you have a significant amount of production data.

Hope this helps to start, while getting familiar and all time after, feel free to ask you questions here - we will try to help.

Michael

4 Likes

Thanks @shrey_batra. I kind of realized it’s doable because I am sure this community runs on mongoDB :grinning: and something similar I had in mind.

I have used a model tree structure with parent reference. will read that.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.