WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

MongoDB - Data Modelling


MongoDB - Data Modelling Let’s now apprehend the structural aspects of MongoDB

Data in MongoDB has a flexible schema.Files in the same series

Some issues while designing Schema in MongoDB

  • Design your schema in step with consumer necessities.

  • Combine items into one record if you may use them collectively. Otherwise separate them (however make sure there must now not be need of joins).

  • Duplicate the facts (however constrained) due to the fact disk space is cheap as examine to compute time.

  • Do joins at the same time as write, now not on study.

  • Optimize your schema for maximum common use cases.

  • Do complicated aggregation in the schema.

Example

Suppose a consumer desires a database layout for his blog/website and see the variations between RDBMS and MongoDB schema design.
  • Every publish has the particular identify, description and CONTENT.
  • Every publish can have one or extra CONTENT.
  • Every put up has the call of its writer and overall wide variety of dislikes.
  • Every submit has remarks given by means of users in conjunction with their call, message, statistics-time and dislikes.
  • On each put up, there may be 0 or extra feedback.
In RDBMS schema, layout for above requirements could have minimal 3 tables. While in MongoDB schema, layout can have one series publish and the following structure

    _id: POST_ID
    identify: TITLE_OF_POST,
    description: POST_DESCRIPTION,
    through: POST_BY,
    url: URL_OF_POST,
    CONTENTs: [CONTENT1, CONTENT2, CONTENT3],
    dislikes: TOTAL_DISLIKE,
    feedback: [
        
            user:'COMMENT_BY',
            message: TEXT,
            dateCreated: DATE_TIME,
            dislike: DISLIKE
        ,
        
            user:'COMMENT_BY',
            message: TEXT,
            dateCreated: DATE_TIME,
            dislike: DISLIKE
        
    ]






Welookups is optimized for learning.Copy right 2018 - 2019 kumar aditya singh .
All Right Reserved and you agree to have read and accepted our term and condition.
All Rights Reserved.