Chapter 8. Relations among documents

 

This chapter covers

  • Objects and arrays of objects
  • Nested mapping, queries, and filters
  • Parent mapping, has_parent, and has_child queries and filters
  • Denormalization techniques

Some data is inherently relational. For example, with the get-together site we’ve used throughout the book, there are groups of people with the same interests and events organized by those groups. How might you search for groups that host events about a certain topic?

If your data is flat structured, then you might as well skip this chapter and move on to scaling out, which will be discussed in chapter 9. This is typically the case for logs, where you have independent fields, such as timestamp, severity, and message. If, on the other hand, you have related entities in your data, such as blog posts and comments, users and products, and so on, then by now you may wonder how you should best represent those relationships in your documents so you can run queries and aggregations across those relationships.

8.1. Overview of options for defining relationships among documents

8.2. Having objects as field values

8.3. Nested type: connecting nested documents

8.4. Parent-child relationships: connecting separate documents

8.5. Denormalizing: using redundant data connections

8.6. Application-side joins

8.7. Summary

sitemap