graph - 如何表示图的数据模型

标签 graph neo4j data-modeling

所以我们一直在开发一些基于图的分析工具,在后台使用neo4j作为持久化引擎。作为其中的一部分,我们正在开发适合我们领域的图数据模型,我们希望在应用层使用它来限制节点的类型,或确保某些类型的节点必须具有某些属性。正常数据模型限制。

这就是背景,我要问的是是否有一些标准方法来表示图形数据库的数据模型?也许相当于 xsd 的图形?

最佳答案

Neo4j 中有一个支持强模式定义的开源项目:Structr( http://structr.org ,请参见实际操作: http://vimeo.com/structr/videos )

Structr's Visual Schema Editor

使用 Structr,您可以定义数据模型的图内模式,包括

  • 类型继承
  • 支持的数据类型:Boolean、String、Integer、Long、Double、Date、Enum(+ 值)
  • 默认值
  • 基数 (1:1, 1:*, *:1)
  • 非空约束
  • 唯一性约束
  • 全式安全
  • 验证
  • 基数强制执行

  • 目前正在向架构中添加对方法(自定义操作)的支持。

    可以使用编辑器或直接通过 REST 编辑模式,修改数据模型的 JSON 表示:
    {
       "query_time": "0.001618446",
       "result_count": 4,
       "result": [
          {
             "name": "Whisky",
             "extendsClass": null,
             "relatedTo": [
                {
                   "id": "96d05ddc9f0b42e2801f06afb1374458",
                   "name": "Flavour"
                },
                {
                   "id": "28f85dca915245afa3782354ea824130",
                   "name": "Location"
                }
             ],
             "relatedFrom": [],
             "id": "df9f9431ed304b0494da84ef63f5f2d8",
             "type": "SchemaNode",
             "_name": "String"
          },
          {
             "name": "Flavour",
             ...
          },
          {
             "name": "Location",
             ...
          },
          {
             "name": "Region",
             ...
          }
       ],
       "serialization_time": "0.000829985"
    }
    
    {
       "query_time": "0.001466743",
       "result_count": 3,
       "result": [
          {
             "name": null,
             "sourceId": "28f85dca915245afa3782354ea824130",
             "targetId": "e4139c5db45a4c1cbfe5e358a84b11ed",
             "sourceMultiplicity": null,
             "targetMultiplicity": "1",
             "sourceNotion": null,
             "targetNotion": null,
             "relationshipType": "LOCATED_IN",
             "sourceJsonName": null,
             "targetJsonName": null,
             "id": "d43902ad7348498cbdebcd92135926ea",
             "type": "SchemaRelationship",
             "relType": "IS_RELATED_TO"
          },
          {
             "name": null,
             "sourceId": "df9f9431ed304b0494da84ef63f5f2d8",
             "targetId": "96d05ddc9f0b42e2801f06afb1374458",
             "sourceMultiplicity": null,
             "targetMultiplicity": "1",
             "sourceNotion": null,
             "targetNotion": null,
             "relationshipType": "HAS_FLAVOURS",
             "sourceJsonName": null,
             "targetJsonName": null,
             "id": "bc9a6308d1fd4bfdb64caa355444299d",
             "type": "SchemaRelationship",
             "relType": "IS_RELATED_TO"
          },
          {
             "name": null,
             "sourceId": "df9f9431ed304b0494da84ef63f5f2d8",
             "targetId": "28f85dca915245afa3782354ea824130",
             "sourceMultiplicity": null,
             "targetMultiplicity": "1",
             "sourceNotion": null,
             "targetNotion": null,
             "relationshipType": "PRODUCED_IN",
             "sourceJsonName": null,
             "targetJsonName": null,
             "id": "a55fb5c3cc29448e99a538ef209b8421",
             "type": "SchemaRelationship",
             "relType": "IS_RELATED_TO"
          }
       ],
       "serialization_time": "0.000403616"
    }
    

    您可以通过基于图内模式动态配置的 RESTful API 访问存储在 Neo4j 中的节点和关系作为 JSON 对象。
    $ curl try.structr.org:8082/structr/rest/whiskies?name=Ardbeg
    {
       "query_time": "0.001267211",
       "result_count": 1,
       "result": [
          {
             "flavour": {
                "name": "J",
                "description": "Full-Bodied, Dry, Pungent, Peaty and Medicinal, with Spicy, Feinty Notes.",
                "id": "626ba892263b45e29d71f51889839ebc",
                "type": "Flavour"
             },
             "location": {
                "region": {
                   "name": "Islay",
                   "id": "4c7dd3fe2779492e85bdfe7323cd78ee",
                   "type": "Region"
                },
                "whiskies": [
                   ...
                ],
                "name": "Port Ellen",
                "latitude": null,
                "longitude": null,
                "altitude": null,
                "id": "47f90d67e1954cc584c868e7337b6cbb",
                "type": "Location"
             },
             "name": "Ardbeg",
             "id": "2db6b3b41b70439dac002ba2294dc5e7",
             "type": "Whisky"
          }
       ],
       "serialization_time": "0.010824154"
    }
    

    在 UI 中,还有一个数据编辑 (CRUD) 工具,以及支持在 Neo4j 上创建 Web 应用程序的 CMS 组件。

    免责声明:我是 Structr 的开发人员和该项目的创始人。

    关于graph - 如何表示图的数据模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23762424/

    相关文章:

    javascript - D3如何创建圆轴和样式选项

    jakarta-ee - 获取锁时出错(org.neo4j.kernel.Store LockException)

    java - 应该使用什么数据结构来表示街道网络?

    java - 图形数据从边输入格式转换为顶点输入格式

    azure - 如何使用graph api更新azure ad中的用户密码

    bash - 如何以编程方式绘制来自文件的连续数据集的图表?

    python - 带有数据库回滚的路由的 Flask 功能 pytest 测试

    java - Neo4j/CYPHER : How can I query some properties from a node, 它的关系和目标节点有效吗?

    mySQL KEY 使用三个表字段(列)进行分区

    java - 客观化 POST/LIKE/USER 关系