Neo4j如何在内部存储数据? [英] How Neo4j stores data internally?

查看:548
本文介绍了Neo4j如何在内部存储数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是从开发人员的角度(不是特别尊重用户),可能会有点凌乱。
我想知道Nodes和Relationships的结构如何被逻辑地存储在数据库中。喜欢,当我说我有bla bla信息。哪里? - 那么答案就是在BOOK中,以网格或网页的形式出现。在RDBMS的情况下,数据以网格/表格格式存储。但是我无法了解如何将图形存储在Neo4j / graph数据库中。
我正在使用neo4j客户端2.1.2。

解决方案

http://www.slideshare.net/thobe/an-overview-of-neo4j-internals 有点过时了但是这给了你很好的Neo4j逻辑表示的概述。



一个节点引用:




  • 它的第一个标签(我的猜测是标签存储为单链表)

  • 它的第一个属性(属性组织为单链表)

  • 它的开始/结束关系



关系被组织为双向链接列表。
一个关系指向:




  • 它的第一个属性(与节点相同)

  • 其起始节点的前身和后继关系

  • 其末端节点的前身和后继关系



<由于这种链接结构,遍历的概念(即查询数据的方式)很容易出现。这就是为什么像Neo4j这样的图形数据库擅长遍历图形结构的数据。



我的粗略猜测也是,因为Neo4j版本2.1(和其新引入的密集节点管理) ,节点的关系按类型分隔。通过这样做,如果节点N例如是类型A的5个关系的起始节点和类型B的500万个关系,则针对N的类型A的遍历相关性保持为O(n = 5)。


My question is from the view of developer (not specifically respect to User) and may be bit messy. I want to know that how the structure of Nodes and Relationships is get stored in database logically. Like, when I say that I have bla bla information. Where? - then the answer is, in BOOK, either in form of Grid or lines on a page. In case of RDBMS, data is stored in Grid/Tabular format. But I am unable to understand how graph is get stored in Neo4j/graph database. I am using neo4j client 2.1.2.

解决方案

http://www.slideshare.net/thobe/an-overview-of-neo4j-internals is a bit outdated but this gives you a good overview of Neo4j logical representation.

A node references:

  • its first label (my guess is that labels are stored as a singly linked list)
  • its first property (properties are organized as a singly linked list)
  • its start/end relationships

Relationships are organized as doubly linked lists. A relationship points to:

  • its first property (same as nodes)
  • the predecessor and successor relationship of its start node
  • the predecessor and successor relationship of its end node

Because of this chaining structure, the notion of traversal (i.e. THE way of querying data) easily emerges. That's why a graph database like Neo4j excels at traversing graph-structured data.

My rough guess would be also, since Neo4j version 2.1 (and its newly introduced dense node management), nodes' relationships are segregated by type. By doing so, if a node N is for example a start node for 5 relationships of type A and for 5 million rels of type B, traversing rels of type A for N remains O(n=5).

这篇关于Neo4j如何在内部存储数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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