它是使用MySQL和Neo4j的一起是个好主意? [英] Is it a good idea to use MySQL and Neo4j together?

查看:3210
本文介绍了它是使用MySQL和Neo4j的一起是个好主意?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将有很多类似的项目(百万)的应用,我想将它们存储在一个MySQL数据库,因为我希望做很多统计和对特定列的特定值搜索

I will make an application with a lot of similar items (millions), and I would like to store them in a MySQL database, because I would like to do a lot of statistics and search on specific values for specific columns.

但与此同时,我将存储的所有项目,即在许多连二进制树状结构(传递闭包)相关关系,与关系数据库不擅长的那种结构的,所以我会喜欢存储的Neo4j其中有这类数据的良好表现的所有关系。

But at the same time, I will store relations between all the items, that are related in many connected binary-tree-like structures (transitive closure), and relation databases are not good at that kind of structures, so I would like to store all relations in Neo4j which have good performance for this kind of data.

我的计划是,除了有存储在数据库中的Neo4j在MySQL数据库中的关系,并与 ITEM_ID 的所有关系的所有数据。当我想查找一棵树,我先搜索的Neo4j所有 ITEM_ID :■在树上,然后我搜索的MySQL数据库中所有指定项目查询看起来像:

My plan is to have all data except the relations in the MySQL database and all relations with item_id stored in the Neo4j database. When I want to lookup a tree, I first search the Neo4j for all the item_id:s in the tree, then I search the MySQL-database for all the specified items in a query that would look like:

SELECT * FROM WHERE ITEM_ID = 45或ITEM_ID = 345435 OR ITEM_ID = 343 OR ITEM_ID = 78或项目ITEM_ID = 4522 OR ITEM_ID = 676 OR ITEM_ID = 443 OR ITEM_ID = 4255 OR ITEM_ID = 4345

这是一个好主意,还是我非常错误的?我以前没有使用图形的数据库。在那里我的问题,任何更好的方法?如何将MySQL的查询在这种情况下执行?

Is this a good idea, or am I very wrong? I haven't used graph-databases before. Are there any better approaches to my problem? How would the MySQL-query perform in this case?

推荐答案

在这几点想法:

我会尝试造型您Neo4j的域模型,包括图中每个节点的属性。通过将数据分成两个不同的数据存储,你可能会限制一些操作,你可能想要做的。

I would try modelling your Neo4j domain model to include the attributes of each node in the graph. By separating your data into two different data stores you might limit some operations that you might want to do.

我猜它归结为你将与你的图中可以做什么?例如,如果要查找所有连接到特定的节点,其属性(如姓名,年龄..等等)有一定价值的节点,你首先要找到正确的节点ID在你的MySQL数据库,然后进入Neo4j的。这似乎只是缓慢和过于复杂时,你可以做到这一切在Neo4j的。所以,问题是你会需要一个节点的属性,当你遍历图?

I guess it comes down to what you will be doing with your graph? If for example want to find all the nodes connected to a specific node, whose attributes (ie name, age.. whatever) are certain values, would you first have to find the correct node ID in your MySQL database and then go into Neo4j. This just seems slow and overly complicated when you could do all this in Neo4j. So the question is will you need the attributes of a node when you traversing the graph?

将你的数据的变化或者是静态的?通过拥有两个独立的数据存储将问题复杂化。

Will your data change or is it static? By having two separate data stores it will complicate matters.

虽然产生使用MySQL数据库可能比Neo4j的做的一切更简单的统计,需要code遍历图来查找符合定义的标准是不是太困难的所有节点。什么这些统计数据是应该推动解决方案。

Whilst generating statistics using a MySQL database might be easier than doing everything in Neo4j, the code required to traverse a graph to find all the nodes that meet a defined criteria isn't overly difficult. What these stats are should drive your solution.

我不能在MySQL查询的性能评价来选择节点ID。我想这归结到你需要多少个节点选择和您的索引策略。我同意的事情性能方面,当涉及到穿越虽然图

I can't comment on the performance of the MySQL query to select node ids. I guess that comes down to how many nodes you will need to select and your indexing strategy. I agree about the performance side of things when it comes to traversing a graph though.

这是对眼前这个好文章: MySQL中使用大型图形对比的Neo4j遍历并在这种情况下,当他们说大,它们仅仅意味着一个百万顶点/节点和四个百万边缘。所以,它甚至不是一个特别稠密图。

This is a good article on just this: MySQL vs. Neo4j on a Large-Scale Graph Traversal and in this case, when they say large, they only mean a million vertices/nodes and four million edges. So it wasn't even a particularly dense graph.

这篇关于它是使用MySQL和Neo4j的一起是个好主意?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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