Neo4j:使用XSD实施架构 [英] Neo4j: Enforcing schema with XSD

查看:60
本文介绍了Neo4j:使用XSD实施架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否存在用于Neo4j的工具,该工具可以读取XSD文件并使用它在Neo4j上实施模式.

I was wondering if there exists a tool for Neo4j that can read an XSD file and use it to enforce a schema on Neo4j.

我是图数据库的新手,但是我开始欣赏无模式方法.有很多项目正在抽取很多非顺序数据并充分利用它们,这真的很酷.

I'm newbie on graph databases but I'm starting to appreciate the schema-less approach. There's a lot of projects out there that have been pumping in a lot of non-sequential data and making sense of it all which is really cool.

我遇到了一些要求,这些要求要求控制节点或边缘可以赋予特定标签的属性以及边缘可以赋予其源节点和目标节点的标签的标签.架构也可能会更改-尽管不经常更改.

I've come across some requirements that call for control on what properties a node or edge can have given a certain label and what labels an edge can have given the labels of its source and destination nodes. The schema is also subject to change - although not frequent.

据我了解,标准做法是从应用程序本身控制架构,对我而言,这似乎不是最佳做法.例如,Oracle的挑剔开发人员创建了供应用程序与之交互的视图,然后将触发器应用于在应用程序尝试在视图上插入或更新时执行适当事务的视图上.

As I understand, the standard practice is to control the schema from the application itself which to me doesn't seem like it should be a BEST practice. For example, the picky developers from Oracle land create views for applications to interact with and then apply triggers onto the views that execute the appropriate transactions upon the application attempting to insert or update on the view.

我将在Neo4j中寻找类似的设备,并且由于我已经拥有XSD文件,因此将其简单地转储到文件夹中并使用它作为执行内容的参考将大大减少整体工作.

I would be looking for a similar device in Neo4j and since I already have the XSD files, it would be a lot less work overall to simply dump them into a folder and have it use those for reference on what to enforce.

这是我愿意写的东西,除非已经有一个用于此的库.毕竟我有一份日常工作. :)

This is something I'm willing to write myself unless there's already a library out there for this. I have a day job after all. :)

谢谢!

推荐答案

该工具不仅不存在,而且如果不进行更多有关XML如何存储在neo4j中的标准化工作,它甚至不存在. XML模型和neo4j模型之间存在主要区别.

Not only does this tool not exist, but it couldn't even exist without more work on standardizing how XML is stored in neo4j. There are key differences between the XML model and the neo4j model.

有一个此python应用程序可以将XML导入neo4j;文档,而不是模式.但是在执行该操作的方式中,要记住许多事情:

There's this python application here that can import XML into neo4j; documents, not schemas. But in the way that it does it, there are many things to keep in mind:

  1. 从XML元素/属性到neo4j节点/属性没有明显的映射.您认为元素应该是节点,属性属性;但是更好的图模型通常与此不同.例如,XML名称空间将成为很好的节点,因为它们连接到许多其他事物(例如,在名称空间中定义的所有元素),但通常它们是属性.也许名称空间应该是标签?除了那里没有标准答案之外,也许也是一个合理的选择.
  2. XML树具有序列,而序列很重要;图没有.假设您有一个带有两个子元素AB的XML元素.在neo4j中,您可能有一个连接到其他两个节点的节点,但是您需要一种表示(可能是通过关系属性)A优先于B的方式.这在neo4j中当然可行,但是据我所知,这还没有达成一致怎么做.因此,也许您选择一个sequence属性,并为其提供一个整数值.似乎合理...但是现在您的模式验证软件已经依赖于该设计选择. neo4j中存储的XML不能通过其他任何方式验证.
  3. 在模式验证中有很多XML处理选项对图形没有影响,例如,您是否关心忽略空白节点,严格还是宽松的模式验证等等.
  1. There's no obvious mapping from XML elements/attributes on to neo4j nodes/properties. You'd think that elements should be nodes, attributes properties; but a better graph model would usually be different than that. For example, XML namespaces would make great nodes because they connect to so many other things (e.g. all elements defined in a namespace) yet typically they're attributes. Maybe namespaces should be labels? Also maybe a reasonable choice, except there's no standard answer there.
  2. XML trees have sequence, and sequence matters; graphs don't. Say you have an XML element with 2 children, A and B. In neo4j you might have a node connected to two other nodes, but you need a way of expressing (probably via a relationship property) that A comes before B. That's of course doable in neo4j, but there's no agreement as far as I know about how to do that. So maybe you pick a sequence attribute, and give it an integer value. Seems reasonable...but now your schema validation software has a dependency on that design choice. XML in neo4j stored any other way won't validate.
  3. There's a host of XML processing options that matter in schema validation that wouldn't in a graph, for example whether or not you care about ignoring whitespace nodes, strict vs. lax schema validation, and so on.

看起来,neo4j很不错,但是如果您确实需要验证一堆XML文档,则由于图形模型与XML的文档模型之间存在某些不匹配,这可能不是您的最佳选择.可能的选择可能是在文档进入neo4j之前对其进行验证,或者只是想出一种从neo4j中的 合成XML文档的方法,然后在结果超出图形范围时对其进行验证.数据库,作为XML文件.

Look, neo4j is great but if you really need to validate a pile of XML documents, it's probably not your best choice because of some mismatches between the graph model and XML's document model. Possible options might be to validate the documents before they go into neo4j, or just to come up with a way of synthesizing XML documents from what is in neo4j, and then validating that result once it's outside of the graph database, as an XML file.

这篇关于Neo4j:使用XSD实施架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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