Data types¶
A data type, also called a value type, describes the values that an expression, variable, parameter, query result, or property can contain. When you create a graph type, you must specify the data type of each property value. The property value type determines what the property can store.
Not every value type can be used to define a node or edge property. For example, NODE and EDGE represent graph element references, and NULL represents the absence of a material value. They cannot be used as property types.
Categories¶
The following table groups the value types supported by NebulaGraph Database Developer Edition according to their primary usage:
| Category | Types | Property type | Primary usage |
|---|---|---|---|
| Basic property value types | Numeric, character string, Boolean, temporal, and vector | Yes | Node or edge properties, variables, parameters, and expressions |
| Container and composite value types | List, set, map, and spatial | Depends on the specific value type and whether the graph is persistent or temporary | Properties, variables, and expressions |
| Query result types | Path and record | No | Path matching, records, and table results |
| Table type | Table | No | Table variables, procedure parameters, and intermediate or query results |
| Graph element reference types | Node and edge | No | MATCH variables, procedure parameters, and query results |
| Immaterial value type | NULL | No | NULL expressions and type inference |
Property value type restrictions¶
This section covers only value types that can define node or edge properties. NODE, EDGE, PATH, RECORD, TABLE, and NULL cannot be used as property types and are therefore not included in the following table.
Temporary graphs in NebulaGraph Database Developer Edition are mutable temporary graphs that support data modification through DML statements (INSERT, SET, DELETE). However, mutable temporary graphs have the following restrictions on property data types:
| Data type | Persistent graph | Temporary graph | Notes |
|---|---|---|---|
| Set | ✅ | ❌ | Not supported as a temporary graph property type |
| Map | ✅ | ❌ | Not supported as a temporary graph property type |
Spatial (GEOGRAPHY) |
✅ | ❌ | Not supported as a temporary graph property type |
| List | ✅ | ✅* | Supported, but element types must also be of supported types (recursive check) |
| Other types | ✅ | ✅ | Numeric, string, boolean, temporal, vector, etc. are all supported |
Caution
If the graph type referenced by a temporary graph uses SET, MAP, or GEOGRAPHY type properties, an error will be raised when creating the temporary graph. Ensure that the graph type referenced by the temporary graph only contains supported property types.
For the index types supported by each property value type, see Property value types and index support.
Type conversion¶
GQL supports type conversion between different data types. For more information, see Cast value expression.
Operators¶
Operators are used to perform operations on data. The type of operation that you can perform often depends on the data type. For more information about the operators that can be used with each data type, see Operators.
Value constraints¶
After a data type is specified for a property value, you can add constraints on the values that can be stored in the property. Supported constraints include nullability, default value, and uniqueness.
Nullability¶
The data type of a property value can be nullable or non-nullable.
If a data type is nullable, the property value of the data type can be value NULL. NULL is a special value that indicates the absence of a value and is not the same as an empty string or zero. By default, the property value of a data type is nullable. For the distinction among the null value, the NULL type, and nullability, see NULL type.
If a data type is non-nullable, the property value of the data type CANNOT be the value NULL and must be a valid value.
For more information about how to specify the nullability of a data type, see CREATE GRAPH TYPE.
Default value¶
You can set a default value for a data type. If the data type of a property value is nullable, the default value is NULL. If the data type of a property value is non-nullable, the default value is the specified value.
For more information about how to specify the default value of a data type, see CREATE GRAPH TYPE.
Uniqueness¶
When you define the properties for a node type or an edge type, the property values may be subject to certain uniqueness constraints.
Note
Property names must be unique within a node type or an edge type.
If a property is solely declared as the PRIMARY KEY of a node type or the MULTIEDGE KEY of an edge type, the value of this property must be unique among all nodes of the node type or all edges of the edge type respectively.
If multiple properties are jointly declared as the PRIMARY KEY of a node type or the MULTIEDGE KEY of an edge type, the combinations of these property values must be unique among all nodes of the node type or all edges of the edge type respectively.
For more information about how to specify the primary key or multi-edge key, see CREATE GRAPH TYPE.