Relation Management
Relationship management allows you to establish relationships between different tables, creating connections between data. The system supports four types of relationships, meeting various complex data modeling needs.
Relationship Types
One to One Relationship
A one-to-one relationship indicates a one-to-one correspondence between records in two tables. For example, each user can only have one detailed information file, and each detailed information file belongs to only one user.
Example scenarios:
- User table and user details table
- Employee table and workstation table
One to Many Relationship
A one-to-many relationship indicates that one record in a table can be related to multiple records in another table. This is the most common type of relationship.
Example scenarios:
- Department and employees (one department has multiple employees)
- Order and order items (one order includes multiple products)
Many to Many Relationship
A many-to-many relationship indicates that records in two tables can be related to multiple records in each other. The system automatically creates a relationship table to manage this relationship.
Example scenarios:
- Student and course (one student can choose multiple courses, one course can have multiple students)
- Product and tag (one product can have multiple tags, one tag can apply to multiple products)
Reverse Relationship (Belongs To)
A reverse relationship is a special type of one-to-one/many-to-one relationship, used to indicate that one record in a table is related to one record in another table.
Setting Relationships
- Click the "Relationship" button on the table settings page
- Click "Create"
- Select the "Relationship Type"
- Set the target table and the field to be related
- Choose whether to automatically add a reverse relationship
- Click "Save"
Tip
It is recommended to use lowercase English for relationship names, separated by underscores.
Relationship Field Display
After setting up relationships, you can:
- In the field type, select "Relationship", and choose to display the corresponding relationship type
- Quickly jump to related records through the relationship field
- View related records on the record details page
Best Practices
- Reasonably choose the relationship type: Select the appropriate relationship type based on the actual business scenario
- Use meaningful field names: Set clear names for relationship fields, making them easy to understand
- Set appropriate display fields: Choose fields that can uniquely identify records as display fields
- Maintain relationships in a timely manner: Update relationship relationships when the data structure changes
Notes
- Relationship are virtual and do not affect physical tables
- Be cautious when deleting relationships, as it may affect views or fields that depend on that relationship
- Queries involving large amounts of relationship data may impact performance, suggesting reasonable use