Entity Structure
A comprehensive guide to defining and managing entity structures, encompassing data fields, relationships, and configuration options.
📄 Overview
The Entity Structure is the foundation of your application's data model. It defines how information is organized, stored, and related, enabling both the database schema and the user interface to work cohesively.
Each entity represents a discrete business object in your application domain, comprising fields that store data and relationships that connect to other entities. The structure design directly influences how data is presented, validated, queried, and maintained throughout the application lifecycle.
⚙️ Entity Configuration
Each entity has core configuration properties that define its behavior within the system.
Basic Settings
Property | Type | Description |
---|---|---|
Name | String | Unique identifier used in code and database. Must start with a letter and contain only letters, numbers, and underscores. |
Description | String | Optional descriptive text to explain the entity's purpose. |
OptimisticLockEnabled | Boolean | When enabled, prevents conflicting simultaneous updates by tracking record versions. |
FullTextSearchEnabled | Boolean | When enabled, allows configured string fields to be included in full-text search operations. |
🔧 Field Types
Entities are composed of fields with different data types, each with specific behavior and storage characteristics.
Primitive Data Types
Type | Storage | Usage |
---|---|---|
String | VARCHAR/TEXT | Text data with optional length constraint. Can be configured for full-text search. |
Int | INTEGER | 32-bit signed integer values. |
Long | BIGINT | 64-bit signed integer values for larger numbers. |
Decimal | DECIMAL | Fixed-precision decimal numbers for financial calculations. |
Double | DOUBLE | Double-precision floating point numbers for scientific calculations. |
Boolean | BOOLEAN | True/false values. |
DateTime | TIMESTAMP | Date and time values with timezone support. |
DateOnly | DATE | Date values without time component. |
TimeOnly | TIME | Time values without date component. |
Complex Data Types
Type | Storage | Usage |
---|---|---|
File | Special | File storage with metadata and content handling. |
Address | Special | Structured address data with map integration. |
User | Reference | Reference to system users with special UI handling. |
Role | Reference | Reference to system roles with special UI handling. |
🔄 Field Properties
Each field in an entity has properties that define its behavior, constraints, and appearance.
Field Configuration
Property | Applies To | Description |
---|---|---|
Name | All types | Unique identifier for the field within the entity. Must start with a letter and contain only letters, numbers, and underscores. |
DataType | All types | The data type of the field (see Field Types section). |
Description | All types | Optional descriptive text explaining the field's purpose. |
Required | All types | When enabled, the field must have a value (not null). |
ReadOnly | All types | When enabled, the field can be read but not modified after creation. |
Length | String | Maximum character length for string fields. |
IncludedInFullTextSearch | String | When enabled, this string field is included in full-text search operations (requires FullTextSearchEnabled on the entity). |
ItemTitle | String | When enabled, this field is used as the default display title for the entity in UI components. |
🔗 Relationships
Relationships connect entities to each other, establishing associations between data records.
Relationship Types
Type | Database Structure | Description |
---|---|---|
OneToOne | Foreign Key | Each record in the first entity corresponds to exactly one record in the second entity. |
OneToMany | Foreign Key | A single record in the first entity can be related to multiple records in the second entity, but each record in the second entity relates to only one record in the first. |
ManyToMany | Junction Table | Records in both entities can be related to multiple records in the other entity, creating a many-to-many relationship through a junction table. |
Relationship Properties
Property | Description |
---|---|
SourceFieldName | The field name on the source entity side of the relationship. |
TargetEntityName | The name of the target entity. |
TargetFieldName | The field name on the target entity side of the relationship. |
RelationType | The type of relationship: OneToOne, OneToMany, or ManyToMany. |
DeleteBehavior | Controls what happens to related records when a record is deleted: Cascade (delete related records), Restrict (prevent deletion if related records exist), or SetNull (set the foreign key to null). |
ManyToManyEntityName | For ManyToMany relationships, the name of the junction entity that connects the two main entities. |
🏷️ Annotations
Annotations provide a flexible tagging system for entity records, allowing users to add metadata and categorize data beyond the predefined field structure.
Annotation System Overview
Every entity in BijouCore can be enhanced with annotations, which function as a sophisticated tagging system. Annotations are displayed as colored tags in the UI and can be filtered, searched, and managed according to user permissions.
- Annotations are automatically included in all OData responses via the
$Annotations
field - Each annotation has a Type that defines its appearance (color, icon) and category
- Annotations can optionally include a Subject field for additional context
- Permissions for annotations follow the entity's read/write permissions
Annotation Types
Annotation types are managed through the Studio and define how annotations appear and behave.
Property | Description |
---|---|
Name | Display name of the annotation type |
Color | Tag color (e.g., blue, green, red, orange) |
Icon | Optional icon from the Tabler icon set |
IsUserDefined | Whether this is a user-created type (vs. system type) |
IsSoftDeleted | Soft delete flag for type management |
Using Annotations in the UI
- Entity Details Pages: Annotations appear as tags in the header card with inline subject text
- Data Tables: A dedicated "Tags" column shows all annotations for each record
- Creating Annotations: Click the tag+ button and select from available types
- Editing Annotations: Click on any tag to edit its subject text
- Deleting Annotations: Click the X icon on a tag (with confirmation)
API Access
Annotations can be accessed and managed through the OData API:
// Get entity - annotations are always included
GET /$odata/Customer('123e4567-e89b-12d3-a456-426614174000')
// Response includes $Annotations field:
{
"Id": "123e4567-e89b-12d3-a456-426614174000",
"Name": "Customer Name",
"$Annotations": [...]
}
// Create annotation
POST /$odata/Customer/{id}/annotations
{
"TypeId": "annotation-type-id",
"Subject": "Important customer note"
}
// Update annotation
PUT /$odata/Customer/{id}/annotations/{annotationId}
{
"Subject": "Updated note"
}
// Delete annotation
DELETE /$odata/Customer/{id}/annotations/{annotationId}
📂 Best Practices
Entity Naming
- Use PascalCase for entity names (e.g.,
CustomerOrder
) - Choose singular nouns rather than plurals (e.g.,
Product
notProducts
) - Be specific and avoid generic names (e.g.,
InvoiceItem
rather thanItem
) - Avoid abbreviations or acronyms unless widely understood
Field Naming
- Use PascalCase for field names (e.g.,
FirstName
) - For relationship fields, include the target entity name (e.g.,
CustomerAddress
) - For boolean fields, use prefixes like "Is", "Has", or "Can" (e.g.,
IsActive
,HasAttachments
) - Date fields typically end with "Date", "Time", or "At" (e.g.,
CreatedAt
,StartDate
)
Entity Structure
- Include a descriptive string field that can be used as the ItemTitle
- Enable OptimisticLockEnabled for entities that may be concurrently edited
- Enable FullTextSearchEnabled only when search across multiple string fields is needed
- Keep fields focused on a single responsibility; avoid overloading fields with multiple purposes
- Design relationships carefully, considering query patterns and data access needs