Schema Diagrams #
The following subclass and ERD diagrams reflect entities in the Caseflow DB. You can also get the svg
version by clicking on the diagrams below. The svg
version of these diagrams facilitates text search (by opening the file in a web browser). These diagrams are automatically generated.
To Caseflow Engineers: These files are generated by running make docs
and are saved in your local docs/schema
directory (see
PR #16371). In that directory, the svg
version of these diagrams facilitates text search, and the dot
version allows you to manipulate the diagrams (for example using online Graphviz tools).
Caseflow Subclasses #
To help understand Caseflow’s schema, let’s start with DB tables that store records (a.k.a. DB rows) representing different ActiveRecord classes. The following diagram shows ActiveRecord classes (and subclasses) associated with certain DB tables.
- Classes associated with the same DB table are indicated with the same color – this color-coding is used in subsequent diagrams.
- These DB tables typically have a
type
column that indicates which ActiveRecord class is being represented by the record. - Blue-outlined rectangular nodes typically indicate abstract classes; while ellipses indicate concrete classes. The names of concrete classes are used to populate the
type
column. - Blue dotted edges/arrows indicate a subclass relationship.
Notable observations:
- The
Appeal
class is a subclass ofDecisionReview
.HigherLevelReview
andSupplementalClaim
are subclasses ofClaimReview
, which is a subclass ofDecisionReview
. This class hierarchy is mimicked byDecisionReviewIntake
,ClaimReviewIntake
,HigherLevelReviewIntake
andSupplementalClaimIntake
. However, all*Intake
records are stored in theintakes
table, whereasAppeal
,HigherLevelReview
, andSupplementalClaim
records are stored in separateappeals
,higher_level_reviews
, andsupplemental_claims
tables respectively. - There are many Tasks and some are grouped under an abstract class. For example, the
ColocatedTask
abstract class groups many*ColocatedTask
s. Similarly, there are abstract classesJudgeTask
,AttorneyTask
,MailTask
, andHearingAdminActionTask
. Vso
,FieldVso
, andPrivateBar
are types ofRepresentative
s, which is a subclass ofOrganization
.
( dot source)
Caseflow ERD #
This next diagram is an Entity-Relationship Diagram (ERD), showing how ActiveRecord classes are associated with each other via some *_id
column (e.g., foreign keys). The column name can be inferred from the edge label between two nodes. For example, a Hearing
record is associated with a HearingDay
via the hearings.hearing_day_id
column – in the DB, there is a foreign key constraint from the hearings
table to the hearing_days
table.
- To reduce clutter, some abstract classes are consolidated into blue-outlined rectangular nodes containing a title. For example, the node with title
appeal_type
refers to theAppeal
andLegacyAppeal
classes. In Rails, this is a polymorphic association – hence a foreign key constraint cannot be added to the DB. - Many classes are associated with the
User
class. To reduce clutter, aUser
class is not drawn in the diagram. Instead, this is indicated with the text “(assoc with User)” for relevant classes to avoid drawing too many overlapping edges. - Additional color-coding has been applied to categorize certain nodes:
- light blue: classes containing the string “Hearings” and classes related to hearings
- red: classes related to completion of a significant step (e.g.,
ClaimEstablishment
,JudgeCaseReview
,DecisionDocument
,DecisionIssue
,BoardGrantEffectuation
)
- Light gray rectangular nodes with 2 rectangular notches indicate join tables (e.g.,
OrganizationsUser
,RequestDecisionIssue
), which associate records in 2 other tables. - Purple edges/arrows indicate custom relationships manually added to the diagram.
- Solid blue edges/arrows indicate polymorphic relationships between tables.
Notable observations:
DecisionReviewIntake
(intakes
table) has a polymorphic association toDecisionReview
(abstract class) via thedetail_id
column. However, each type of intake class maps to a specific table.AppealIntake
class maps to theappeals
table (a.k.a.Appeal
class).HigherLevelReviewIntake
class maps to thehigher_level_reviews
table (a.k.a.HigherLevelReview
class).SupplementalClaimIntake
class maps to thesupplemental_claims
table (a.k.a.SupplementalClaim
class).RampElectionIntake
class maps to theramp_elections
table (a.k.a.RampElection
class).RampRefilingIntake
class maps to theramp_refilings
table (a.k.a.RampRefiling
class).
AppealStreamSnapshot
(hearing_appeal_stream_snapshots
table) maps aLegacyHearing
with aLegacyAppeal
. This association is also available in thelegacy_hearings
table viaappeal_id
. PerhapsAppealStreamSnapshot
should be deprecated.AppealStreamSnapshot
,AppealSeries
,LegacyHearing
,ClaimEstablishment
,Dispatch::Task
,EstablishClaim
, andWorksheetIssue
only exists to supportLegacyAppeal
s.CavcRemand
,AppellantSubstitution
, andDocketSwitch
reference two differentAppeal
s.Task
can beassigned_to
aUser
orOrganization
, as indicated by theassigned_to_type
column.- The nodes labeled
decision_review_type
,review_type
, anddecision_review_remanded_type
are synonyms. The naming difference is an artifact of different column names for the associations.
( dot source)
Caseflow ERD with Subclasses #
This next diagram combines the above two diagrams.
( dot source)