将JSON-LD插入Neo4j的语义上正确的方法是什么?

wux*_*eji 5 database database-design graph neo4j

例如,这是我要插入的两个链接节点:

{
  "@context": "http://schema.org",
  "@id": "some_organization_id",
  "@type": "Organization",
  "name": "Some Awesome Company",
  "image": [
     "http://someawesomecompany.com/logo.jpg",
     { "@id": "some_image_id" }
  ]
}

{
  "@context": "http://schema.org",
  "@id": "some_image_id",
  "@type": "ImageObject",
  "contentUrl": "http://instagram.com/blahblah",
  "thumbnail: "...",
  "caption: "..."
}
Run Code Online (Sandbox Code Playgroud)

请注意,属性“图像”如何包含多个对象,这些对象可以是文本,也可以指向其他节点。

Neo4j似乎区分“属性”和“关系”。在Neo4j或类似的图形数据库中,有没有一种方法可以使关系和属性成为同一事物,并且属性的值可以指向另一个节点?

Dav*_*ett 3

在 Neo4j 中,关系本身就是对象,并且可以包含自己的属性。

没有什么可以阻止您在属性中保留对另一个节点的引用,但不建议这样做,因为数据库会为您跟踪该引用。

使用 Neo4j 作为示例,您可以使用图像创建其他节点,并简单地创建组织节点和图像节点之间的关系。

如果您需要有关特定节点的关系的信息,可以通过 ReST 接口获得大量详细信息,尽管返回的 JSON 对象中返回了多个属性来描述该节点的关系。

"outgoing_relationships": "http://localhost:7474/db/data/node/1/relationships/out"
"all_typed_relationships": "http://localhost:7474/db/data/node/1/relationships/all/{-list|&|types}"
"outgoing_typed_relationships": "http://localhost:7474/db/data/node/1/relationships/out/{-list|&|types}"
"incoming_relationships": "http://localhost:7474/db/data/node/1/relationships/in"
"create_relationship": "http://localhost:7474/db/data/node/1/relationships"
"all_relationships": "http://localhost:7474/db/data/node/1/relationships/all"
"incoming_typed_relationships": "http://localhost:7474/db/data/node/1/relationships/in/{-list|&|types}   
Run Code Online (Sandbox Code Playgroud)

同样,对于关系,返回的 JSON 文档中有一些属性描述连接到关系的起始节点和结束节点。

"start": "http://localhost:7474/db/data/node/2"
"end": "http://localhost:7474/db/data/node/22"
Run Code Online (Sandbox Code Playgroud)