从SQL Server迁移到neo4j,就像SSMS一样将数据导入neo4j

时间:2023-01-10 18:03:46

I'm migrating from SQL Server to Neo4J (or ArangoDB, much more challenging), currently using the Windows stack, and C#. I saw the batch importer on github[https://github.com/jexp/batch-import/tree/20 ].

我正在从SQL Server迁移到Neo4J(或ArangoDB,更具挑战性),目前正在使用Windows堆栈和C#。我在github上看到了批量导入器[https://github.com/jexp/batch-import/tree/20]。

This util is an export tool, but I can't figure out where the rels.csv and nodes.csv are, on the export side (I see it on the import into neo4j). Is this an option in the util, or is this something I tell SSMS (SQL Server Management Studio) to create. More specifically, what is the difference rels and nodes from a SQL RDB standpoint?

这个util是一个导出工具,但我无法弄清楚rels.csv和nodes.csv在导出端的位置(我在导入到neo4j时看到它)。这是util中的一个选项,还是我告诉SSMS(SQL Server Management Studio)创建的内容。更具体地说,从SQL RDB的角度来看,rels和节点的区别是什么?

To migrate the data - what options/steps do I need to follow to, set so that I can 1) export from SQL Server 2) Import into Neo4j that can easily work with the .netdriver/client?

要迁移数据 - 我需要遵循哪些选项/步骤,设置以便我可以1)从SQL Server导出2)导入到Neo4j中,可以轻松使用.netdriver / client?

Here is what I know on the import, but not on the export side.

以下是我对导入的了解,但不是出口方面。

batch_import.nodes_files=nodes1.csv[,nodes2.csv]
batch_import.rels_files=rels1.csv[,rels2.csv]

Is there an import tool, like SSMS import in Neo4j, that will help in this and translate/keep the relationships as nodes to nodes

是否有一个导入工具,如Neo4j中的SSMS导入,将有助于此并将关系转换/保持为节点到节点

Am I correct in thinking this way -

我是这样思考的 -

  • Do schema tables map to nodes?
  • 架构表是否映射到节点?
  • Do table columns/attributes map to (table) nodes in neo4j
  • 表列/属性是否映射到neo4j中的(表)节点
  • Do FK's and PK's translate to relationships or labels?
  • FK和PK会转化为关系或标签吗?

2 个解决方案

#1


1  

I'll try to provide brief, succinct answers to your specific questions, but on the data modeling topics, you need to read some background. Check out Data Modeling in Graphs for a good intro. I'm not giving you the whole story here, becuase you're asking a question that requires an in-depth answer. That briefing is that answer.

我将尝试为您的具体问题提供简明扼要的答案,但在数据建模主题上,您需要阅读一些背景知识。查看图表中的数据建模以获得良好的介绍。我不是在这里给你讲完整个故事,因为你问的是一个需要深入回答的问题。那个简报就是答案。

  1. Do schema tables map to nodes? Sort of, yes - the way I would put it is more that in a relational database, "entities" map to nodes. Note that "entities" and "tables" are really not the same thing due to normalization and many other factors. Also, not all of the schema table maps to a node, in particular because tables include things like PKs/FKs which you won't use in neo4j (more on this in a moment)

    架构表是否映射到节点?排序,是的 - 我想说的方式更多的是在关系数据库中,“实体”映射到节点。请注意,由于规范化和许多其他因素,“实体”和“表格”实际上并不相同。此外,并非所有模式表都映射到节点,特别是因为表包含您不会在neo4j中使用的PK / FK之类的东西(稍后会详细介绍)

  2. Do table columns/attributes map to (table) nodes in neo4j. No, they don't. Attributes map on to node attributes, but there are many exceptions. In particular, any attribute that you're using to join things on in a relational database likely maps to a neo4j relationship, not a node attribute.

    表列/属性是否映射到neo4j中的(表)节点。不,他们没有。属性映射到节点属性,但有许多例外。特别是,您用于在关系数据库中加入内容的任何属性都可能映射到neo4j关系,而不是节点属性。

  3. Do FK's and PK's translate to relationships or labes? They map to relationships. Any kind of joining is generally going to translate into a relationship between nodes.

    FK和PK是否会转化为人际关系或实验室?他们映射到关系。任何类型的连接通常都会转化为节点之间的关系。

#2


0  

I can only give you an general answer on how to import graph data into ArangoDB. Also checkout FrobberOfBits answers. For a more specific answer, please contact "hackers (at) arangodb.org".

我只能就如何将图形数据导入ArangoDB给出一般答案。还要结帐FrobberOfBits的答案。有关更具体的答案,请联系“hackers(at)arangodb.org”。

Normally the sql schema corresponds to some entities, which are visible as C# objects. The modelling of a class hierarchy can done in different ways. Such entity would correspond to documents in ArangoDB.

通常,sql架构对应于某些实体,这些实体作为C#对象可见。类层次结构的建模可以以不同的方式完成。这样的实体将对应于ArangoDB中的文档。

For example: One way of modelling vehicles, cars and motorcycle is using three tables. One for the superclass and two for the subclass. There will be foreign keys to link the the subclass data to the superclass data. In ArangoDB there will only be a vehicle class and the documents contain attributes vary depending if it is a car or a motorcycle.

例如:对车辆,汽车和摩托车进行建模的一种方法是使用三张桌子。一个用于超类,两个用于子类。将有外键将子类数据链接到超类数据。在ArangoDB中,只有车辆类,文件包含的属性取决于它是汽车还是摩托车。

Now there might be a relationship between a person and a vehicle. This is different from the above example - also again foreign keys are used. In this case you would a edge in ArangoDB between two documents.

现在,人和车之间可能存在关系。这与上面的例子不同 - 也使用外键。在这种情况下,您将在两个文档之间的ArangoDB中占优势。

So you need an export to create all the documents (entities) and all the edges (relationship). You can then use "arangoimp" to import these files into ArangoDB.

因此,您需要导出以创建所有文档(实体)和所有边(关系)。然后,您可以使用“arangoimp”将这些文件导入ArangoDB。

#1


1  

I'll try to provide brief, succinct answers to your specific questions, but on the data modeling topics, you need to read some background. Check out Data Modeling in Graphs for a good intro. I'm not giving you the whole story here, becuase you're asking a question that requires an in-depth answer. That briefing is that answer.

我将尝试为您的具体问题提供简明扼要的答案,但在数据建模主题上,您需要阅读一些背景知识。查看图表中的数据建模以获得良好的介绍。我不是在这里给你讲完整个故事,因为你问的是一个需要深入回答的问题。那个简报就是答案。

  1. Do schema tables map to nodes? Sort of, yes - the way I would put it is more that in a relational database, "entities" map to nodes. Note that "entities" and "tables" are really not the same thing due to normalization and many other factors. Also, not all of the schema table maps to a node, in particular because tables include things like PKs/FKs which you won't use in neo4j (more on this in a moment)

    架构表是否映射到节点?排序,是的 - 我想说的方式更多的是在关系数据库中,“实体”映射到节点。请注意,由于规范化和许多其他因素,“实体”和“表格”实际上并不相同。此外,并非所有模式表都映射到节点,特别是因为表包含您不会在neo4j中使用的PK / FK之类的东西(稍后会详细介绍)

  2. Do table columns/attributes map to (table) nodes in neo4j. No, they don't. Attributes map on to node attributes, but there are many exceptions. In particular, any attribute that you're using to join things on in a relational database likely maps to a neo4j relationship, not a node attribute.

    表列/属性是否映射到neo4j中的(表)节点。不,他们没有。属性映射到节点属性,但有许多例外。特别是,您用于在关系数据库中加入内容的任何属性都可能映射到neo4j关系,而不是节点属性。

  3. Do FK's and PK's translate to relationships or labes? They map to relationships. Any kind of joining is generally going to translate into a relationship between nodes.

    FK和PK是否会转化为人际关系或实验室?他们映射到关系。任何类型的连接通常都会转化为节点之间的关系。

#2


0  

I can only give you an general answer on how to import graph data into ArangoDB. Also checkout FrobberOfBits answers. For a more specific answer, please contact "hackers (at) arangodb.org".

我只能就如何将图形数据导入ArangoDB给出一般答案。还要结帐FrobberOfBits的答案。有关更具体的答案,请联系“hackers(at)arangodb.org”。

Normally the sql schema corresponds to some entities, which are visible as C# objects. The modelling of a class hierarchy can done in different ways. Such entity would correspond to documents in ArangoDB.

通常,sql架构对应于某些实体,这些实体作为C#对象可见。类层次结构的建模可以以不同的方式完成。这样的实体将对应于ArangoDB中的文档。

For example: One way of modelling vehicles, cars and motorcycle is using three tables. One for the superclass and two for the subclass. There will be foreign keys to link the the subclass data to the superclass data. In ArangoDB there will only be a vehicle class and the documents contain attributes vary depending if it is a car or a motorcycle.

例如:对车辆,汽车和摩托车进行建模的一种方法是使用三张桌子。一个用于超类,两个用于子类。将有外键将子类数据链接到超类数据。在ArangoDB中,只有车辆类,文件包含的属性取决于它是汽车还是摩托车。

Now there might be a relationship between a person and a vehicle. This is different from the above example - also again foreign keys are used. In this case you would a edge in ArangoDB between two documents.

现在,人和车之间可能存在关系。这与上面的例子不同 - 也使用外键。在这种情况下,您将在两个文档之间的ArangoDB中占优势。

So you need an export to create all the documents (entities) and all the edges (relationship). You can then use "arangoimp" to import these files into ArangoDB.

因此,您需要导出以创建所有文档(实体)和所有边(关系)。然后,您可以使用“arangoimp”将这些文件导入ArangoDB。