Change Password

Input error
Input error
Input error
Submit

Change Nickname

Current Nickname:
Submit
v4.0

CRUD Metadata

Unique Identifier

Ultipa Graph system provides two types of unique identifiers: UUID and ID. UUID is of int64 type with the property name _uuid, it yields the highest efficiency when querying. ID is stored as a string with the maximum length of 128, and the property name is _id, ID is supported by node only and can be used to represent some actual meaning of the node, such as card number, employee number, etc.

The UUID and ID of nodes in a GraphSet keep a one-to-one mapping relationship.

In normal cases, the oder of query efficiency in Ultipa Graph system is: UUID > ID > Index/LTE

Insertion

Insert

Insert means to insert new node/edge data in the current GraphSet; properties carried in the data will be given the value directly, while those not will be left as an empty string, null or 0 based on their data type.

Insertion will insert one or multiple nodes/edges in the current GraphSet:

  • Insert nodes: specify UUID and/or ID in the data, or leave them auto-generated by the system; the operation fails if the specified UUID or ID already exists in the GraphSet.
  • Insert edges: specify UUID in the data, or leave it auto-generated by the system; the operation fails if the specified UUID already exists in the GraphSet; the operation also fails if the start/end node of the edge is not specified or if the start/end node doesn't exist in the GraphSet.

Syntax:

  • Command: insert().into(@<schema>)
  • Parameter: nodes() or edges()
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias supported, structure type is NODE or EDGE
// To insert nodes of a certain schema in the current graphset
insert().into(@<schema>)
  .nodes([				// Square brackets can be omitted if inserts only one node
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])
  
// To insert edges of a certain schema in the current graphset, must carry _from and _to, or must carry _from_uuid and _to_uuid
insert().into(@<schema>)
  .edges([				// Square brackets can be omitted if inserts only one edge
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])

Example: Insert two nodes into @account with names "Graph", "Database" and account No. U001, U002; check the UUID generated by the system

insert().into(@account)
  .nodes({_id: "U001", name: "Graph"}, {_id: "U002", name: "Database"}) as nodes
return nodes._uuid

Note: In the above node insertion operation, account No. is a string and can be stored in ID.

Example: Insert an edge into @transaction with transaction No. TRX001, amount 100, transaction time 2021-01-01 09:00:00, from card C001 to card C002; check the UUID generated by the system

insert().into(@transaction)
  .edges({no: "TRX001", 
          _from: "C001", 
          _to: "C002", 
          amount: 100, 
          time: "2021-01-01 09:00:00"
  }) as edges
return edges._uuid

Note: In the above edge insertion operation, the transaction No. is a string and needs to be stored in a user-defined string-type property no, because ID is not supported by edges; query for user-defined properties can be sped up via index or LTE.

Overwrite

Overwrite means to update or clear values of properties other than UUID and ID; properties carried in the data will be updated, while those not will be left as an empty string, null or 0 based on their data type.

Overwriting will insert or overwrite one or multiple nodes/edges in the current GraphSet:

  • Overwrite nodes: specify existent UUID or ID in the GraphSet, or both that match the correspondence in the GraphSet; the operation fails when the specified UUID and ID pair violates the mapping relationship in the GraphSet; when either the specified UUID or ID or neither doesn't exist in the GraphSet, or neither of them is specified, the insertion operation will be triggered.
  • Overwrite edges: specify UUID; when the specified UUID doesn't exist in the GraphSet, or UUID is not specified, the insertion operation will be triggered; the operation fails if the start/end node of edge is not included or not existent.

Syntax:

  • Command: insert().overwrite().into(@<schema>)
  • Parameter: nodes() or edges()
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias supported, structure type is NODE or EDGE
// To overwrite nodes of a certain schema in the current graphset
insert().overwrite().into(@<schema>)
  .nodes([				// Square brackets can be omitted if overwrites only one node
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])
  
// To overwrite edges of a certain schema in the current graphset, must carry _from and _to, or must carry _from_uuid and _to_uuid
insert().overwrite().into(@<schema>)
  .edges([				// Square brackets can be omitted if overwrites only one edge
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])

Example: Given an account U001 named "test", overwrite the account if it already exists, otherwise insert the account; check the account information after the operation

insert().overwrite().into(@account)
  .nodes({_id: "U001", name: "test"}) as nodes
return nodes{*}

Example: Overwrite transaction edge of UUID = 1 with transaction No. TRX001 and from C001 to C003, or insert such an edge if not existing; insert another transaction edge with No. TRX003 and from C003 to C001 in the same UQL

insert().overwrite().into(@transaction)
  .edges([
  	{no: "TRX001", _from: "C001", _to: "C003", _uuid: 1},
  	{no: "TRX003", _from: "C003", _to: "C001"}
])

Upsert

Upsert means to update values of properties other than UUID and ID; only properties carried in the data will be updated, while those not will remain unchanged.

Upsertion will insert or update one or multiple nodes/edges in the current graphset:

  • Upsert nodes: specify existent UUID or ID in the GraphSet, or both that match the correspondence in the GraphSet; the operation fails when the specified UUID and ID pair violates the mapping relationship in the GraphSet; when either the specified UUID or ID or neither doesn't exist in the GraphSet, or neither of them is specified, the insertion operation will be triggered.
  • Upsert edges: specify UUID; when the specified UUID doesn't exist in the GraphSet, or UUID is not specified, the insertion operation will be triggered; the operation fails if the start/end node of edge is not included or not existent.

Syntax:

  • Command: upsert().into(@<schema>)
  • Parameter: nodes() or edges()
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias supported, structure type is NODE or EDGE
// To upsert nodes of a certain schema in the current graphset
upsert().into(@<schema>)
  .nodes([				// Square brackets can be omitted if upserts only one node
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])
  
// To upsert edges of a certain schema in the current graphset, must carry _from and _to, or must carry _from_uuid and _to_uuid
upsert().into(@<schema>)
  .edges([				// Square brackets can be omitted if upserts only one edge
    {<property1>:<value1>, <property2>:<value2>, ...},
    {<property1>:<value1>, <property2>:<value2>, ...},
    ...
  ])

Example: Given an account U001 with name "test", update the account if it already exists, otherwise insert the account; check the account information after the operation

upsert().into(@account)
  .nodes({_id: "U001", name: "test"}) as nodes
return nodes{*}

Example: Update transaction edge of UUID = 1 with transaction No. TRX001 and from C001 to C003, or insert such an edge if not existing; insert another transaction edge with No. TRX003 and from C003 to C001 in the same UQL

upsert().into(@transaction)
  .edges([
  	{no: "TRX001", _from: "C001", _to: "C003", _uuid: 1},
  	{no: "TRX003", _from: "C003", _to: "C001"}
])

Update

Command, Parameter

Update operations can update node and edge data in a single or batch manner in the current GraphSet. UQL finds the nodes and edges to be modified according to the filtering rules before modifying its properties except the unique identifiers _id and _uuid.

Syntax:

  • Command: update()
  • Parameter: nodes(<filter>) or edges(<filter>), set()
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias supported, structure type is NODE or EDGE

Update Node Data

// To update nodes in the current graphset
update().nodes(<filter>)
  .set({<property1>: <value1>, <property2>: <value2> ...})

Example: Update the balance of bank card C001 to 300

update().nodes({_id == "C001"})
  .set({balance: 300})

Example: Update the score of all bank cards @card to the value of level*balance

update().nodes({@card})
  .set({score: level * balance})

Example: Upgrade all bank cards @card at level 2 to the next upper level

update().nodes({@card.level <= 2})
  .set({level: level + 1})

Update Edge Data

When updating the start/end node (_from, _to, _from_uuid and _to_uuid) of edge, the new start/end node must exist in the GraphSet, otherwise the operation will fail. Ultipa system will automatically update _from_uuid when _from is updated and vise versa, and same for _to and _to_uuid. When modifying _from and _from_uuid at the same time but the two don't match the correspondence in the GraphSet, Ultipa system subjects to _from_uuid, and same for _to and _to_uuid.

// To update edges in the current graphset
update().edges(<filter>)
  .set({<property1>: <value1>, <property2>: <value2> ...})

Example: Update the amount of @transaction.no TRX001 to 100

update().edges({@transaction.no == "TRX001"})
  .set({amount: 100})

Deletion

Delete Data

Deletion operation deletes the nodes and edges that meet the filtering rules in the current GraphSet. Caution should be exercised when deleting data using sophisticated filters, as the deletion is irreversible. When deleting nodes, edges that are endpointed at those nodes will also be deleted by the system.

Syntax:

  • Command: delete()
  • Parameter: nodes() or edges()
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias not supported
// To delete nodes in the current graphset
delete().nodes(<filter>)
               
// To delete edges in the current graphset
delete().edges(<filter>)

Example: Delete node ID = C003

delete().nodes({_id == "C003"})

Example: Delete edges that start from node C004

delete().edges({_from == "C004"})

Example: Delete all bank card @cards at level 5 with balance of 0

delete().nodes({@card.level == 5 && @card.balance == 0})

Truncate

Truncate is the delete operation done against all or part of the nodes and edges in a certain GraphSet in the current Ultipa instance.

Syntax:

  • Command: truncate().graph()
  • Parameter: nodes() or edges() or omit
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias not supported
// To truncate all the nodes and edges in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>")

// To turncate all the nodes of certain schema in a certain graphset in the current Ultipa instance
truncate().graph("<graphSet>").nodes(@<schema>)
                                     
// To turncate all the edges of certain schema in a certain graphset in the current Ultipa instance
truncate().graph("<graphSet>").edges(@<schema>)

// To truncate all the nodes in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>").nodes("*")

// To truncate all the edges in a certain graphset in the current Ultipa instance
truncate().graph("<graphset>").edges("*")

Example: Erase all the data from GraphSet "test"

truncate().graph("test")

Example: Erase all edges from GraphSet "test"

truncate().graph("test").edges("*")

Compact

Compact is to clear some useless, redundant data in a certain GraphSet in the current Ultipa instance.

Syntax:

  • Command: compact().graph()
  • Parameter: Omit
  • Parameter Alias: Custom alias not supported
  • Statement Alias: Custom alias not supported
// To defragment a certain graphset in the current Ultipa instance
compact().graph("<graphset>")
Please complete the following information to download this book
*
公司名称不能为空
*
公司邮箱必须填写
*
你的名字必须填写
*
你的电话必须填写
*
你的电话必须填写