图数据库中有模式吗?

时间:2022-12-16 13:04:48

Is there such a thing as a schema in a graph database? For example, can you specify which types of node can have relationships with which other types of node?

图数据库中有模式吗?例如,能否指定哪些类型的节点可以与哪些类型的节点具有关系?

What does such a schema look like?

这种模式是什么样子的?

3 个解决方案

#1


4  

Yes. Schemas useful in selecting vertex labels, which are part both Neo4J 2 and Tinkerpop 3. I think writing down the schema helps clarify how the graph should be used, although most databases don't support validations against a schema.

是的。模式在选择顶点标签时很有用,它们既是Neo4J 2的一部分,也是Tinkerpop 3的一部分。我认为写下模式有助于阐明应该如何使用图表,尽管大多数数据库不支持对模式的验证。

I have a longer post on how to draw the schema as a graph. http://lambdazen.blogspot.com/2014/01/do-property-graphs-have-schemas.html

我有一个更长的帖子,关于如何把模式画成图表。http://lambdazen.blogspot.com/2014/01/do-property-graphs-have-schemas.html

#2


3  

A graph database will always have a rudimentary schema consisting of (at least) Vertex and Edge objects, where an Edge can contain data about a particular relationship. The degree to which you can add to this schema varies widely across implementations. You may be able to customize the schema by inheriting from Edge and/or Vertex objects,for instance.

图形数据库总是有一个基本的模式,包括(至少)顶点和边缘对象,其中边缘可以包含关于特定关系的数据。您可以添加到这个模式的程度在不同的实现中有很大的不同。例如,您可以通过继承Edge和/或顶点对象来定制模式。

If the graph database uses an underlying RDBMS or ODBMS then you may have access to more powerful schema creation and manipulation capabilities.

如果图形数据库使用底层RDBMS或ODBMS,那么您可以访问更强大的模式创建和操作功能。

#3


2  

Graph databases differ a lot in this area, just like das_weezul says. In the general case I think graph databases which are closer to object databases (OODB) also have built-in schema support. One nice thing about graph databases is that they're very well suited for mixing data and metadata. So a common approach for both dealing with schema support and security is to store this kind of metadata in a (sometimes hidden) part of the very same graph.

就像das_weezul说的那样,图形数据库在这方面有很大的不同。在一般情况下,我认为更接近对象数据库(OODB)的图形数据库也具有内置模式支持。图数据库的一个优点是它们非常适合混合数据和元数据。因此,处理模式支持和安全性的一种常见方法是将这种元数据存储在同一图的(有时是隐藏的)部分中。

When it comes to Neo4j - where I'm on the team - there's currently at least two approaches in use for defining schemas:

当涉及到Neo4j(我所在的团队)时,目前至少有两种用于定义模式的方法:

  • Defining the schema in annotations, for example using Spring Data Graph (docs).
  • 在注释中定义模式,例如使用Spring数据图(docs)。
  • Using a meta-model layer on top of the database.
  • 使用数据库之上的元模型层。

You'll find some more reading on this topic over at myNoSQL.

您将在myNoSQL找到更多关于这个主题的阅读。

#1


4  

Yes. Schemas useful in selecting vertex labels, which are part both Neo4J 2 and Tinkerpop 3. I think writing down the schema helps clarify how the graph should be used, although most databases don't support validations against a schema.

是的。模式在选择顶点标签时很有用,它们既是Neo4J 2的一部分,也是Tinkerpop 3的一部分。我认为写下模式有助于阐明应该如何使用图表,尽管大多数数据库不支持对模式的验证。

I have a longer post on how to draw the schema as a graph. http://lambdazen.blogspot.com/2014/01/do-property-graphs-have-schemas.html

我有一个更长的帖子,关于如何把模式画成图表。http://lambdazen.blogspot.com/2014/01/do-property-graphs-have-schemas.html

#2


3  

A graph database will always have a rudimentary schema consisting of (at least) Vertex and Edge objects, where an Edge can contain data about a particular relationship. The degree to which you can add to this schema varies widely across implementations. You may be able to customize the schema by inheriting from Edge and/or Vertex objects,for instance.

图形数据库总是有一个基本的模式,包括(至少)顶点和边缘对象,其中边缘可以包含关于特定关系的数据。您可以添加到这个模式的程度在不同的实现中有很大的不同。例如,您可以通过继承Edge和/或顶点对象来定制模式。

If the graph database uses an underlying RDBMS or ODBMS then you may have access to more powerful schema creation and manipulation capabilities.

如果图形数据库使用底层RDBMS或ODBMS,那么您可以访问更强大的模式创建和操作功能。

#3


2  

Graph databases differ a lot in this area, just like das_weezul says. In the general case I think graph databases which are closer to object databases (OODB) also have built-in schema support. One nice thing about graph databases is that they're very well suited for mixing data and metadata. So a common approach for both dealing with schema support and security is to store this kind of metadata in a (sometimes hidden) part of the very same graph.

就像das_weezul说的那样,图形数据库在这方面有很大的不同。在一般情况下,我认为更接近对象数据库(OODB)的图形数据库也具有内置模式支持。图数据库的一个优点是它们非常适合混合数据和元数据。因此,处理模式支持和安全性的一种常见方法是将这种元数据存储在同一图的(有时是隐藏的)部分中。

When it comes to Neo4j - where I'm on the team - there's currently at least two approaches in use for defining schemas:

当涉及到Neo4j(我所在的团队)时,目前至少有两种用于定义模式的方法:

  • Defining the schema in annotations, for example using Spring Data Graph (docs).
  • 在注释中定义模式,例如使用Spring数据图(docs)。
  • Using a meta-model layer on top of the database.
  • 使用数据库之上的元模型层。

You'll find some more reading on this topic over at myNoSQL.

您将在myNoSQL找到更多关于这个主题的阅读。