[关闭]
@contribute 2016-04-08T02:04:30.000000Z 字数 3308 阅读 3090

图数据库schema定义

tinkerpop



0. TODO


1. bluemix图数据库schema设计

1.1 边标签

1.1.1 定义

1.1.2 举例

  1. {
  2. "name": "working-on",
  3. "multiplicity": "MULTI"
  4. }

注意:
1. 创建后不能被修改。
2. 每天边都必须有个标签。

1.2 顶点标签

1.2.1 定义

1.2.2 举例

  1. {
  2. "name": "location"
  3. }

1.3 属性key

1.3.1 定义

1.3.2 举例

  1. {
  2. "name": "population",
  3. "datatype": "Integer",
  4. "cardinality": "SINGLE"
  5. }

注意:
Integer : 在-9007199254740992+9007199254740992之间,也就是 ±2^53.
String : 小于等于65535个字节。

1.4 schema 完整例子

  1. [
  2. {
  3. "edgeindexes": [],
  4. "edgelabels": [
  5. {
  6. "multiplicity": "simple",
  7. "name": "route"
  8. }
  9. ],
  10. "propertykeys": [
  11. {
  12. "cardinality": "single",
  13. "datatype": "string",
  14. "name": "city"
  15. }
  16. ],
  17. "vertexindexes": [
  18. {
  19. "composite": false,
  20. "name": "cityindex",
  21. "propertykeys": [
  22. "city"
  23. ],
  24. "unique": false
  25. }
  26. ],
  27. "vertexlabels": [
  28. {
  29. "name": "location"
  30. }
  31. ]
  32. }
  33. ]

1.5 schema API

Method URI Request Response Description
get /schema - [ { "edgeindexes": [], "edgelabels": [ {"multiplicity":"simple", "name":"route"} ], "propertykeys": [ {"cardinality":"single", "datatype":"string", "name":"city"} ], "vertexindexes": [ {"composite":false, "name":"cityindex", "propertykeys":[ "city" ], "unique":false} ], "vertexlabels": [ {"name": "location"} ] } ] 返回json格式的schema
post /schema { "edgeindexes": [], "edgelabels": [ {"multiplicity":"simple", "name":"route"} ], "propertykeys": [ {"cardinality":"single", "datatype":"string", "name":"city"} ], "vertexindexes": [ {"composite":false, "name":"cityindex", "propertykeys":[ "city" ], "unique":false} ], "vertexlabels": [ {"name": "location"} ] } [ { "edgeindexes": [], "edgelabels": [ {"multiplicity":"simple", "name":"route"} ], "propertykeys": [ {"cardinality":"single", "datatype":"string", "name":"city"} ], "vertexindexes": [ {"composite":false, "name":"cityindex", "propertykeys":[ "city" ], "unique":false} ], "vertexlabels": [ {"name": "location"} ] } ] 更新schema

2. metagraph的schema设计

2.1 schema的设计。

参考IBM bluemix的schema设计titan的schema定义设计出来的schema。

  1. [
  2. {
  3. /*顶点标签的定义。*/
  4. "vertexlabels": [
  5. {
  6. "name": "location",
  7. /* 支持过期时间,单位为秒*/
  8. "ttl":"1000"
  9. },
  10. {
  11. "name":"god"
  12. }
  13. ],
  14. /*边标签的定义。*/
  15. "edgelabels": [
  16. {
  17. "multiplicity": "simple",
  18. "name": "route"
  19. },
  20. {
  21. "multiplicity": "simple",
  22. "name": "create",
  23. "ttl":"5000"
  24. }
  25. ],
  26. /*属性定义。*/
  27. "propertykeys": [
  28. {
  29. "cardinality": "single",
  30. "datatype": "string",
  31. "name": "name"
  32. },
  33. {
  34. "cardinality": "single",
  35. "datatype": "string",
  36. "name": "description"
  37. },
  38. {
  39. "cardinality": "list",
  40. "datatype": "string",
  41. "name": "oldname"
  42. },
  43. {
  44. "cardinality": "set",
  45. "datatype": "string",
  46. "name": "address",
  47. /*支持按照此字段排序*/
  48. "order":true
  49. }
  50. ],
  51. /*顶点索引。*/
  52. "vertexindexes": [
  53. {
  54. /* 建立关于citynamecomposite内部索引。 */
  55. "backend":"internal"
  56. "indextype": "composite",
  57. "name": "cityindex",
  58. "propertykeys": [
  59. "city","name"
  60. ],
  61. "unique": false
  62. },
  63. {
  64. /* 建立关于oldnamedescription外部的索引。 */
  65. "backend":"external"
  66. "indextype": "mixed",
  67. "name": "oldNameAndDescription",
  68. "mixIndexName":"search",
  69. "propertykeys": [
  70. "oldname","description"
  71. ],
  72. "unique": false
  73. }
  74. ],
  75. /*边索引。*/
  76. "edgeindexes": []
  77. }
  78. ]

2.2 schema的增删改操作定义

  1. {
  2. /*顶点标签增删改操作。*/
  3. "vertexlabels":
  4. {
  5. /*添加*/
  6. "add":{"name":"person"},
  7. },
  8. /*边标签增删改操作。*/
  9. "edgelabels":
  10. {
  11. /*添加*/
  12. "add":{"multiplicity": "simple","name": "addedEdgeLabels"},
  13. },
  14. /*属性增删改操作。*/
  15. "propertykeys":
  16. {
  17. /*添加*/
  18. "add":{"cardinality": "single","datatype": "string","name": "addedname"},
  19. },
  20. }

相关参考:
1. Titan支持的数据类型
2. IBM Graph bluemix schema
3. Titan index
4. Titan schema
5. Titan-1.0.0 官方文档

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注