A primary key is a column or set of columns that uniquely identifies each row in a relational table. In an ACH database, unique identifiers distinguish uploaded files, file records, batch records, entry details, and addenda records. section 5.1
Primary keys provide the stable identity that related tables can reference. Together with foreign keys, field constraints, and appropriate data types, they support querying and data integrity in the relational design. section 5.1 section 5.12
An ACH-oriented schema uses identifiers to distinguish records at several levels:
- An ACH file has an identifier that related upload and record data can reference. section 5.1
- Foreign keys connect related tables to unique data such as a primary key, while referential integrity helps prevent orphan records. section 5.1 section 5.12
ACH record relationships
A database can assign each record a UUID, then use fields such as file_header_id, batch_header_id, and entry_detail_id to connect records across tables. Deleting a parent batch can remove its dependent entries and addenda through referential-integrity rules. section 5.1
Listing 5.1 PlantUML definition of our database
@startuml #1
object ach_file_uploads { #2
ach_files_id: UUID #3
filename: VARCHAR(255) #3
file_hash: VARCHAR(32) #3
credit_total: NUMERIC(12,2) #3
debit_total: NUMERIC(12,2) #3
}
object ach_files {
ach_files_id: UUID
record_type: VARCHAR(1)
record_id: UUID
parsed: BOOLEAN
sequence: NUMERIC
unparsed_record: VARCHAR(94)
}
object ach_file_header_records {
record_id: UUID
fields for record type
}
object ach_batch_header_records {
record_id: UUID
file_header_id: UUID
fields for record type
}
object ach_entry_detail_ppd_records {
record_id: UUID
batch_header_id: UUID
fields for record type
}
object ach_addenda_ppd_records {
record_id: UUID
entry_detail_id: UUID
fields for record type
}
object ach_batch_control_records {
record_id: UUID
batch_header_id: UUID
fields for record type
}
object ach_file_control_records {
record_id: UUID
file_header_id: UUID
fields for record type
}
ach_file_uploads::ach_files_id <-- ach_files::ach_files_id #4
#4
ach_files::record_id <-- ach_file_header_records::record_id #4
ach_files::record_id <-- ach_batch_header_records::record_id #4
ach_files::record_id <-- ach_entry_detail_ppd_records::record_id #4
ach_files::record_id <-- ach_addenda_ppd_records::record_id #4
ach_files::record_id <-- ach_batch_control_records::record_id #4
ach_files::record_id <-- ach_file_control_records::record_id #4
#4
ach_batch_header_records::file_header_id ->
ach_file_header_records::record_id #4
ach_entry_detail_ppd_records::batch_header_id ->
ach_batch_header_records::record_id #4
ach_addenda_ppd_records::entry_detail_id ->
ach_entry_detail_ppd_records::record_id #4
ach_batch_control_records::batch_header_id -->
ach_batch_header_records::record_id #4
ach_file_control_records::file_header_id -->
ach_file_header_records::record_id #4
#4
@enduml #5
Inspect the PlantUML definition to see primary-key-style record identifiers and the foreign-key fields linking ACH tables. section 5.1




















