Skip to content

Database Schema

This document describes the database schema for our Test Case Management System. The schema is designed to manage organisations, projects, test cases, test runs, labels, and associated metadata.

You can import the _schema.sql file in dbdiagram.io for visualising relationships.


Tables Overview

The database consists of 16 tables that can be categorized as follows:

  1. Core Entities: users, organisations, projects, tests, runs
  2. Test Organization: sections, squads, labels
  3. Test Metadata: type, priority, platform, automationStatus, testCoveredBy
  4. Relationship Tables: labelTestMap, testRunMap, testRunsStatusHistory

Core Entities

Users

Users who interact with the test management system.

ColumnTypeConstraintsDescription
userIdintPK, AUTO_INCREMENTUnique user identifier
userNamevarchar(100)NOT NULLUser’s display name
emailvarchar(100)NOT NULL, UNIQUEUser’s email address
ssoIdvarchar(200)UNIQUESingle sign-on identifier
profileUrltextURL to user’s profile image
roleenumNOT NULL, DEFAULT userUser role: admin, user, or reader
tokenvarchar(500)UNIQUEAuthentication token
updatedByintFK to users.userIdUser who last updated this record
statusenumDEFAULT activeAccount status: active, archive, or delete

Organisations

Organizations that group projects and users.

ColumnTypeConstraintsDescription
orgIdintPK, AUTO_INCREMENTUnique organization identifier
orgNamevarchar(20)NOT NULL, UNIQUEOrganization name
createdByintFK to users.userIdUser who created the organization
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp

Projects

Projects that contain tests and test runs.

ColumnTypeConstraintsDescription
projectIdintPK, AUTO_INCREMENTUnique project identifier
projectNamevarchar(50)NOT NULLProject name
projectDescriptionvarchar(255)Project description
createdByintFK to users.userIdUser who created the project
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the project
testsCountintDEFAULT 0Count of tests in the project
runsCountintDEFAULT 0Count of test runs in the project
statusenumNOT NULL, DEFAULT ActiveProject status: Active, Archived, or Deleted
updatedOntimestampDEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the project

Indexes:

  • projectsNameIndex on projectName
  • projectsProjectIdIndex on projectId
  • projectOrgUniqueIndex (UNIQUE) on projectName and orgId

Tests

Test cases with detailed specifications.

ColumnTypeConstraintsDescription
testIdintPK, AUTO_INCREMENTUnique test identifier
sectionIdintFK to sections.sectionIdSection containing the test
projectIdintNOT NULL, FK to projects.projectIdProject that owns the test
titlevarchar(750)NOT NULLTest title
squadIdintFK to squads.squadIdSquad responsible for the test
priorityIdintFK to priority.priorityIdTest priority
typeIdintFK to type.typeIdTest type
automationStatusIdintFK to automationStatus.automationStatusIdAutomation status
testCoveredByIdintFK to testCoveredBy.testCoveredByIdTest coverage type
preConditionstextTest preconditions
stepstextTest steps
expectedResulttextExpected test results
assignedTointFK to users.userIdUser assigned to the test
createdByintFK to users.userIdUser who created the test
updatedByintFK to users.userIdUser who last updated the test
createdOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMPCreation timestamp
testStatusHistoryjsonHistory of status changes
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
editInfojsonDEFAULT (’[]‘)Edit history
platformIdintFK to platform.platformIdPlatform for the test
createdByNamevarchar(100)Name of creator (denormalized)
jiraTicketvarchar(100)Associated JIRA ticket
defectsvarchar(100)Associated defects
attachmentsvarchar(100)Associated attachments
statusenumNOT NULL, DEFAULT ActiveTest status: Active, Archived, or Deleted
referencetextReferences or links
additionalGroupstextAdditional grouping information
automationIdvarchar(100)Identifier for automation
descriptiontextTest description

Indexes:

  • projectSquadIndex on projectId and squadId
  • statusIndex on status
  • titleIndex on title

Runs

Test execution runs that group test results.

ColumnTypeConstraintsDescription
runIdintPK, AUTO_INCREMENTUnique run identifier
projectIdintNOT NULL, FK to projects.projectIdProject that owns the run
statusenumRun status: Active, Locked, Archived, or Deleted
runDescriptionvarchar(255)Run description
refrencevarchar(255)References (note: typo in schema)
createdByintFK to users.userIdUser who created the run
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the run
runNamevarchar(50)NOT NULLRun name
lockedByintFK to users.userIdUser who locked the run
lockedOntimestampTimestamp when run was locked

Indexes:

  • runProjectIndex on projectId and status

Test Organization

Sections

Hierarchical sections to organize tests.

ColumnTypeConstraintsDescription
sectionIdintPK, AUTO_INCREMENTUnique section identifier
sectionNamevarchar(250)NOT NULLSection name
sectionDescriptiontextSection description
parentIdintFK to sections.sectionIdParent section (for hierarchy)
editHistoryjsonDEFAULT (’[]‘)Edit history
projectIdintNOT NULL, FK to projects.projectIdProject that owns the section
createdByintFK to users.userIdUser who created the section
createdOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the section

Indexes:

  • sectionNameIndex on sectionName
  • sectionHierarchyUnique (UNIQUE) on parentId, sectionName, and projectId

Squads

Teams responsible for tests.

ColumnTypeConstraintsDescription
squadIdintPK, AUTO_INCREMENTUnique squad identifier
squadNamevarchar(100)NOT NULLSquad name
createdByintFK to users.userIdUser who created the squad
createdOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMPCreation timestamp
projectIdintNOT NULL, FK to projects.projectIdProject that owns the squad
editInfojsonDEFAULT (’[]‘)Edit history
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the squad

Indexes:

  • squadsSquadNameIndex on squadName
  • squadsProjectIdIndex on projectId
  • squadNameUnique (UNIQUE) on squadName and projectId

Labels

Tags for categorizing tests.

ColumnTypeConstraintsDescription
labelIdintPK, AUTO_INCREMENTUnique label identifier
labelNamevarchar(100)NOT NULLLabel name
labelTypeenumLabel type: System or Custom
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
createdByintFK to users.userIdUser who created the label
editHistoryjsonDEFAULT (’[]‘)Edit history
projectIdintNOT NULL, FK to projects.projectIdProject that owns the label
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the label

Constraints:

  • labelProjectunique (UNIQUE) on labelName and projectId

Test Metadata

Type

Types of tests.

ColumnTypeConstraintsDescription
typeIdintPK, AUTO_INCREMENTUnique type identifier
typeNamevarchar(30)NOT NULLType name
createdByintFK to users.userIdUser who created the type
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the type
projectIdintFK to projects.projectIdProject that owns the label

Indexes:

  • typeNameIndex on typeName

Priority

Priority levels for tests.

ColumnTypeConstraintsDescription
priorityIdintPK, AUTO_INCREMENTUnique priority identifier
priorityNamevarchar(30)NOT NULLPriority name
createdByintFK to users.userIdUser who created the priority
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the priority
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the priority

Indexes:

  • priorityNameIndex on priorityName

Platform

Platforms for tests.

ColumnTypeConstraintsDescription
platformIdintPK, AUTO_INCREMENTUnique platform identifier
platformNamevarchar(30)NOT NULLPlatform name
createdByintFK to users.userIdUser who created the platform
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the platform
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the platform
projectIdintFK to projects.projectIdProject that owns the label

Indexes:

  • platformNameIndex on platformName

AutomationStatus

Automation statuses for tests.

ColumnTypeConstraintsDescription
automationStatusIdintPK, AUTO_INCREMENTUnique automation status identifier
automationStatusNamevarchar(30)NOT NULLAutomation status name
createdByintFK to users.userIdUser who created the automation status
createdOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMPCreation timestamp
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the automation status
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the automation status
projectIdintFK to projects.projectIdProject that owns the label

Indexes:

  • automationStatusNameIndex on automationStatusName

TestCoveredBy

Coverage types for tests.

ColumnTypeConstraintsDescription
testCoveredByIdintPK, AUTO_INCREMENTUnique coverage type identifier
testCoveredByNamevarchar(30)NOT NULLCoverage type name
createdByintFK to users.userIdUser who created the coverage type
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the coverage type
orgIdintNOT NULL, FK to organisations.orgIdOrganization that owns the coverage type
projectIdintFK to projects.projectIdProject that owns the label

Indexes:

  • testCoveredByNameIndex on testCoveredByName

Relationship Tables

LabelTestMap

Maps labels to tests.

ColumnTypeConstraintsDescription
labelIdintNOT NULL, FK to labels.labelIdLabel identifier
testIdintNOT NULL, FK to tests.testIdTest identifier
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
createdByintFK to users.userIdUser who created the mapping
projectIdintNOT NULL, FK to projects.projectIdProject that owns the mapping
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
updatedByintFK to users.userIdUser who last updated the mapping

Constraints:

  • labelToTest (UNIQUE) on labelId and testId

Indexes:

  • labelTestMapLabelIdIndex on labelId

TestRunMap

Maps tests to runs and tracks test status.

ColumnTypeConstraintsDescription
testRunMapIdintPK, AUTO_INCREMENTUnique mapping identifier
runIdintFK to runs.runIdRun identifier
testIdintFK to tests.testIdTest identifier
projectIdintNOT NULL, FK to projects.projectIdProject that owns the mapping
isIncludedbooleanDEFAULT trueWhether the test is included in the run
statusvarchar(25)NOT NULL, DEFAULT UntestedTest status within the run
statusUpdatesjsonHistory of status updates
updatedByintFK to users.userIdUser who last updated the mapping
createdOntimestampDEFAULT CURRENT_TIMESTAMPCreation timestamp
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
commentvarchar(200)Comment on the test result

Indexes:

  • testRunMapRunIdIndex on runId
  • testRunMapStatusIndex on status

TestRunsStatusHistory

Historical record of test status changes within runs.

ColumnTypeConstraintsDescription
testRunsStatusHistoryIdintPK, AUTO_INCREMENTUnique history record identifier
runIdintFK to runs.runIdRun identifier
testIdintFK to tests.testIdTest identifier
statusvarchar(25)NOT NULLTest status
updatedByintFK to users.userIdUser who updated the status
updatedOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMP ON UPDATELast update timestamp
createdOntimestampNOT NULL, DEFAULT CURRENT_TIMESTAMPCreation timestamp
commenttextComment on the status change
totalTestCaseintDEFAULT 0Total number of test cases
passedTestCaseintDEFAULT 0Number of passed test cases
failedTestCaseintDEFAULT 0Number of failed test cases
untestedTestCaseintDEFAULT 0Number of untested test cases

Indexes:

  • testRunsStatusHistoryRunIdIndex on runId and testId

Entity Relationship Diagram

The database follows a relational model with these key relationships:

  • Organizations contain Projects
  • Projects contain Tests, Runs, Sections, Squads, and Labels
  • Organizations define metadata like Types, Priorities, Platforms, Automation Statuses, and Test Coverage Types
  • Tests are organized into Sections and can be assigned to Squads
  • Tests can have multiple Labels through LabelTestMap
  • Runs track test execution through TestRunMap and TestRunsStatusHistory
  • Users create and update records throughout the system