Introduction
Designing a well-structured database in ActivityInfo requires a deep understanding of how data points relate to one another. One of the most critical architectural decisions you will make is choosing between a form and a subform.
These elements define the organization of your data, the user entry experience, and the long-term management of relationships between datasets. This article explains the core definitions of forms and sub-forms, highlights their key differences, and provides guidance on when to use each.
What is a form?
A form is the fundamental building block of your database, acting as the structure used to collect and organize data. It is similar to a table in a spreadsheet or a page in a paper-based questionnaire.
Think of a form as a table where:
- Each record is a row
- Each field is a column
Example: A form named “Household Registration” can include fields such as:
- Household ID
- Head of Household Name
- Household Location
- Household Size
What is a subform?
A subform is a secondary form nested within another form (parent form), allowing you to collect multiple related data associated with a single parent record.
Instead of duplicating parent data across multiple records, subforms allow you to structure data more efficiently.
Key characteristics of subforms
- Cannot exist independently without a parent form
- Stores multiple related records for a single parent entry
- Maintains a one-to-many relationship
- Automatically linked to the parent record
Example: In the parent form Household Registration, a subform could be Household Members.
Each household (parent record) can have multiple household members (subform records) with fields such as:
- Member Name
- Date of Birth
- Gender
Key differences Between forms and subforms
| Feature | Form | Subform |
|---|---|---|
| Independence | Standalone | Requires a parent form |
| Purpose | Capture primary data | Capture child related or secondary data |
| Relationship | One record per entry | Multiple records per parent |
| Structure | Top level | Nested within a form |
| Example | Household | Members in the household |
When to use a form vs a subform
Use a form when:
- You are collecting primary data
- Each record stands alone
- When creating master data
Examples: Households, Schools, Health Facilities, Projects
Use a subfrom when:
- One record contains multiple related entries
- There is a clear parent-child relationship
- You are capturing time-based or longitudinal data
Examples:
- Household - Members
- Training - Participants
Why Subforms are Preferred Over Multiple Forms
Avoid creating separate forms for related data and linking them later; subforms are more efficient, as they keep related data structured within a single, coherent relationship.
Contextual data entry - Users can view and enter related records in one place. When opening a parent record, all associated subform entries are visible. This also eliminates the need to re-enter data that already exists in the parent record.
Simplified analysis - ActivityInfo automatically maintains the relationship between parent and child records. This makes aggregation straightforward, such as:
Total beneficiaries per household
Number of clinic visits per patient
Data integrity - Subform records cannot exist without a parent. This prevents orphaned records or inconsistent data. Additionally, if a parent record is deleted, all associated subform records are automatically deleted.
Hierarchy depth - Subforms can contain additional subforms (nested structure). This keeps structures simple to maintain usability especially during mobile data collection.
Conclusion
Understanding the difference between forms and subforms is fundamental to building effective databases in ActivityInfo.
- Use forms for independent, primary data
- Use subforms for related, repeating, or time based data
Applying this correctly results in:
- Better data quality
- Easier analysis
- Scalable systems
Well-designed forms improve data entry and reporting, and they also improve long-term maintenance as your database grows in size and complexity.