Neo4j所依赖的图模型,其学名为(标记)属性图模型。其定义如下:
- 一个标记属性图由点、关系、属性以及标签组成
- 点拥有属性。点就像一个文件,他以任意键值对的形式存储属性。在 Neo4j 中,键值是字符串,其值是Java 字符串、基元数据类型,以及这些类型的数组。
- 点可以被多个标签标记。标签将点氛围不用组,并且标识点在数据集中的角色与作用。
- 关系将点联系在了一起,并构成了图的结构。关系总是包含一个方向,一个名字和关系的起始点与终止点——没有悬空的关系。关系的方向和名称一起为节点的结构增加了语义清晰度。
- 和点一样,关系和可以拥有属性。可以为关系增加属性的能力非常有用,尤其是为图算法提供额外的元数据、向关系添加其他语义(包括质量和权重),以及在运行时约束查询的时候。
英文原文:
基本定义(In Chapter 1):A labeled property graph has the following characteristics:
- It contains nodes and relationships.
- Nodes contain properties (key-value pairs).
- Nodes can be labeled with one or more labels.
- Relationships are named and directed, and always have a start and end node.
- Relationships can also contain properties.
它的解释:
We introduced the labeled property graph model in Chapter 1. To recap, these are its salient features:
- A labeled property graph is made up of nodes, relationships, properties, and labels.
- Nodes contain properties. Think of nodes as documents that store properties in the form of arbitrary key-value pairs. In Neo4j, the keys are strings and the values are the Java string and primitive data types, plus arrays of these types.
- Nodes can be tagged with one or more labels. Labels group nodes together, and indicate the roles they play within the dataset.
- Relationships connect nodes and structure the graph. A relationship always has a direction, a single name, and a start node and an end node—there are no dangling relationships. Together, a relationship’s direction and name add semantic clarity to the structuring of nodes.
- Like nodes, relationships can also have properties. The ability to add properties to relationships is particularly useful for providing additional metadata for graph algorithms, adding additional semantics to relationships (including quality and weight), and for constraining queries at runtime.