Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Couchbase Essentials

You're reading from  Couchbase Essentials

Product type Book
Published in Feb 2015
Publisher
ISBN-13 9781784394493
Pages 170 pages
Edition 1st Edition
Languages

Nested collections


So far, we've focused on pretty simple documents. In practice, however, you're more likely to work with complex JSON structures that mirror your application's object graph. For example, consider the common Customer class. In this case, you have a Customer object, which has a collection of Address objects, as demonstrated in the following C# snippet:

public class Customer
{
  public string FirstName { get; set; }
  public string LastName { get; set; }
  public IEnumerable<Address> Addresses { get; set; }
}

public class Address
{
  public string Street { get; set; }
  public string City { get; set; }
  public string Province { get; set; }
  public string State { get; set; }
  public string Country { get; set; }
  public string PostalCode { get; set; }
}

In a relational model, this object structure would translate into a one-to-many relationship between a Customers table and an Addresses table. By contrast, with document databases, you tend to store related object graphs...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}