图或关系数据库专门的递归 [英] Graph or Relational DB specifically recursion

查看:74
本文介绍了图或关系数据库专门的递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将为客户开发解决方案,该客户的基本实体是会员,而会员可以与其他会员建立不同的多种社会关系.例如,假设我们有四种类型的成员:医生,专家,护士和患者.因此,一位或多位医生可以咨询一位或多位专家,一位或多位医生可以治疗一位或多位患者.一名或多名医生负责一名或多名护士.因此,如果我要使用关系数据库,则高度递归是必要的(因为所有实体都必须是成员).而在Graph数据模型中不需要递归.

I am about to develop a solution for a customer where the basic entity is a member and members can have different multiple social relationships with other members. For instance Lets say we have four types of members Doctors, Specialist, Nurses and Patients. So one or more Doctors can consult one or more Specialists, One or more Doctors can treat one or more Patients. One or more Doctor is in Charge of one or more Nurses. So if I were to use a Relational DB a high degree of recursion would be necessary (as All entities must be members). Whereas recursion is not necessary in a Graph data model.

那么可以肯定地说,将Graph数据库用于成员可能具有不同或重叠角色的社交类型应用程序是否更好.

Is it then safe to say it is better to use a Graph database for a social type application where members may have different or overlapping roles.

推荐答案

图形数据库将很好地为这些类型的关系建模.您可以通过几种方法对其进行建模.您可以认为一个顶点是一个成员,它的成员到其他成员之间的边沿不同,代表关系的类型:

A graph database would be good at modelling these kinds of relationships. There's a few ways that you might model it. You could think of a vertex as being a Member with different edges from Member to other Members representing the types of relationships:

  • 成员-咨询->成员(医师到专科医生)
  • 成员--reportsTo->成员(护士的护士)
  • 成员-诊断->成员(医师对患者)

很明显,会员可以具有任意多个边缘类型(例如,与专家进行多次协商").在更复杂的模型中,您可能还会将Member视为某人的身份",因此您的模型如下所示:

Obviously a Member may have as many of any edge type (e.g. multiple "consults" with specialists). In a more complex model, you might also see a Member as being an "identity" for a person such that your model looks like:

  • 成员--actsAsPhysician->医师
  • 成员--actsAsSpecialist->专家
  • 医师-咨询->专家

在这种方法中,咨询"边只能存在于医师"顶点上,因此,您可以对哪些顶点类型可以具有什么样的边提供一些约束.

In this approach the "consults" edge can only exist on a "Physician" vertex, thus you provide some constraints as to what vertex types can be expected to have what kind of edges.

图为您提供了很大的灵活性,使其能够对现实世界中存在的数据进行建模,因为您实际上只是在描述实体及其之间的关系.我鼓励您查看 http://tinkerpop.com ,以获得有助于构建图形应用程序的一系列工具与您选择的图形数据库无关.

Graphs provide you a lot of flexibility in being able to model data such as it exists in the real-world as you are really just describing entities and the relationships among them. I'd encourage you to look at http://tinkerpop.com for a collection of tools that are helpful in building graph applications independent of the graph database you choose.

这篇关于图或关系数据库专门的递归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆