Modeling items and categories

27 views
Skip to first unread message

Mircea Chirea

unread,
Dec 24, 2012, 9:56:11 AM12/24/12
to rav...@googlegroups.com
I have this problem on my mind. Suppose I have items and categories; items belong in categories. I most commonly need to access a list of all categories and a list of all items that belong in some categories. How should I model this into the documents?

Category
{
   string Id;
   string Name;
   string[] Items; 
   // etc.
}

Item
{
    string Id;
    string Name;
    // etc.
}

or this way

Category
{
   string Id;
   string Name;
   // etc.
}

Item
{
    string Id;
    string Name;
    string[] Categories;
    // etc.
}

As in, either a category has a list of items, or an item has a list of all categories. 

Itamar Syn-Hershko

unread,
Dec 24, 2012, 10:03:53 AM12/24/12
to rav...@googlegroups.com
Is the list of categories hierarchical? and when you need the list of all categories, do you need the rest of the data attached to it?

The second approach is going to be easier to work with. You can then get the list of all (used) categories directly from your index. If there is no hierarchy involved, you can maintain a collection of Category documents too. If there is hierarchy, you probably want to have one large document with all the categories - at least their IDs.

Mircea Chirea

unread,
Dec 24, 2012, 10:13:00 AM12/24/12
to rav...@googlegroups.com
The categories are stand-alone, basically groups. Typically when I need the categories I need the data about them too (like name and whatever), to display a list.
Reply all
Reply to author
Forward
0 new messages