database design - food information graph modeling -
i've following information mongodb db want export neo4j graph:
"_id" : 1366, "fields" : { "title" : "beef steak", "keywords" : [ "beef", "steak" ], "categories" : { "category" : "meat", "subcategory" : null, "verified" : false, "predicted" : true }, "nutrients" : { "tag_name" : "fasat", "value" : 1.352, "unit" : "g", "title" : "saturated fatty acids" }, ...
i've been reading neo4j modelling examples i'm not sure model.
this i'm thinking:
nodes:
- food
- keyword
- category
- subcategory
- nutrient
relationships:
- food - rel_name -> keyword
- food - rel_name -> category
- food - rel_name -> subcategory
- category - rel_name -> subcategory
- food - has_nutrients -> nutrient
the "has_nutrients" relationship name contain "value" property indicate how of nutrient food has.
i thought 2,3 , 4 relationships have possibility perform different queries: - subcategories of category 'meat', - category , subcategory of food, -all foods 'pasta' category. maybe there's more simple way.
if can't think of better names relations,
food - [has_keyword] -> keyword food - [has_subcategory] -> subcategory subcategory - [belongs_to] -> category food - [has_nutrient] -> nutrient
for subcategory, typically direction child parent, that's more preference.
will need differentiate between category , subcategory? if category meat
, subcategory pork
, ever need link meat
? have connection pork
, imply meat
cut down on relationships.
({name='pork', type='subcategory'}) -[belongs_to]-> ({name='meat', type='category'}) ({name='pork chops', type='food'}) -[has_subcategory]-> ({name='pork', type='subcategory'})
this cut down on relationships, you'll able imply category subcategory.
aside above recommendations, rest looks graph oriented , looks solid design.
Comments
Post a Comment