Designers > K2 Studio > Working with SmartObjects > SmartObject Integration > SmartObject Properties Toolbar > SmartObject Keys | Send feedback |
The Key property identifies the field / property as unique which ensures that the contents of the property will always be unique and no two fields will contain the same data. The key is essential for indexing, and consuming the SmartObject in production systems. The SmartObject Key is closely tied to the Property type and the way in which the key can be used is dependant on the type selected. Two types of keys are available:
Feature | What it is |
---|---|
Autonumber Key | Only one Autonumber key can be assigned when the SmartObject is created |
AutoGuid | Only one AutoGuid key can be assigned when the SmartObject is created |
Composite Key * | The composite key allows for as many keys as there are properties in the SmartObject |
Boolean Key | The property type Yes / No or Boolean key is valid and can be used. It will however only allow a maximum of two entries into the SmartObject before an error is thrown. This key type should not be used as part of a composite key as it will impose the two entry only restrictions on the SmartIObject unless this is required |
* A property type Yes / No must not be used as a key when compiling a composite key |
The keys are assigned when the property is created and may be changed by using the Edit function to edit the property. Certain keys can only be used under certain circumstances, and the property type determines if or how the key is assigned by default or if it needs to be set manually.
For example If a property is defined the type AutoNumber, then by default this becomes a property assigned as a key and is created that way by default. This property cannot be changed from being a key field unless the category is changed to something else for example Text.. Since AutoGuid is very similar to AutoNumber, the same SmartObject cannot have a property of type AutoNumber and AutoGuid.
Property Type | Key Allocation | Usage | Configuration Options |
---|---|---|---|
Autonumber |
By default |
This key prevents the use of the property with composite keys. Once set the property type would need to be changed to change the Key setting as the check box will be disabled. |
This key cannot be disabled, and is enabled by default when the property type is assigned. |
AutoGuid |
By default, configurable |
This key prevents the use of the property with composite keys. Once set the property type would need to be changed to change the Key setting as the check box will be disabled. |
The key is enabled when the property type is assigned, and it can be disabled as a key. |
Date Time |
Set Manually |
These property types can be used as keys, however the content of the property would not be unique by default as it is entered manually by a save or write operation to the SmartObject and is not created by either SQL Server or a Mathematical Algorithm. These property types would typically be used to create composite keys, however using these types may not be advisable given the format that the content of the property field would be in; the data format may not be ideal for indexing and searching. When used as a composite key, there is no architectural limitation to the number of properties in the SmartObject that can be used as keys to create a composite key.
|
Since these Property types would necessarily be useful as keys, they are not set and enabling their status as a key is set manually by the user. |
![]() |
Best Practice: Good design practice would be to use a property type that has no business bearing on the contents of the SmartObject i.e. AutoNumber and AutoGuid. There are also security benefits when this is put into practice. |