Skip to main content

Employee Database Schema Reference

Summary

The current Employee Service model contains 13 persisted objects in its owned schema, 8 required child-to-root foreign keys, and 17 indexes. This reference inventories logical objects and important storage behavior without reproducing every internal column.

Audience

  • Backend developers and QA engineers
  • DevOps engineers, support engineers, and solution architects
  • Future schema-reference automation

Reference Content

Source-reference keys

KeyRepository-relative source
S1microservices/src/employee-service/Infrastructure/EmployeeDbContext.cs
S2microservices/src/employee-service/Infrastructure/Persistence.cs
S3microservices/src/employee-service/Domain/Employees/Employee.cs
S4microservices/src/employee-service/Domain/Organization/Organization.cs
S5microservices/src/employee-service/Infrastructure/Migrations/20260701173627_InitialEmployeeSchema.cs
S6microservices/src/employee-service/Infrastructure/Migrations/20260701181407_AddTimelineEventFields.cs
S7microservices/src/employee-service/Infrastructure/Migrations/EmployeeDbContextModelSnapshot.cs
S8microservices/src/employee-service/Infrastructure/PostgresEmployeeSearchProvider.cs
S9Data/AppDbContext.cs
S10Models/Labor.cs
S11Models/Department.cs
S12Models/Designation.cs
S13Models/EmployeeDocument.cs

DbContext inventory

ContextClassificationResponsibilityModel boundarySource
EmployeeDbContextEmployee-ownedEmployee aggregate, organization, history, audit, outboxDefault Employee schema; code-first migrationsS1
AppDbContextLegacy / TransitionalMonolith Labor, Department, Designation, EmployeeDocument and other monolith domainsSeparate Legacy model and migrationsS9

EmployeeDbContextFactory is a design-time factory, not a third persisted context. It supplies the Employee context with a null tenant abstraction for EF tooling (S2).

Persisted object inventory

CategoryLogical objectPurpose / ownerTenant scopeIDRelationshipsUniqueness / indexesHistory and lifecycleSource
Employee coreEmployeeWorkforce master aggregate root; Employee ServiceInteger tenant filterGUIDOwns inline Employment and 8 child collections; logical org/manager refsUnique tenant/code; tenant/status; tenant/departmentStatus-based soft deletion; produces timeline/audit/outbox participationS1, S3, S5
OrganizationDepartmentWorkforce organization unit; Employee ServiceInteger tenant filterGUIDLogical parent and head refsUnique tenant/codeActive/inactive; deactivation restricted when active Employees assignedS1, S4
OrganizationDesignationWorkforce designation; Employee ServiceInteger tenant filterGUIDLogical Department refUnique tenant/codeActive/inactive deactivationS1, S4
ProfileEmployee educationEducation collection childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplaced as aggregate collectionS1, S3, S5
ProfileEmployee experienceWork-history collection childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplaced as aggregate collectionS1, S3, S5
ProfileEmergency contactContact collection childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplaced as aggregate collectionS1, S3, S5
ProfileEmployee skillSkill collection childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplaced as aggregate collection; queried by searchS1, S3, S8
ProfileEmployee bank accountBank-detail collection childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplaced as aggregate collectionS1, S3, S5
ProfileEmployee document referenceDocument metadata/reference childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexReplace or append through aggregate methodsS1, S3, S5
HistoryEmployee noteEmployee note childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID indexAppend through aggregate methodS1, S3, S5
HistoryEmployee timeline entryWorkforce history childStamped integer tenant/filterGUIDRequired Employee FK, cascadeEmployee-ID and tenant/time indexesAppend from aggregate lifecycle or confirmed external-event methodS1, S3, S6
AuditEmployee audit logTechnical action/actor record; infrastructureInteger tenant filterGUIDTextual entity reference; no FKTenant/time indexIntended append-only; DB enforcement not foundS1, S5
MessagingOutbox messageLocal integration-delivery work item; shared model in Employee schemaOptional shared tenant concept; no user query filterGUIDNo business FKUnique event identity; status/time indexPending/failed/processed trackingS1, S2, S5

Employment is an owned value stored inline with Employee and is not a separate persisted object. Personal address and government-identifier concepts are also root values rather than separate objects.

Relationship inventory

RelationshipCardinalityDatabase FKDelete behaviorValidationSource
Employee → Education1:NRequiredCascadeAggregate stampingS1, S5
Employee → Experience1:NRequiredCascadeAggregate stampingS1, S5
Employee → Emergency Contact1:NRequiredCascadeAggregate stampingS1, S5
Employee → Skill1:NRequiredCascadeAggregate stampingS1, S5
Employee → Bank Account1:NRequiredCascadeAggregate stampingS1, S5
Employee → Document Reference1:NRequiredCascadeAggregate/document invariantsS1, S5
Employee → Note1:NRequiredCascadeAggregate note invariantS1, S5
Employee → Timeline1:NRequiredCascadeAggregate timeline invariantS1, S5
Employee → Employment1:1 ownedInline ownershipRoot lifecycleDomain valueS1, S3
Employee → Department/Designation/ManagerOptional referencesNone configuredNoneApplication/domain validationS1, validators
Department → Parent/HeadOptional referencesNone configuredNoneSelf-parent check only; broader hierarchy requires confirmationS1, S4
Designation → DepartmentOptional referenceNone configuredNoneApplication validation in Employee assignment pathsS1, S4
Audit → entityTextual referenceNoneNoneWriter-controlledS1, S2
Outbox → domain changeMessage correlation onlyNoneNoneContext event mappingS1

Index and constraint inventory

ObjectIndex/constraintUniquePurposeSource
EmployeeTenant + Employee codeYesTenant-scoped code uniquenessS1, S5
EmployeeTenant + statusNoStatus filteringS1, S5
EmployeeTenant + departmentNoDepartment filteringS1, S5
DepartmentTenant + codeYesTenant-scoped code uniquenessS1, S5
DesignationTenant + codeYesTenant-scoped code uniquenessS1, S5
Eight Employee child objectsEmployee ID, one eachNoRoot-to-child joinsS5
TimelineTenant + occurrence timeNoTenant history orderingS6
Audit logTenant + occurrence timeNoTenant audit lookupS1, S5
OutboxEvent identityYesPersisted event idempotencyS1, S5
OutboxStatus + occurrence timeNoOrdered relay work selectionS1, S5

This accounts for 17 indexes: 3 Employee, 2 organization, 8 child, 2 history/audit, and 2 outbox. Employee email, designation reference, and reporting-manager reference have no confirmed database index.

Migration inventory

OrderMigrationModel effectSource
1Initial Employee schemaCreates all 13 objects, initial indexes, and 8 child FKsS5
2Timeline event fieldsAdds timeline classification/metadata and tenant/time index; constrains two text propertiesS6
CurrentModel snapshotCurrent canonical EF model snapshotS7

Tenant-isolation inventory

PathBehaviorSource
Normal root/organization/audit queryCurrent-tenant or confirmed super-admin filterS1
Child queryShared generic child filterS1
Code/email existence checksIgnore filters plus explicit tenant predicateS2
Command persistenceTenant required by approved handlersapplication validators/handlers
Outbox processingOperational status query without end-user tenant filterS2

Transaction participant inventory

ParticipantLocal context commitNotesSource
Aggregate/organization changesYesTracked by Employee contextS1, S2
Timeline childrenYesAdded by aggregate methodsS3
Audit recordsYesAdded before unit-of-work saveS2
New outbox recordsYesAdded by context override before saveS1
Broker deliveryNoSeparate relay concernS2

Legacy and compatibility inventory

Legacy objectClassificationIdentifierEmployee Service equivalentSource
LaborLegacy / TransitionalNumericEmployee aggregate with GUIDS9, S10
DepartmentLegacy / TransitionalNumericDepartment aggregate with GUIDS9, S11
DesignationLegacy / TransitionalNumericDesignation aggregate with GUIDS9, S12
EmployeeDocumentLegacy / TransitionalNumeric associationsEmployee document reference metadata; not equivalent binary ownershipS9, S13

No Employee Service legacy-ID mapping object or backfill-state object appears in S1, S5, S6, or S7.

Source References

  • microservices/src/employee-service/Infrastructure/EmployeeDbContext.cs
  • microservices/src/employee-service/Infrastructure/Persistence.cs
  • microservices/src/employee-service/Infrastructure/PostgresEmployeeSearchProvider.cs
  • microservices/src/employee-service/Infrastructure/Migrations/20260701173627_InitialEmployeeSchema.cs
  • microservices/src/employee-service/Infrastructure/Migrations/20260701181407_AddTimelineEventFields.cs
  • microservices/src/employee-service/Infrastructure/Migrations/EmployeeDbContextModelSnapshot.cs
  • microservices/src/employee-service/Domain/Employees/Employee.cs
  • microservices/src/employee-service/Domain/Organization/Organization.cs
  • Data/AppDbContext.cs
  • Models/Labor.cs
  • Models/Department.cs
  • Models/Designation.cs
  • Models/EmployeeDocument.cs

See Also

Keywords

  • Schema inventory
  • Persisted objects
  • Relationship reference

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly