How to model "reference data" in a document database model?

Member

by deron , in category: MySQL , 5 months ago

How to model "reference data" in a document database model?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , 5 months ago

@deron 

In a document database model, reference data can be modeled in a few different ways depending on the specific requirements of the application. Here are some common approaches:

  1. Embedding reference data: In this approach, the reference data is embedded directly within the documents that require it. This can be useful for reference data that is relatively small and does not change frequently. For example, if you have a collection of documents representing products, you could embed the product categories directly within each product document.
  2. Using references: In this approach, reference data is stored separately from the documents that reference it, and a reference to the data is included in the document. This can be useful for reference data that is large or frequently changing. For example, if you have a collection of documents representing orders, you could store customer information in a separate collection and include a reference to the customer in each order document.
  3. Hybrid approach: In some cases, a combination of embedding and referencing may be appropriate. For example, you could embed some reference data directly in documents and use references for other reference data that is larger or more volatile.


Ultimately, the best approach for modeling reference data in a document database will depend on the specific requirements of the application and the relationship between the data entities. It is important to carefully consider factors such as data size, frequency of change, and access patterns when designing the database model.

Related Threads:

How to reference a model in ember.js?
How to convert data between model and view in knockout.js?
How to model recursive data structures in graphql?
How to get model data on view in ember.js?
How to display nested related model data in ember.js?
How to send data from angular function to codeigniter view to model?