02.10.2015 Views

The Little Mongo DB Schema Design Book

The Little Mongo DB Schema Design Book - Leanpub

The Little Mongo DB Schema Design Book - Leanpub

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Many-To-Many (N:M) 10<br />

Some example Author documents<br />

1 {<br />

2 _id: 1,<br />

3 name: "Peter Standford",<br />

4 books: [1, 2]<br />

5 }<br />

6<br />

7 {<br />

8 _id: 2,<br />

9 name: "Georg Peterson",<br />

10 books: [2]<br />

11 }<br />

Mirroring the Author document, for each <strong>Book</strong> we include the Author foreign<br />

Author field.<br />

keys under the<br />

Some example <strong>Book</strong> documents<br />

1 {<br />

2 _id: 1,<br />

3 title: "A tale of two people",<br />

4 categories: ["drama"],<br />

5 authors: [1, 2]<br />

6 }<br />

7<br />

8 {<br />

9 _id: 2,<br />

10 title: "A tale of two space ships",<br />

11 categories: ["scifi"],<br />

12 authors: [1]<br />

13 }<br />

Queries

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!