tags:

views:

97

answers:

1

Hi guys, I'm really trying hard to understand this new concept after working so long with relational databases...

Can anyone explain how I should go about storing say, a category hierarchy?

in a relational DB, I'd have:

Category:
  CategoryId
  ParentCategoryId
  Name

or something of that nature..

+2  A: 

You can start with the same approach as you would with relational databases: creating a separate document for each category, and keeping a reference to the parent category.

If you'd like to query a whole subtree or breadcrumbs with a single query, you should maintain an array field that contains all the ancestor keys. Then you can create a view that walks through the ancestors and emits [ancestor_key, doc] for querying a subtree. To get the breadcrumbs data for a category make a bulk query on the ancestor IDs.

Leventix
Hmm ok I see.. I was reading in to NOSQL and one of the things i got from it was a document should be totally self contained, and I took that as not refer to any other documents etc.. Thanks for your help
Michael Baldry