Embedding vs Refrenecing Data modeling approaches (Meghna Shinde)
TITLE : Embedding vs Refrenecing Data modeling approaches
INTRODUCTION
1: EMBEDDING = Stores data inside database
Embedding means placing related data directly inside the main document
⟤ When to use Embedding:
- When the related data is small and always used together
- For faster reads , since everything is in one place
- Example: Comments that are only shown with their blog post
2: REFERENCING = Stores data separately and link with ID's
Referencing means keeping related data in separate documents or collection, and connecting them using a common ID
⟤ When to use Referencing:
- When the related data is large, or frequently updated
- When data needs to be shared or reused
- Better for write heavy applications
TOOLS USED
MongoDB + MongoDB Compass
STEPS
- Open mongodb compass
- Create a database name example blogs
- Then create a collection name students
- Then enter the data into it using javascript,python ,or csv file
- Then again create a collection in the created database and insert the documents
- The embedding is done by placing the data inside the collection
- Then referencing is done by keeping the related data or documents organized and seprated
SUMMARY
The database is created in the mongodb compass and then the documents is inserted with the help of JSON or CSV file in the collection here embedding is done after that the data is organized in a good format here while organizing the data referencing is done
CONCLUSION
Embedding and referencing are two distinct approaches for managing related data, each with its own strengths and weaknesses. Embedding stores related data within a single document, while referencing uses identifiers to link separate documents. The best choice depends on factors like data access patterns, update frequency, and scalability requirements.
Helpfull blog
ReplyDeleteUsefull information
ReplyDeleteHelpful 👍
ReplyDeleteValueable
ReplyDeleteNice blog
ReplyDeleteUseful
ReplyDeletenice blog:)
ReplyDeleteExcellent 👌🏻
ReplyDeleteGreat post!
ReplyDeleteIncredible 👍🏻
ReplyDeleteHelpful 👍
ReplyDelete