部分图形数据集的neo4j或neo4j + mysql

时间:2021-06-23 18:01:39

Even though I read another question here advising not to use both neo4j and mysql (neo4j - graph database along with a relational database?), I was wondering what approach would be the best for dataset that has some data which can be modeled like a graph and the rest looks relational. For some reasons, I can't post the kind of data I'm using.

即使我在这里读到另一个问题,建议不要同时使用neo4j和mysql(neo4j - 图形数据库以及关系数据库吗?),我想知道哪种方法最适合具有一些数据的数据集,这些数据可以像图形一样建模其余看起来是关系型的。由于某些原因,我无法发布我正在使用的数据类型。

I can shoehorn the relational part into neo4j but it looks ugly and complex, something I would want to avoid.

我可以把关系部分搞砸到neo4j,但它看起来很丑陋和复杂,我想避免的。

On the other hand, if I use both together, I'll have to do double the amount of queries to get the result, decreasing performance (assume the DBs are on cloud in separate machines).

另一方面,如果我同时使用它们,我将不得不做两倍的查询以获得结果,降低性能(假设数据库在不同的机器上的云上)。

I can't use mysql alone because one of the queries requires a depth of around 20-30 which I assume can't be handled by mysql.

我不能单独使用mysql,因为其中一个查询需要大约20-30的深度,我认为这是mysql无法处理的。

Have any of you encountered such a situation before ? If so, how did you solve it ?

你们有没有遇到过这样的情况?如果是这样,你是如何解决的?

1 个解决方案

#1


1  

As everyone else says: "give us a better idea of what data you are trying to model so we can best give you a suggestion".

正如其他人所说:“让我们更好地了解您尝试建模的数据,以便我们最好地给您一个建议”。

That being said, dealing with 2 DBs is not an issue and its more common than people think: often-times you use a Full-Text store for searches and then get back a list of Document IDs which you then hit the relational DB for additional metadata. Or hitting Redis to get a list of IDs which you also hit the relational DB for more data.

话虽这么说,处理2个DB并不是一个问题,它比人们想象的更常见:经常 - 你使用全文存储进行搜索,然后返回一个文档ID列表,然后你可以点击关系数据库元数据。或者点击Redis获取一个ID列表,您也可以访问关系数据库以获取更多数据。

I proof-of-concepted a system of Neo4j+MySQL for targeted searching based on your social network ("show me all restaurants my network has recommended ordered by depth (e.g. 1st level friend recs are weighted higher than 2nd level, and so on) and it didn't feel awkward. But I also didn't take it to scale.

我根据你的社交网络对Neo4j + MySQL系统进行了有针对性的搜索验证(“告诉我网络推荐的所有餐厅都按深度排序(例如,1级朋友记录加权高于2级,依此类推)并没有感到尴尬。但我也没有把它扩大规模。

You will be having to keep both datastores in sync. So in my case when a user recommends a place on the web app (which inserts it into MySQL) you then need to turn around and do the same insert into Neo. You probably want to do this asynchronously as well, so you'll need to setup a message queue with workers.

您将不得不保持两个数据存储同步。因此,在我的情况下,当用户在Web应用程序上建议一个位置(将其插入MySQL)时,您需要转身并对Neo执行相同的插入操作。您可能也希望异步执行此操作,因此您需要使用worker设置消息队列。

#1


1  

As everyone else says: "give us a better idea of what data you are trying to model so we can best give you a suggestion".

正如其他人所说:“让我们更好地了解您尝试建模的数据,以便我们最好地给您一个建议”。

That being said, dealing with 2 DBs is not an issue and its more common than people think: often-times you use a Full-Text store for searches and then get back a list of Document IDs which you then hit the relational DB for additional metadata. Or hitting Redis to get a list of IDs which you also hit the relational DB for more data.

话虽这么说,处理2个DB并不是一个问题,它比人们想象的更常见:经常 - 你使用全文存储进行搜索,然后返回一个文档ID列表,然后你可以点击关系数据库元数据。或者点击Redis获取一个ID列表,您也可以访问关系数据库以获取更多数据。

I proof-of-concepted a system of Neo4j+MySQL for targeted searching based on your social network ("show me all restaurants my network has recommended ordered by depth (e.g. 1st level friend recs are weighted higher than 2nd level, and so on) and it didn't feel awkward. But I also didn't take it to scale.

我根据你的社交网络对Neo4j + MySQL系统进行了有针对性的搜索验证(“告诉我网络推荐的所有餐厅都按深度排序(例如,1级朋友记录加权高于2级,依此类推)并没有感到尴尬。但我也没有把它扩大规模。

You will be having to keep both datastores in sync. So in my case when a user recommends a place on the web app (which inserts it into MySQL) you then need to turn around and do the same insert into Neo. You probably want to do this asynchronously as well, so you'll need to setup a message queue with workers.

您将不得不保持两个数据存储同步。因此,在我的情况下,当用户在Web应用程序上建议一个位置(将其插入MySQL)时,您需要转身并对Neo执行相同的插入操作。您可能也希望异步执行此操作,因此您需要使用worker设置消息队列。