Table Relationships
Table Relationships
One of the most powerful features of AutoCRUD is the ability to create relationships between tables. This allows you to connect related data and build complex data models similar to relational databases.
Understanding Table Relationships
Table relationships in AutoCRUD allow you to:
- Connect records between different tables
- View related data in context
- Maintain data integrity
- Build sophisticated data models
- Reduce data duplication
Types of Relationships
AutoCRUD supports several relationship types:
One-to-Many Relationship
The most common relationship type, where one record in Table A can be linked to multiple records in Table B.
Example: A Customer (Table A) can have multiple Orders (Table B).
Many-to-Many Relationship
A relationship where records in both tables can link to multiple records in the other table.
Example: Students (Table A) can enroll in multiple Courses (Table B), and each Course can have multiple Students.
One-to-One Relationship
A relationship where one record in Table A corresponds to exactly one record in Table B.
Example: An Employee (Table A) has one detailed Profile (Table B).
Creating Table Relationships
Step 1: Add a Link Field
- Open the table where you want to create the link
- Click + Add Field
- Select Link to Another Record as the field type
- Choose the table you want to link to
- Configure the relationship settings:
- Relationship name
- Field names in both tables
- Reciprocal field settings
- Click Save to create the relationship
Step 2: Configure Reciprocal Field (Automatic)
When you create a link field, AutoCRUD automatically creates a reciprocal field in the linked table:
- For One-to-Many: Creates a “Many” field in the linked table
- For Many-to-Many: Creates another “Many” field in the linked table
- For One-to-One: Creates a “One” field in the linked table
You can rename these reciprocal fields to better describe the relationship.
Working with Linked Records
Adding Links Between Records
To link records together:
- Open the record you want to link from
- Click in the link field cell
- Search for or select the record(s) you want to link to
- Click outside the cell to save
Viewing Linked Records
When viewing a record with links:
- The link field shows the linked records
- Click on a linked record to expand details
- Use the “+” icon to add more links
- Use the “x” icon to remove links
Expanding Linked Records
To see more details about linked records:
- Click on the linked record
- Select Expand Record to see full details
- Navigate between linked records using the arrows
Advanced Relationship Features
Lookup Fields
Lookup fields display information from linked records directly in your table:
- Add a new field to your table
- Select Lookup as the field type
- Choose the link field to use for the lookup
- Select which field from the linked table to display
- Configure display options
Example: In an Orders table with a link to Customers, add a lookup field to display the Customer’s email or phone number directly in the Orders table.
Rollup Fields
Rollup fields perform calculations on linked records:
- Add a new field to your table
- Select Rollup as the field type
- Choose the link field to use for the rollup
- Select which field from the linked table to aggregate
- Choose the aggregation function (Sum, Average, Count, etc.)
Example: In a Projects table with links to Tasks, add a rollup field to count the total number of tasks or sum their estimated hours.
Filtering Linked Records
When adding links, you can filter which records are available to link:
- Click in a link field
- Use the filter option in the record selector
- Set conditions to narrow down the available records
- Select from the filtered list
Best Practices for Table Relationships
Data Model Planning
- Plan your data model before creating complex relationships
- Diagram your tables and their connections
- Consider what types of queries you’ll need to perform
- Think about data integrity and maintenance
Naming Conventions
- Use clear, descriptive names for link fields
- Name link fields based on the relationship they represent
- Be consistent with naming patterns across your workspace
- Consider using prefixes for related fields
Performance Considerations
- Avoid creating unnecessary relationships
- Be cautious with deeply nested lookups and rollups
- Consider breaking very complex relationships into simpler ones
- Use filters to limit the number of linked records when possible
Common Use Cases
Customer Relationship Management (CRM)
- Customers linked to Orders
- Contacts linked to Companies
- Activities linked to Customers
- Products linked to Orders
Project Management
- Projects linked to Tasks
- Tasks linked to Team Members
- Projects linked to Clients
- Resources linked to Tasks
Inventory Management
- Products linked to Categories
- Products linked to Suppliers
- Orders linked to Products
- Warehouses linked to Inventory Items
Troubleshooting Relationships
Common Issues
Issue: Cannot see reciprocal field Solution: Check if the field was renamed or hidden; unhide the field in the field settings
Issue: Lookup or rollup field not updating Solution: Refresh the view or check if the relationship is set up correctly
Issue: Difficulty selecting the right records to link Solution: Use filters or improve naming conventions for clearer identification
Next Steps
Now that you understand table relationships, learn about: