关系数据库和图数据库的比较

关系数据库和图数据库的比较

问题描述:

有人可以向我解释一下关系数据库(例如MySQL)与图形数据库(例如Neo4j)相比的优缺点吗?

Can someone explain to me the advantages and disadvantages for a relation database such as MySQL compared to a graph database such as Neo4j?

在SQL中,您具有多个具有各种ID的表,这些表将它们链接在一起.然后,您必须加入才能连接表.从新手的角度来看,您为什么要设计数据库以要求联接,而不是像图数据库那样从一开始就将连接显式地指定为边.从概念上讲,这对于新手来说毫无意义.大概有一个非常技术性但非概念性的原因吗?

In SQL you have multiple tables with various ids linking them. Then you have to join to connect the tables. From the perspective of a newbie why would you design the database to require a join rather than having the connections explicit as edges from the start as with a graph database. Conceptually it would make no sense to a newbie. Presumably there is a very technical but non-conceptual reason for this?

两种样式背后实际上都有概念上的推理.有关关系模型

There actually is conceptual reasoning behind both styles. Wikipedia on the relational model and graph databases gives good overviews of this.

主要区别在于,在图形数据库中,关系存储在单个记录级别,而在关系数据库中,结构定义在更高级别(表定义).

The primary difference is that in a graph database, the relationships are stored at the individual record level, while in a relational database, the structure is defined at a higher level (the table definitions).

这有重要影响:

  • 关系数据库在大量运行时要快得多 记录.在图形数据库中,必须检查每条记录 在查询过程中分别确定其结构 数据,尽管这在关系数据库中是提前知道的.
  • 关系数据库使用较少的存储空间,因为它们没有 存储所有这些关系.
  • A relational database is much faster when operating on huge numbers of records. In a graph database, each record has to be examined individually during a query in order to determine the structure of the data, while this is known ahead of time in a relational database.
  • Relational databases use less storage space, because they don't have to store all of those relationships.

只有在关系中会有很多变化时,才有可能将所有关系存储在个人记录级别.否则,您将一遍又一遍地复制相同的内容.这意味着图形数据库非常适合不规则的复杂结构.但是在现实世界中,大多数数据库都需要规则的,相对简单的结构.这就是关系数据库占主导地位的原因.

Storing all of the relationships at the individual-record level only makes sense if there is going to be a lot of variation in the relationships; otherwise you are just duplicating the same things over and over. This means that graph databases are well-suited to irregular, complex structures. But in the real world, most databases require regular, relatively simple structures. This is why relational databases predominate.