Book Image

Meteor Design Patterns

By : Marcelo Reyna
Book Image

Meteor Design Patterns

By: Marcelo Reyna

Overview of this book

Table of Contents (13 chapters)

Database relationships


Our collections will always be related in one way or another to other collections in our database. This topic is going to examine the three different types of relationships you should be thinking about when you are designing your database.

The shape that our database will take ultimately defines what our publishers are going to look like. If your data is all mashed up in just one or two different collections, you will very quickly find yourself struggling to filter data. If your data is spread too far between collections, the code will become difficult to maintain in the long run. So what is the solution to this problem?

The solution to database relationships is to understand how the data is going to be used in the client, how often it is going to be modified, and how large the set can be.

Let's build out the rest of our collections to get a notion of what good relationships look like.

One to one

A one to one database relationship describes how one MongoDB document in a...