Properties are linked to a node or edge schema to define the attributes of the corresponding nodes or edges. For example, a node schema card may have properties balance and openedDate, while an edge schema transfers may have properties amount and time.
In UQL, the operator . is used to extract a property from a schema. The expression @<schema>.<property> specifies a certain property of a schema, such as @company.name.
Each node has two system properties serving as unique identifiers: _id and _uuid. The _id value can be manually assigned, ensuring distinct identification of nodes, while the _uuid value is always generated by the system.
System Property | Value Type | Description |
|---|---|---|
_id | string | A string-type (with a length of up to 128 bytes) unique identifier for a node. |
_uuid | uint64 | A numeric unique identifier for a node. |
Each edge has only the _uuid as its unique identifier, which is also generated by the system. Each edge connects a source node to a destination node, its _from/_to and _from_uuid/_to_uuid identify its two end nodes.
System Property | Value Type | Description |
|---|---|---|
_uuid | uint64 | A numeric unique identifier for an edge. |
_from | string | The _id of the source node of an edge. |
_to | string | The _id of the destination node of an edge. |
_from_uuid | uint64 | The _uuid of the source node of an edge. |
_to_uuid | uint64 | The _uuid of the destination node of an edge. |
To retrieve information about properties in current graphset:
UQL// Shows all properties show().property() // Shows all node properties show().node_property() // Shows properties associated with a specified node schema show().node_property(@card) // Shows all edge properties show().edge_property() // Shows properties associated with a specified edge schema show().edge_property(@transfers)
The information about properties is organized into different tables:
_nodeProperty (all properties) and _nodeProperty_shard_N (properties with data in one shard) tables._edgeProperty (all properties) and _edgeProperty_shard_N (properties with data in one shard) tables.Each table includes fields that provide essential details about each property:
Field | Description |
|---|---|
name | The property name. |
type | The property value type. |
lte | Whether the property is loaded to the shards' memory for query acceleration. |
read | Whether the current database user can read the property. 1 for true, 0 for false. |
write | Whether the current database user can write the property. 1 for true, 0 for false. |
schema | The schema that the property is associated with. |
description | The description given to the property. |
encrypt | The encryption method used for the property. |
You can create one or more properties using a single create() statement. Each property is specified by chaining a node_property() or edge_property() method. To encrypt a property, use the encrypt() method.
Syntaxcreate() .node_property(<schema>, "<propName>", <propValueType?>, "<propDesc?>").encrypt("<encMeth?>") .edge_property(<schema>, "<propName>", <propValueType?>, "<propDesc?>").encrypt("<encMeth?>") ...
| Method | Param | Description |
|---|---|---|
node_property() or edge_property() | <schema> | Specifies the node or edge schema (e.g., @user); @* denotes all node or edge schemas. |
<propName> | Property name. Naming conventions are:
| |
<propValueType?> | Optional. Property value type. When it is omitted, string is used by default. See all supported property value types. Note that the type cannot be modified after the property is created. | |
<propDesc?> | Optional. Description of the property. | |
encrypt() | <encMeth?> | Optional. Encrypts property values using one of the supported encryption methods: AES128 (default), AES256, RSA and ECC. |
The supported integral property value types include int32, uint32, int64 and uint64.
UQLcreate().node_property(@user, "age", uint32)
The supported decimal property value types include float, double, and decimal.
UQLcreate() .edge_property(@links, "distance", float) .edge_property(@links, "weight", "decimal(25,10)", "Weight of the relation")
The decimal(25,10) specifies a decimal type with a precision of 25 (total digits, excluding the decimal point) and a scale of 10 (digits after the decimal point). You may set the precision between 1 to 65, and the scale between 0 to 30. Specifically, decimal(<precision>, <scale>) must be declared within quotes.
The supported textual property value types include string and text, with string set as the default type. When defining a property as string, you can omit specifying the type during creation.
UQLcreate() .node_property(@post, "title") .node_property(@post, "content", text)
The supported temporal property value types include date, local datetime, local time, zoned datetime, zoned time, timestamp, datetime, duration(year to month), and duration(day to second).
UQLcreate() .node_property(@post, "createdOn", "local datetime", "When the post is created") .node_property(@post, "visibilityPeriod", "duration(year to month)", "When the post is published")
The supported boolean property value type is bool.
UQLcreate().node_property(@city, "isCapital", bool, "Indicates whether it is the capital city")
The supported spatial property value types are point and point3d.
UQLcreate().node_property(@city, "position", point, "Location of the city")
The supported record property value type is record.
UQLcreate().node_property(@product, "specs", record, "Specifications such as weight, color and warranty")
The supported binary property value type is blob.
UQLcreate().node_property(@user, "avatar", blob, "Avatar image file")
The supported list property value type is <subtype>[]. Supports all of the above types as subtypes, except for bool.
UQLcreate().node_property(@user, "interests", "string[]", "user interest tags")
The supported set property value type is set(<subtype>). Supports all of the above types as subtypes, except for bool.
UQLcreate() .node_property(@user, "heights", "set(float)", "Store user heights history as a set")
To create the property time for all edge schemas:
UQLcreate().edge_property(@*, "time", datetime)
To create the property password and encrypt it using AES256:
UQLcreate().node_property(@user, "password", string).encrypt("AES256")
You can modify the name and description of a property using the alter().node_property().set() or alter().edge_property().set() statement.
In the node_property() or edge_property() method, you can specify a particular property in the form of @<schema>.<property>, or target all properties with the same name in the form of @*.<property>.
To alter both name and description of the node property @user.name:
UQLalter().node_property(@user.name).set({name: "Name", description: "Full name"})
To alter name of all the edge properties time:
UQLalter().edge_property(@*.time).set({name: "createdOn"})
You can drop one or more properties using a single drop() statement. Each property is specified by chaining a node_property() or edge_property() method. When a property is dropped, all related data — including the property values, associated indexes, full-text indexes, and any LTE-ed values held in memory — are removed.
In the node_property() or edge_property() method, you can specify a particular property in the form of @<schema>.<property>.
To drop the node property @user.name:
UQLdrop().node_property(@user.name)
To drop the edge property @links.time:
UQLdrop().edge_property(@links.time)
To drop multiple properties:
UQLdrop().node_property(@user.age).edge_property(@links.time)