DEV Community

Discussion on: MongoDB Atlas Hackathon Help Thread

Collapse
 
kmukabe profile image
Kacha

Hi, I'd like some help understanding something in the realm data schema.
In what scenario would we use the relationships.json under the mongo-atlas schema in data-sources?
Why use this relationships file instead of just using embedding or adding a field with an objectId referencing another collection.

I hope I have asked that semi-coherently.

Collapse
 
joellord profile image
Joel Lord

Hi!

I think I would need more information before I can answer this question. Also, for more technical questions, you might want to try to search or post on our community forums (mongodb.com/community/forums/), you will normally get a quicker answer there.

Regarding the use of relationships or embedding fields, there is no one-size-fits-all solution. The general rule of thumbs is that if data is accessed together, it should be stored together. You can find out more information about data modeling in our docs (docs.mongodb.com/manual/core/data-...), or watch the talk “From Tables to Documents” (youtube.com/watch?v=j9N1dIVmV48).

I hope this helps.

Collapse
 
sumedhamehta profile image
Sumedha Mehta

Hi - I'm from the Realm Team! You're pretty much correct. The relationships defined in Realm let you easily reference fields in another collection to define your relationships instead of having to embed them in your documents. This is especially valuable when using services like Realm's Hosted GraphQL API or Realm Sync because we will automatically resolve the relationship for you without having to do a $lookup or another query.