[SOLVED] Better MongoDB structure for a social network


I am developing a social network and I want to store my data with MongoDB and I am faced with a problem how i can store.

Let me explain here is a document containing a users:

    "_id" : ObjectId("5bcc70df3766462078e0a942"),
    "name" : "FlaRize",
    "password" : "123456789"
    "description" : "A good man !"
    "friend" : [
           { "_id" : ObjectId("5bcc47a66a04301cac7e7c67"),
           "name" : "Steve",
           "password" : "azerty"
           "description" : "Nothing" },
           { "_id" : ObjectId("5bcb9d06681bbf3cc4b811b9"),
           "name" : "John",
           "password" : "999"
           "description" : "What is ur problem ?" }

My first question is, is it a good way to store my data ?

If Steve changes his name this will not change his name in the FlaRize document how to fix it?

I was told that ‘JOIN’ does not exist in NOSQL is this true ?

I am a beginner in mongoDB, thank you for giving me a maximum of info so that my database got an exelante structure


One of the first steps in figuring the database you want to use in an application, is to figure the data and the application. The data with its attributes, the size, etc., and the relationships between various entities – the one-one, one-to-many and many-to-many. Then the application functionality – the queries (crud operations), and the associated user interface. These are some things one can do as a process or informally. These are often called as data modeling, application design, etc.

The next part would be the tools, the database (e.g., MongoDB), the application platform, programming languages, etc.

These are things one has to work with to build an application. Most of these aspects one cannot avoid, they show up in one form or other at different stages of application building.

Given that social data has various relations, to users in particular, it lends better to a relational database over time. Even though a NoSQL solution like MongoDB can seem like a great way to retrieve lots of data quickly, the relational nature of users in a social network can cause lots of duplication to occur.

Such duplication lends itself to data becoming inconsistent and/or unreliable over time, or to queries becoming much more difficult to handle if the duplication is removed (since documents will likely need to point to other documents, which is not optimal for a NoSQL type of database).

As a result, MySQL would be the better recommendation because it will have the data reliability and relational tools necessary to handle the interactions and relationships among numerous users. You may also decide to use both MySQL and MongDB together to utilize the best features of each database.

Answered By – Zaheer UD Din Baber

Answer Checked By – Timothy Miller (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *