I need a design suggestion for implementing a Index or Relation for an array. I am using latest Spring Data Neo4j for its implementation
I have a Node which has field of categories like below,
@NodeEntity
Class Product {
Set<Category> Categories;
}
public enum Category {
RTW,
SHOE,
DENIM,
OUTER_WEAR
}
Now, i need to find out the products which have X and Y category (for ex: RTW and SHOE).
What is the best way to achieve this?
Can i create index on array types? or Shall i create a new NodeEntity for Category and create necessary relationship between Product and Category?
Any help for this would be greatly appreciated. Thanks in advance.
You should use relationships because it’s the nature of a graph database.
Imagine that you want to display the number of products in each categories, the most popular categories based on the top selling products, user recommandations, etc… It’s easy to compute with transversal queries. You should use indexes to optimize, not to relate.
Take a look at gremlin’s video presentation, it’s really powerful : http://www.youtube.com/watch?v=5wpTtEBK4-E
Spring Data supports the Cypher and Gremlin query languages.
See here for more informations about modeling categories in graph database : http://blog.neo4j.org/2010/03/modeling-categories-in-graph-database.html