Entities: Understanding Property Types
In the DataModel of our system, entities are composed of various properties, each serving a unique purpose to accurately model and manage data within applications. These properties are derived from a base Property
class, encompassing common characteristics crucial for data integrity and system functionality.
Common Property Attributes
All property types share foundational attributes, establishing a consistent framework for data representation:
- LogicalId: A unique identifier for the property.
- DataType: The type of data (e.g., String, Integer, Boolean) the property holds.
- Description: A brief description of the property's purpose.
- Required: Indicates whether the property must be provided.
- IsUnique: Ensures the property value is unique across all instances.
- AutoGenerate: Specifies if the property value is automatically generated by the system.
Specific Property Attributes and Examples
ArrayProperty
Represents an array of objects defined by a custom object type.
{
"ObjectTyeLogicalId": "CustomObjectTypeId"
}
BooleanProperty
Stores a Boolean value, optionally with a default setting.
{
"DefaultValue": true
}
CharProperty
Holds a single character, allowing an optional default character.
{
"DefaultValue": "A"
}
DateTimeProperty
Manages date and time information, with optional format specifications.
{
"DateAndTime": true,
"Format": "YYYY-MM-DD HH:mm:ss"
}
DecimalProperty
Handles decimal numbers, allowing for minimum, maximum, default values, and format specification.
{
"MinValue": 1.0,
"MaxValue": 100.0,
"DefaultValue": 50.0,
"Format": "#.##"
}
DoubleProperty
Stores double-precision floating-point numbers with constraints on values and format.
{
"MinValue": -100.0,
"MaxValue": 100.0,
"DefaultValue": 0.0,
"Format": "#.##"
}
EnumProperty
Links to a defined enumeration type.
{
"EnumTyeLogicalId": "StatusEnum"
}
GuidProperty
Stores globally unique identifiers, with an optional default value.
{
"DefaultValue": "00000000-0000-0000-0000-000000000000"
}
Int16Property, Int32Property, Int64Property
Represent integers of various sizes, including range and default value specifications.
{
"MinValue": -32768,
"MaxValue": 32767,
"DefaultValue": 0
}
PrimitiveArrayProperty
Defines an array of primitive types with a specified element type.
{
"ValueType": "string"
}
ObjectProperty
Represents a custom object type.
{
"ObjectTyeLogicalId": "CustomObjectTypeId"
}
StringProperty
Stores text data, with limitations on length and optional default values.
{
"MaxLength": 255,
"DefaultValue": "default text",
"RegularExpression": "[A-Za-z]+"
}
UInt16Property, UInt32Property, UInt64Property
Similar to their signed counterparts but store unsigned integers, with defined ranges and default values.
{
"MinValue": 0,
"MaxValue": 65535,
"DefaultValue": 123
}
TimeSpanProperty
Represents a time interval, with an optional default value.
{
"DefaultValue": "01:00:00"
}
Each property type is designed with specific attributes to cater to diverse data modeling needs, enhancing the flexibility and precision of the DataModel in applications.
Example Entity
The following JSON snippet provides an example of how these properties might be used within an entity definition:
{
"Entities": [
{
"LogicalId": "Author",
"Description": "Represents an author of posts.",
"Properties": [
{
"LogicalId": "Id",
"DataType": "Guid",
"Description": "Unique identifier for the Author.",
"Required": true,
"IsUnique": true,
"AutoGenerate": true
},
{
"LogicalId": "Name",
"DataType": "String",
"Description": "Name of the Author.",
"Required": true,
"IsUnique": false,
"AutoGenerate": false,
"MaxLength": 255
},
{
"LogicalId": "IsActive",
"DataType": "Boolean",
"Description": "Whether the Author is active or not.",
"Required": true,
"IsUnique": false,
"AutoGenerate": false,
"DefaultValue": true
}
]
}
]
}