Characteristics of mongodb database (including database field design for comments and likes)
The biggest difference between mongo and traditional databases is:
Traditional database: structured data, after determining the table structure, the content of each row must be in line with the table structure, that is to say-the number of columns, the type is the same.
Mongo document database: each document under the table can have its own unique structure (json objects can have their own unique properties and values)
Idea: if there is a movie, film review, film review reply, reply score
In the traditional database, at least 4 tables are needed, and the correlation degree is very complex.
In the document database, it can be completed through 1 document. It reflects the anti-normalization of the document database.
{
Fiim:' The Demi-Gods & Semi-Devils'
Comment: [
{
The movie style of content:' Wong Kar-wai
Reply: ['support', 'good']
}
]
}
Comment and like menu structure of traditional data tables:
(it will be very complicated)
Mongodb, on the other hand, is a tree structure, which is very clear:
(no matter how deep it is, it can be very clear.)