例如,这里有两个我要插入的链接节点:
{
"@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: "..."
}
请注意“图像”属性如何包含多个对象,这些对象可以是文本或指向其他节点。
Neo4j 似乎区分了“属性”和“关系”。在 Neo4j 或类似的图形数据库中,有没有一种方法可以使关系和属性是一回事,并且属性的值可以指向另一个节点?
最佳答案
在 Neo4j 中,关系本身就是对象,可以包含自己的属性。
没有什么可以阻止您在属性中保留对另一个节点的引用,但不建议这样做,因为数据库会为您跟踪它。
使用 Neo4j 作为示例,您可以使用图像创建其他节点,并简单地在组织节点和图像节点之间创建关系。
如果您需要有关特定节点关系的信息,可以通过 ReST 接口(interface)获得很多详细信息,尽管在返回的 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}
同样对于关系,返回的 JSON 文档中有属性描述连接到关系的开始节点和结束节点。
"start": "http://localhost:7474/db/data/node/2"
"end": "http://localhost:7474/db/data/node/22"
关于database - 将 JSON-LD 插入 Neo4j 的语义正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29099217/