Properties
SQL - CREATE PROPERTY
Creates a new property in the schema. It requires that the type for the property already exist on the database.
Syntax
CREATE PROPERTY <type>.<property> [IF NOT EXISTS] <data-type> [OF <embd-type>] [<property-constraint>[,]*]
-
<type>Defines the type for the new property. -
<property>Defines the logical name for the property. -
<data-type>Defines the property data type. For supported types, see the table below. -
<embd-type>Defines the property’s embedded type (only for embedding property typesEMBEDDED,LIST,MAP, as well asLINK). -
<property-constraint>SeeALTER PROPERTY<attribute-name> * <attribute-value>-
mandatory <true|false>If true, the property must be present. Default is false -
notnull <true|false>If true, the property, must be present and cannot be null. Default is false -
readonly <true|false>If true, the property cannot be changed after the creation of the record. Default is false -
hidden <true|false>If true, the property is not added to the result set when using * in projections such as inSELECT * FROM; it is included whenSELECT FROMis used or if the hidden property is part of the projection list . Default is false -
min <number|string>Defines the minimum value for this property. For number types it is the minimum number as a value. For strings it represents the minimum number of characters. For dates is the minimum date (uses the database date format). For collections (lists, sets, maps) this attribute determines the minimally required number of elements. -
max <number|string>Defines the maximum value for this property. For number types it is the maximum number as a value. For strings it represents the maximum number of characters. For dates is the maximum date (uses the database date format). For collections (lists, sets, maps) this attribute determines the maximally allowed number of elements. -
regexp <string>Defines the mask to validate the input as a Regular Expression -
default <any>Defines default value if not present. Default isnull. -
IF NOT EXISTSIf specified, create the property only if not exists. If a property with the same name already exists in the type, then no error is returned
-
The hidden attribute is currently deactivated and has no function!
|
| When you create a property, ArcadeDB checks the data for property and type. In the event that persistent data contains incompatible values for the specified type, the property creation fails. It applies no other constraints on the persistent data. |
When constraints are set, such as mandatory, read-only, etc., it’s not possible to use the Gremlin syntax to add vertices and edges without incurring in a Validation exception.
The issue is that Gremlin API sets the properties after the creation of the vertex and edge.
|
Properties of the type LINK may have the value NULL, furthermore accessing a
LINK property which is not set results also in a NULL value.
|
A mandatory property generally cannot have a default value NULL (the default default value).
However, to force a default value NULL one can use ifnull(NULL, NULL) as explicit default value expression.
|
Examples
-
Create the property
nameof the string type in the typeUser:
ArcadeDB> CREATE PROPERTY User.name STRING
-
Create a property called
tagsin the typeProfileonly allowing list members of type string:
ArcadeDB> CREATE PROPERTY Profile.tags LIST OF STRING
-
Create the property
friends, as an embedded map:
ArcadeDB> CREATE PROPERTY Profile.friends MAP
-
Create the property
address, as an embedded document:
ArcadeDB> CREATE PROPERTY Profile.address EMBEDDED
-
Create the property
createdOnof type date with additional constraints:
ArcadeDB> CREATE PROPERTY Transaction.createdOn DATE (mandatory true, notnull true, readonly true, min "2010-01-01")
-
Create the property
secretof type string with hidden constraint:
ArcadeDB> CREATE PROPERTY Employee.secret STRING (hidden true, notnull true)
-
Create the property
salaryonly if it does not exist:
ArcadeDB> CREATE PROPERTY Employee.salary IF NOT EXISTS double
-
Create the property
hiredAtwith the time of creation being the default value:
ArcadeDB> CREATE PROPERTY Employee.hiredAt DATETIME (readonly, default sysdate('YYYY-MM-DD HH:MM:SS'))
For more information, see:
Supported Types
ArcadeDB supports the following data types for standard properties:
|
|
|
|
|
|
|
|
|
|
|
|
|
It supports the following data types for container properties:
|
|
|
SQL - ALTER PROPERTY
Change a property defined in the schema. The change is persistent.
Syntax
ALTER PROPERTY <type-name>.<property-name> <attribute-name> <attribute-value> [CUSTOM <custom-key> = <custom-value>]
-
<type-name>Defines the type where the property is defined -
<property-name>Defines the property in thetype-nameyou want to change -
<attribute-name>Defines the attribute you want to change. For a list of supported attributes, see the table below -
<attribute-value>Defines the value you want to set-
mandatory <true|false>If true, the property must be present. Default is false -
notnull <true|false>If true, the property, if present, cannot be null. Default is false -
readonly <true|false>If true, the property cannot be changed after the creation of the record. Default is false -
hidden <true|false>If true, the property is not added to the result set when using * in projections such as inSELECT * FROM; it is included whenSELECT FROMis used or if the hidden property is part of the projection list. -
min <number|string>Defines the minimum value for this property. For number types it is the minimum number as a value. For strings, it represents the minimum number of characters. For dates is the minimum date (uses the database date format). For collections (lists, sets, maps) this attribute determines the minimally required number of elements. -
max <number|string>Defines the maximum value for this property. For number types it is the maximum number as a value. For strings, it represents the maximum number of characters. For dates is the maximum date (uses the database date format). For collections (lists, sets, maps) this attribute determines the maximally allowed number of elements. -
regexp <string>Defines the mask to validate the input as a Regular Expression -
default <any>Defines default value if not present. Default isnull.
-
-
<custom-key>Name of the custom property to set -
<custom-value>Value for the custom property. All data types are supported as values.
The hidden attribute is currently deactivated and has no function!
|
A custom property can be deleted by setting its value to null.
|
Examples
-
Set the property 'subscribedOn' as mandatory:
ArcadeDB> ALTER PROPERTY User.subscribedOn MANDATORY true
-
Set the property 'createdOn' as read-only
ArcadeDB> ALTER PROPERTY User.createdOn READONLY true
-
Set the custom value with key 'description':
ArcadeDB> ALTER PROPERTY Account.signedOn CUSTOM description = 'First Sign In'
For more information, see:
SQL - DROP PROPERTY
Removes a property from the schema. Does not remove the property values in the records, it just changes the schema information. Records continue to have the property values, if any.
Syntax
DROP PROPERTY <type>.<property> [FORCE]
-
<type>Defines the type where the property exists. -
<property>Defines the property you want to remove. -
FORCEIn case one or more indexes are defined on the property, the command will throw an exception. UseFORCEto drop indexes together with the property
Examples
-
Remove the
nameproperty from the typeUser:
ArcadeDB> DROP PROPERTY User.name
For more information, see: