简体   繁体   English

Neo4J 用户画像数据建模

[英]Neo4J user profile data modeling

I need to design a data model, which stores user profile information.我需要设计一个数据模型,用于存储用户个人资料信息。 User node may contain name, address, telephone as attributes.用户节点可能包含姓名、地址、电话作为属性。 Amount of users is expected to be increased dramatically.预计用户数量将大幅增加。 At the same time, I want to store each users' skills and hobbies which are entered by the users themselves during the profile creation.同时,我想存储每个用户在个人资料创建过程中自己输入的技能和爱好。
One user can enter multiple skills and hobbies.一个用户可以输入多种技能和爱好。 Of course multiple users may share a certain hobby or a skill.当然,多个用户可能共享某种爱好或技能。

We also have a requirement to filter users by skill or hobby.我们还有一个需求,就是要根据技能或者爱好来过滤用户。 That is, if the hobby (Badminton) is given, we need to find all the users who like Badminton.也就是说,如果给定了爱好(羽毛球),我们需要找到所有喜欢羽毛球的用户。

  1. Would it make sense to create hobbies, skills as nodes?将兴趣爱好、技能作为节点创造有意义吗? My understanding is, this will increase the query performance but, amount of distinct hobbies, skills users happen to enter may increase the number of nodes in the database.我的理解是,这会提高查询性能,但是,用户碰巧输入的不同爱好、技能的数量可能会增加数据库中的节点数量。
  2. Would it be good to store skills and hobbies as attributes of user nodes?将技能和爱好存储为用户节点的属性是否很好? My understanding is, search by an attribute over all the user base would decrease the query performance.我的理解是,按属性搜索所有用户群会降低查询性能。

Please advise.请指教。 Thank you.谢谢你。

The answer is in your phrasing of the question.答案就在你对问题的措辞中。

  • Skills and hobbies are shared amongst users技能和爱好在用户之间共享
  • Find all users who like Badminton查找所有喜欢羽毛球的用户

This clearly indicates that skills/hobbies are entities, or nodes.这清楚地表明技能/爱好是实体或节点。 There's no need to prematurely optimise, and the number of nodes will increase but steady at some level (the number of skills and hobbies is not infinite).无需过早优化,节点数量会增加但稳定在一定水平(技能和爱好的数量不是无限的)。 Also, the performance of queries is unrelated to the total size of the graph, so it may not really matter that the size of the graph has grown- the performance will depend on the size of the subgraph touched.此外,查询的性能与图的总大小无关,因此图的大小增长可能并不重要——性能将取决于所涉及的子图的大小。 Unless you're looking at 10s or 100s of billions of nodes, it is pretty safe to add skills and hobbies as nodes, and not worry about performance at this stage.除非您正在查看数十亿个节点的数十个或数百个,否则将技能和爱好添加为节点是非常安全的,并且不必担心现阶段的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM