MongoDB Data Model

Hello everyone in this article we will learn about MongoDB Data Model. Let’s go. ACID Properties

MongoDB with .Net Core course link => MongoDB

Data Modeling

MongoDB is schema-less database or data has a flexible schema which means there is no need to defining a structure for the data before inserting a data. MongoDB Data Model is balancing the needs of the application, the performance characteristics of the database engine and the data retrieval patterns this all are the key challenge of the Data Modeling. Designing data models continuously deliberate the application usage of the data that is the processing of the data, queries, and updates as well as the inherent structure of the data itself. In MongoDB communal fields in a collection can contain different types of data, this helps in easy mapping.

When designing the schema in MongoDB, then consider the following point that helps you to design the schema in MongoDB:

1. Need for user requirements to design schema.

2. Need to do join on write operations, not on reading operations.

3. Which object do you want to use together should be combined into one document, and then they should be separated.

4. When you optimize your schema then you will get more frequent use cases and do complex aggregation in your schema.

MongoDB with .Net Core course link => MongoDB

Document Structure in MongoDB in details

The main resolution in designing data models for MongoDB applications rotates around the structure of documents and how the application signifies relationships between the data. MongoDB permits linked data to be embedded within a solo document. There are two ways to create relationships among the data in MongoDB:

1. Embedded Documents

2. References Documents

1. Embedded Documents

In MongoDB Embedded Documents capture relationships among data by storing related data in a single document structure. De-normalized embedded documents data models permit applications to retrieve and deploy related data in single database operations. MongoDB embedded documents are one collection will be embedded into another collection.

{
	_id: 1,
	name: “empname”
}
{
	_empID: 1,
	st: “548 Market st”,
	city: “San Francisco”,
	state: “CA”
}
{
	_empID: 1,
	st: “155 4th St”,
	city: “Juneau”
	state: “AK”
}

So embedding multiple addresses:

{
	_id: 1,
	Name: “empname”
	addresses: [
{
	st: “548 Market st”,
	city: “San Francisco”,
	state: state: “CA”
},
{
	st: “155 4th St”,
	city: “Juneau”
	state: “AK”
}
	]
}

MongoDB with .Net Core course link => https://www.udemy.com/mongodb-with-net-core-sagar-jaybhay/

2. References Documents

In MongoDB, Reference Documents is one of the most important tools that store the relationships between data by including references or links from one data document to another. In Reference document, a reference to the data in one collection will be used in linking the data among the collections. In such a case, the application can resolve these references to access the related data and these are normalized data models. One to many or many to many relationships between document should be used in reference relationships.

employee document

{
_id: <ObjectId1>,
ename: "John Bry"
}

edetails document

{
_id: <Objectd2>
employee_id: <ObjectId1>,
address: "San Jose, CA",
email: "john.bry12@ex.com"
}

deparment document

{
_id: <ObjectId3>,
employee_id: <ObjectId1>,
position: "senior developer",
deparment: "development"
}

Here is in the employee documents employee_id: <ObjectId1> is referenced to edetails document and department document. So here is very easy to store the relationships between data by including references.

MongoDB with .Net Core course link => https://www.udemy.com/mongodb-with-net-core-sagar-jaybhay/

sagar jaybhay

29 thoughts on “MongoDB Data Model

  1. Does your website have a contact page? I’m having trouble locating it but, I’d like to shoot you an email.
    I’ve got some suggestions for your blog you might be
    interested in hearing. Either way, great site and I look forward to seeing it improve over
    time.

  2. hey there and thank you for your info – I have definitely picked up anything new from right here.
    I did however expertise a few technical points using this web site, as I experienced to reload the website lots of times previous to I could get it to
    load correctly. I had been wondering if your hosting is OK?
    Not that I’m complaining, but sluggish loading instances times will very
    frequently affect your placement in google and
    could damage your high-quality score if ads and marketing with Adwords.
    Anyway I am adding this RSS to my e-mail and can look out for much more
    of your respective interesting content. Make sure you update this again very soon.

  3. This is really interesting, You’re a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking more of your
    wonderful post. Also, I have shared your site in my social networks!

  4. You can definitely see your expertise in the work you write. The world hopes for even more passionate writers such as you who are not afraid to mention how they believe. All the time go after your heart.

  5. Nice blog here! Also your web site loads up fast! What web host are you using?
    Can I get your affiliate link to your host? I wish my site loaded up as quickly as yours
    lol

  6. Hey just wanted to give you a quick heads up. The text in your content seem
    to be running off the screen in Chrome. I’m not sure if
    this is a formatting issue or something to do with internet browser compatibility
    but I thought I’d post to let you know. The layout
    look great though! Hope you get the issue fixed soon. Thanks

  7. Hello there, I found your site by way of Google even as looking for a related
    matter, your web site came up, it appears good.
    I’ve bookmarked it in my google bookmarks.
    Hello there, just became alert to your blog through Google, and located that it’s
    really informative. I’m gonna watch out for
    brussels. I will appreciate should you proceed this in future.
    Many other folks shall be benefited from your writing. Cheers!

  8. Wonderful article! That is the type of info that are supposed to be shared
    around the internet. Disgrace on Google for no longer positioning this submit upper!
    Come on over and talk over with my website . Thanks =)

  9. I’m not sure where you are getting your info, but good topic.
    I needs to spend some time learning much more or understanding
    more. Thanks for great info I was looking for this information for my mission.

  10. Please let me know if you’re looking for a author for your weblog.
    You have some really good articles and I believe I would be a good asset.
    If you ever want to take some of the load off, I’d really
    like to write some content for your blog in exchange for a link
    back to mine. Please send me an email if interested.
    Cheers!

Leave a Reply

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

Back to top