Verifying Foreign Keys for Subsetting
Published 22 October 2025
Before running subsetting, verify your database has foreign key constraints defined.
Why Foreign Keys Matter
- Subsetting maintains referential integrity by following foreign key relationships
- Without FKs, the tool cannot determine which related records to include
- Missing FKs may result in orphaned records or incomplete data sets
Checking Your Database
Interpreting Results
Good: Most tables show ForeignKeyCount > 0
- Indicates relationships are defined
- Subsetting can maintain referential integrity
Warning: Many tables show ForeignKeyCount = 0
- Tables may be isolated with no relationships
- Subsetting may not include related data
- Consider defining manual relationships
If Foreign Keys Are Missing
If your database lacks foreign key constraints but tables are related, you can define manual relationships in the options file.
Manual relationships tell the subsetter how tables connect, even without database-level foreign keys.
See manualRelationships in the subsetting options file reference.
Next Steps
Once you've verified foreign keys:
- Getting Started with the Subset CLI - Run your first subset
- Create an empty target database - Prepare your target database