Book Image

Couchbase Essentials

Book Image

Couchbase Essentials

Overview of this book

Table of Contents (15 chapters)
Couchbase Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Document design


Document design is a more involved activity than key design. There are far more variables to consider when creating a document's schema. Some of these factors are specific to Couchbase. Others are generally applicable to document databases.

Denormalization

When designing a relational system, you typically start with a highly denormalized logical view of your entities. That view is then normalized into a physical model where the data is spread across several tables in an effort to minimize any possible data redundancy.

Similarly, you'll likely start your document design by creating a denormalized, logical model. With this approach, your design first considers the most complete document that your domain demands. For example, if you were building a blog, you might start with a blog document with nested posts. Within each post, there would be nested comments and tags:

{
  "type": "blog",
  "title": "John Zablocki'sdllHell.net",
  "author": {
    "name": "john.zablocki",
    "email...