Documentation
Getting Started
Data Grid
Modeling
Business Rules
Approvals
Users, Roles & Security
Administration
Integration & API
Installation
Migrating from MDS
Documentation/Architecture/Database Schema

Database Schema

Primentra creates 36 SQL Server tables, in nine groups. Every write goes through a stored procedure — the API never sends raw SQL.

Per-entity staging tables are not in this count. They are created on demand in the separate stg schema, one per staged entity.

Core data — the EAV model

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

Attributes.DataType is limited by a CHECK constraint to Text, Int, Decimal, DateTime, Domain and Boolean.

Users and permissions

TablePurposeKey columns
UsersUser accountsId, Email, DisplayName, PasswordHash, MustChangePassword, FailedLoginAttempts, IsActive, IsDeleted, UserType
RolesPermission rolesId, Name, IsAdmin, CanApprove
RoleMembersUser to role membershipRoleId, UserId
PermissionsPer-role accessRoleId, Scope, TargetId, Level, CanCreate, CanRead, CanUpdate, CanDelete, IsModerator, IsExplicit
ApiKeysAPI key credentials for the REST APIId, UserId, Name, KeyHash, KeyPrefix, ExpiresAt, LastUsedAt, CallCount

Permissions.Scope is model, entity or attribute. Users.UserType is standard or api.

Modeling extras

TablePurposeKey columns
EntityDerivedColumnsDerived column definitions (path traversal)Id, EntityId, DisplayName, AttributePath, SortOrder
DateTimeFormatsThe installation-wide date format libraryId, Name, Mask, SqlPattern, HasTime, IsSystem

Business rules

TablePurposeKey columns
BusinessRulesRule definitions per entityId, EntityId, Name, Template, Definition, RuleKind, Severity, Message, IsActive
RowValidationFailuresOne row per failing rule per data rowId, EntityRowId, BusinessRuleId, Severity, Message, AttributeName

RuleKind is validation or default. An absent RowValidationFailures row means the record passes.

Approval workflow

TablePurposeKey columns
ApprovalRequestsApproval requestsId, EntityId, SubmittedByUserId, Status, SubmitterNote, Version, PreviousRequestId
ApprovalRowsRow snapshots inside a requestId, ApprovalRequestId, EntityRowId, Operation, RowStatus, RowCode, SnapshotData
ApprovalReviewsReviewer decisionsId, ApprovalRequestId, ReviewedByUserId, Decision, Comment, FlaggedRowIds
EntityApproversPer-entity approver assignmentsEntityId, UserId, ReceivesEmail

Integration, staging and scheduling

TablePurposeKey columns
IntegrationViewsSQL view definitions for external systemsId, Name, EntityId, ViewType, ExcludedColumns, ColumnSnapshot
StagingImportTemporary rows for the model import wizardSessionId, EntityName, ModelName, RowData, Status
StagingConfigurationsStaging setup, one row per staged entityId, EntityId, IsEnabled, TableName, DefaultImportAction, DefaultMergeMode, SentinelText
StagingFieldRulesPer-attribute merge and error rulesId, EntityId, AttributeId, MergeMode, OnValidationError
StagingBatchesOne row per batch runId, EntityId, BatchTag, Status, TotalRows, SuccessRows, ErrorRows, HeartbeatAt
StagingErrorDetailsPer-row error detail for a batchId, BatchId, StagingRowId, AttributeName, ErrorCode, ErrorMessage
ImportDomainFKStagingUnresolved domain references during model importId, AttributeId, DomainEntityName, DomainEntityModelName
SchedulerConfigurationsPer-entity scheduling settingsId, EntityId, ProcessingMode, ScheduleType, IntervalMinutes, RunTimes, IsRunning, NextScheduledRun
SchedulerLogEvery dispatcher action per entityId, EntityId, EventTime, EventType, TriggerSource, RowsQueued, BatchId

Logs

TablePurposeKey columns
AuditLogBusiness event history (append-only)EntityId, EntityName, ModelName, Action, RecordCount, UserId, Comment, CreatedAt
ErrorLogServer-side technical errors (append-only)Timestamp, Level, Method, Path, StatusCode, Message, Stack

Settings

TablePurposeKey columns
AppSettingsApplication-wide configurationSettingKey, SettingValue
UserSettingsPer-user key-value preferencesUserId, SettingKey, SettingValue
UserFavoritesPer-user entity favoritesUserId, EntityId
UserHiddenEntitiesPer-user hidden sidebar entitiesUserId, EntityId

System

TablePurposeKey columns
SystemConfigInternal timestamps, such as the last cleanup runConfigKey, ConfigValue (DATETIME2), Metadata
SchemaVersionThe deployed schema versionVersion, UpdatedAt
ErrorCodesReference table for every error codeErrorCode, CodeType, Name, Category, Description, UsedIn

ErrorCodes.CodeType is Throw for stored procedure THROW numbers, or StagingBitmask for the bitmask values on a staging row.

Most tables carry CreatedAt and ModifiedAt with a GETUTCDATE() default. Append-only tables and simple link tables — AuditLog, ErrorLog, UserFavorites, UserHiddenEntities, EntityApprovers, ApprovalRows, EntityDerivedColumns — carry only a creation timestamp.

Foreign key cascade behavior

Stored procedures delete in the correct dependency order. The cascades below are defined at the database level as a safety net.

RelationshipOn delete
Entity → AttributesCASCADE
Entity → IntegrationViewsCASCADE
Entity → EntityApproversCASCADE
Entity → EntityDerivedColumnsCASCADE
Entity → BusinessRulesCASCADE
Entity → StagingConfigurations and StagingFieldRulesCASCADE
Entity → UserFavorites and UserHiddenEntitiesCASCADE
Attribute → EntityValuesCASCADE
Attribute → ImportDomainFKStagingCASCADE
Row → EntityValues and RowValidationFailuresCASCADE
Role → Permissions and RoleMembersCASCADE
User → RoleMembers, UserSettings, UserFavorites, UserHiddenEntities, EntityApproversCASCADE
Approval request → ApprovalRows and ApprovalReviewsCASCADE
Staging batch → StagingErrorDetailsCASCADE
Attribute → StagingFieldRulesNO ACTION — usp_Attribute_Delete clears the rules first
Business rule → RowValidationFailuresNO ACTION — usp_BusinessRule_Delete clears the failures first
Entity → ApprovalRequests, StagingBatches, SchedulerConfigurationsNO ACTION — the delete is blocked until history is cleared

EntityRows, Entities and Models have no cascade delete. SQL Server rejects a configuration where two cascade paths converge on the same table, so the stored procedures handle those in order instead.

`AuditLog` has no foreign key on `EntityId`. The audit log is a historical record, so the entity id is kept verbatim after the entity is deleted. A fresh install never creates the constraint, and an upgrade drops it if an older version left one behind.

Do not delete directly from the database

You can delete rows in SQL Server Management Studio, but do not do it in production:

  • No audit entry is written. The audit log only records actions that pass through the application. A direct DELETE FROM Entities leaves no trace of who deleted what.
  • Permissions become orphaned. Permissions.TargetId has no foreign key, so deleting an entity leaves permission rows pointing at nothing. They accumulate silently.
  • Staging and approval history blocks the delete. StagingBatches and ApprovalRequests reference Entities with NO ACTION, so a manual delete fails with a constraint error rather than doing anything useful.

If you must remove data at database level, call usp_Entity_Delete or usp_Model_Delete. They clean up in the correct order, handle permissions, and write an audit entry, all in one transaction.

Ready to get started?

Start managing your master data with Primentra today.

View Pricing
Database Schema | Architecture | Docs | Primentra