Property is a component of schema that describes the data dimension of entities and relations in the graph. For example, node schema @card (Bank Card) has card number, balance, opening time and other node properties; edge schema @transaction (Transaction) has amount, transfer time and other edge properties.
Below are system properties inhered in each metadata:
- node: _id, _uuid
- edge: _uuid, _from, _to, _from_uuid, _to_uuid
Each schema may contain multiple custom properties. See Data Type for the supported data types of custom property.
The
@<schema>
and@<schema>.<property>
that appear in this article filter a specific schema and/or property in a graph model, which is different than the@<schema>
and@<schema>.<property>
that appear in an Ultipa filter which filter the metadata of a specific schema and/or property. Please read Filter | Operator - Conditional Operator - Schema Checker for more information.
Naming Conventions
Properties are named by developers. A same name can be shared between two properties of different schemas, but not between properties of a same schema.
- 2 ~ 64 characters
- Not allow to start with wave line '~'
- Not allow to contain back quote '`'
- Not allow to use Reserved Words listed in Basic Concepts
- (When containing characters other than letters, numbers and underscore, the property name should be wrapped with backquote '`' when being used in the UQL)
Show Property
Returned table name: _nodeProperty
and/or _edgeProperty
Returned table header: name
| type
| lte
| read
| write
| schema
| description
|extra
| encrypt
(the name, data type, if LTEed, if allow read, if allow write, schema, description,of precesion&scale of decimal and encryption method)
Syntax:
// To show properties of all schemas in the current graphset (node properties and edges properties in separated tables)
show().property()
// To show properties of all node schemas in the current graphset
show().node_property()
// To show properties of all edge schemas in the current graphset
show().edge_property()
// To show properties of a certain node schema in the current graphset
show().node_property(@<schema>)
// To show properties of a certain edge schema in the current graphset
show().edge_property(@<schema>)
Create Property
string is used by default if data type is omitted when creating property. Use encryption method AES128 to store this property (string or text) if parameter encrypt()
is included, or otherwise do not encrypt the property.
Syntax:
// To create a node property under a certain node schema in the current graphset
create().node_property(@<schema>, "<name>", <type?>, "<desc?>").encrypt()
// To create a node property under all node schemas in the current graphset
create().node_property(@*, "<name>", <type?>, "<desc?>").encrypt()
// To create an edge property under a certain edge schema in the current graphset
create().edge_property(@<schema>, "<name>", <type?>, "<desc?>").encrypt()
// To create an edge property under all edge schemas in the current graphset
create().edge_property(@*, "<name>", <type?>, "<desc?>").encrypt()
// To create multiple node/edge properties by using the four methods above
create()
.node_property(@<schema>, "<name>", <type?>, "<desc?>")
.node_property(@*, "<name>", <type?>, "<desc?>")
.edge_property(@<schema>, "<name>", <type?>, "<desc?>")
.edge_property(@*, "<name>", <type?>, "<desc?>")
Property type | Type string used when creating property |
---|---|
int32 | int32 |
uint32 | uint32 |
int64 | int64 |
uint64 | uint64 |
float | float |
double | double |
decimal | decimal(<precision>,<scale>),i.e., 'decimal(5,10)' where the range of precision is 1~65 and the range of scale is 0~30 |
string | string |
text | text |
datetime | datetime |
timestamp | timestamp |
point | point |
blob | blob |
list | int32[]、int64[]、uint32[]、uint64[]、float[]、double[]、string[]、text[]、datetime[]、timestamp[] |
set | set(int32)、set(int64)、set(uint32)、set(uint64)、set(float)、set(double)、set(string)、set(text)、set(datetime)、set(timestamp) |
The type string of decimal, list and set should be wrapped with quote
Example: Create node properties 'title' and 'description' under @course and edge property "time" for all edge schemas
create().node_property(@course, "title", string, "course name")
.node_property(@course, "description")
.edge_property(@*, "time", datetime)
Example: Create node properties 'fRate', 'tags' and 'records' under @forex
create().node_property(@forex, "fRate", "decimal(65,30)")
.node_property(@forex, "tags", "set(string)")
.node_property(@forex, "records", "string[]")
Analysis: When declaring as list, set and decimal types, <type>
should be wrapped with quote.
Example: Create node properties 'title' under @course, given that this property already exists
create().node_property(@course, "title")
Property exists!
Analysis: This query will give no return if using prefix TRY try create().node_property(@course, "title")
.
Alter Property (Name, Description)
Property type does not support modification.
Syntax:
// To modify the name, description of a certain node property under a certain node schema in the current graphset
alter().node_property(@<schema>.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain node property (if has) under all node schemas in the current graphset
alter().node_property(@*.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain edge property under a certain edge schema in the current graphset
alter().edge_property(@<schema>.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
// To modify the name, description of a certain edge property (if has) under all edge schemas in the current graphset
alter().edge_property(@*.<property>)
.set({name: "<new_name?>", description: "<new_desc?>"})
Example: Rename @card property 'sum' as 'balance'
alter().node_property(@card.sum)
.set({name: "balance"})
Example: Rename property 'time' as 'createTime' for all edges
alter().edge_property(@*.time)
.set({name: "createTime"})
Drop Property
Except for system properties _id
, _uuid
, _from
, _to
, _from_uuid
and _to_uuid
which are not allowed to be deleted, all the other properties of schema can be deleted. Deleting a property will also delete all kinds of indexes related.
Syntax:
// To delete a certain node property under a certain node schema from the current graphset
drop().node_property(@<schema>.<property>)
// To delete a certain node property (if has) under all node schemas from the current graphset
drop().node_property(@*.<property>)
// To delete a certain edge property under a certain edge schema from the current graphset
drop().edge_property(@<schema>.<property>)
// To delete a certain edge property (if has) under all edge schemas from the current graphset
drop().edge_property(@*.<property>)
// To delete multiple node/edge properties by using the four methods above
drop()
.node_property(@<schema>.<property>)
.node_property(@*.<property>)
.edge_property(@<schema>.<property>)
.edge_property(@*.<property>)
Example: Delete node property 'branch' under @card and edge property 'time' for all edges
drop().node_property(@card.branch).edge_property(@*.time)
Example: Delete @default edge property 'test'
drop().edge_property(@default.test)