# tracking_kits - Data Models **Date:** 2026-03-13 ## Database Overview The project uses an Access database accessed through ADO. The authoritative schema history lives in [../Data/Migrations](../Data/Migrations). Repository SQL and migration names indicate a relational model centered on jurisdictions, kits, labels, contacts, settings, inkjet records, and custom office copy jobs. ## Core Tables ### Jurisdiction Primary fields observed in `JurisdictionRepository`: - `JCode` - `Name` - `Mailing_Address` - `CSZ` - `IMB` - `IMB_Digits` Later migrations indicate additional fields such as `Title`. **Role:** Master data for election jurisdictions and mailing identity information. ### Contact Created in migration 02 and joined from import/export logic. **Role:** Contact and addressing data associated with a jurisdiction. ### Settings Created in migration 03 and used by `SettingsRepository`. **Role:** Application configuration stored in the database, including STID-related values referenced by kit workflows. ### Kit Observed fields in `KitRepository` and migrations: - `ID` - `JobNumber` - `JCode` - `CreatedOn` - `LabelsPrinted` - `ExportedToSnailWorks` - `InkJetJob` - `JobType` - `Filename` - `Cass` - `Status` - `OutboundSTID` - `InboundSTID` - `OfficeCopiesAmount` **Role:** Central workflow entity representing a print/export job for a jurisdiction. ### KitLabels Created in migration 05 and counted in kit switchboard queries. **Role:** Individual label records associated with a kit. ### InkJetRecords Created in migration 09 and extended later with `KitLabelID` and `ColorId`. **Role:** Inkjet output records tied to kits and, later, colors and label relationships. ### CustomOfficeCopyJob Created in migration 18. **Role:** Tracks custom office copy proof/export work outside the standard label path. ### Colors Created in migration 19. **Role:** Lookup table used for purple-envelope color assignment and inkjet record coloring. ## Relationship Summary - `Kit.JCode` links kits to a jurisdiction. - `KitLabels.KitId` links labels to a kit. - `InkJetRecords.KitId` links inkjet records to a kit. - Later migrations add relationship and foreign-key support between key tables. - Contacts appear tied to jurisdictions through a jurisdiction code field. - Custom office copy jobs appear tied to jurisdiction and batch-processing state. ## Migration History Notable schema evolution based on migration names: 1. Create `Jurisdiction` 2. Create `Contact` 3. Create `Settings` 4. Create `Kit` 5. Create `Kit_Labels` 6. Alter `Kit` 7. Alter `Kit` labels/settings behavior 8. Add inkjet job to `Kit` 9. Create `InkJetRecords` 10. Add table relations 11. Add foreign keys 12. Add type to `Kit` 13. Add file/cass fields to `Kit` 14. Add STIDs to `Kit` 15. Add `KitLabelID` to `InkJetRecords` 16. Add title to `Jurisdiction` 17. Add office copies amount to `Kit` 18. Create `CustomOfficeCopyJob` 19. Create `Colors` 20. Add `ColorId` to `InkJetRecords` ## Data Access Patterns - Repositories use direct SQL strings and `Automapper.AutoMap`. - Search methods build `LIKE` queries from controller-provided values. - Pagination relies on `DAL.PagedQuery`. - Validation is light and often commented out in controller flows. ## Change Guidance - Treat migrations as the source of truth for schema evolution. - If a repository query changes shape, verify all views and export scripts using that entity. - Search both `App/` and `ImportService/` before renaming fields or changing status semantics. --- _Generated for brownfield analysis._