Documentation
Getting Started
Installation
Data Grid
Approvals
Administration
Account & Security
Integration & Staging
Architecture
Documentation/Architecture/Database Schema

Database Schema

Primentra uses 30 SQL Server tables, organized into seven groups.

Core Data — the EAV (Entity-Attribute-Value) model

TablePurposeKey columns
ModelsTop-level data domainsId, Name, IsActive, SortOrder
EntitiesEntity types within a modelId, ModelId, Name, TableName, SharedAcrossModels
AttributesColumn definitions per entityId, EntityId, DisplayName, DataType, DomainEntityId
EntityRowsOne record per master data rowId, EntityId, Code, Name, CreatedBy, ModifiedBy
EntityValuesOne value per attribute per rowEntityRowId, AttributeId, TextValue / IntValue / DecimalValue / DateTimeValue / DomainValue

Auth / RBAC

TablePurposeKey columns
UsersUser accountsId, Email, DisplayName, PasswordHash, IsActive, UserType
RolesPermission rolesId, Name, IsAdmin, CanApprove
RoleMembersUser ↔ role membershipRoleId, UserId
PermissionsPer-role CRUD accessRoleId, Scope, TargetId, CanCreate, CanRead, CanUpdate, CanDelete, IsModerator, Level (attribute scope)
ApiKeysAPI key credentials for external REST accessId, UserId, KeyHash, KeyPrefix, Label, ExpiresAt, CallCount, LastUsedAt

Features

TablePurposeKey columns
IntegrationViewsSQL view definitions for external systemsId, Name, EntityId, ViewType (hierarchy/flat)
AuditLogBusiness event history (append-only)EntityId, Action, UserId, RecordCount, CreatedAt
ErrorLogServer-side technical errors (append-only)Timestamp, Level, Method, Path, StatusCode
UserSettingsPer-user key-value preferencesUserId, SettingKey, SettingValue
UserFavoritesPer-user entity favoritesUserId, EntityId
UserHiddenEntitiesPer-user hidden sidebar entitiesUserId, EntityId
AppSettingsApplication-wide configurationSettingKey, SettingValue
EntityDerivedColumnsDerived column definitions (relational path traversal)Id, EntityId, DisplayName, AttributePath, SortOrder

Staging & Scheduler

TablePurposeKey columns
StagingImportTemporary staging for bulk importsSessionId, EntityName, RowData, Status
StagingConfigurationsStaging pipeline definitionsId, EntityId, SourceType, ConnectionString, IsActive
StagingFieldRulesPer-field mapping rules for staging pipelinesId, StagingConfigId, SourceField, TargetAttributeId, TransformType
StagingBatchesExecution history for staging runsId, StagingConfigId, Status, RowsProcessed, StartedAt, CompletedAt
StagingErrorDetailsPer-row error details for failed staging rowsId, BatchId, RowIndex, ErrorMessage, RowData
ErrorCodesLookup table for standardized staging error codesCode, Severity, Description
ImportDomainFKStagingTemporary staging for domain FK resolution during model importId, SessionId, EntityName, AttributeName, DomainEntityName
SchedulerConfigurationsScheduled job definitionsId, Name, CronExpression, IsActive, StagingConfigId
SchedulerLogExecution log for scheduled jobsId, SchedulerConfigId, Status, StartedAt, CompletedAt, Message

System

TablePurposeKey columns
SystemConfigLicense and trial stateConfigKey, ConfigValue (DATETIME2)
SchemaVersionCurrently deployed schema versionVersion, UpdatedAt

Approval Workflow

TablePurposeKey columns
ApprovalRequestsApproval workflow requestsId, EntityId, SubmittedByUserId, Status, SubmitterNote, Version
ApprovalRowsIndividual row snapshots within a requestId, ApprovalRequestId, EntityRowId, Operation, RowStatus, SnapshotData
ApprovalReviewsReviewer decisions on approval requestsId, ApprovalRequestId, ReviewedByUserId, Decision, Comment
EntityApproversPer-entity approver assignmentsEntityId, UserId, ReceivesEmail

All tables (except append-only logs) include CreatedAt and ModifiedAt columns with automatic GETUTCDATE() defaults. Every write to the database goes through stored procedures — the API never sends raw SQL.


Foreign key cascade behavior

When records are deleted through the application, stored procedures handle cleanup in the correct order. The following cascade actions are also defined at the database level as a safety net:

RelationshipOn delete
Entity deleted → its IntegrationViewsRemoved automatically (CASCADE)
Entity deleted → its AuditLog entriesEntityId set to NULL — entries are preserved
Entity deleted → its AttributesRemoved automatically (CASCADE)
Attribute deleted → its EntityValuesRemoved automatically (CASCADE)
Row deleted → its EntityValuesRemoved automatically (CASCADE)
Role deleted → its Permissions and RoleMembersRemoved automatically (CASCADE)
Entity deleted → its EntityApproversRemoved automatically (CASCADE)
Entity deleted → its EntityDerivedColumnsRemoved automatically (CASCADE)
Entity deleted → its UserHiddenEntitiesRemoved automatically (CASCADE)
User deleted → their UserHiddenEntitiesRemoved automatically (CASCADE)
Approval request deleted → its ApprovalRows and ApprovalReviewsRemoved automatically (CASCADE)

Some relationships cannot use cascades because SQL Server rejects configurations where two paths converge on the same table. EntityRows, Entities, and Models do not have cascade deletes for this reason — the stored procedures handle them in the correct dependency order.

Do not delete directly from the database

It is technically possible to delete rows directly in SQL Server Management Studio, but this is strongly discouraged in production:

  • No audit entry is written. Primentra's audit log only records actions that go through the application. A direct DELETE FROM Entities leaves no trace of who deleted what or when.
  • Permissions become orphaned. The Permissions table references models and entities by ID without a foreign key on TargetId. Deleting an entity directly leaves behind permission records pointing to a non-existent entity. These orphaned rows accumulate silently.
  • Audit log entries lose context. The ON DELETE SET NULL on AuditLog.EntityId keeps the entries but clears the entity reference, making historical records harder to attribute.

If you must remove data at the database level (for example, during emergency maintenance), use the stored procedures usp_Entity_Delete and usp_Model_Delete directly. They clean up in the correct order, handle permissions, and write an audit entry — all in a single atomic transaction.

Ready to get started?

Start managing your master data with Primentra today.

View Pricing