Create Relation

Create Relation

Creating relationships between tables in a database facilitates efficient organization and manipulation of data. By linking tables, you can ensure data integrity, reduce redundancy, and simplify data querying.

To create a 1:1 or 1:N relationship, click the "Add Relation" icon and follow these steps:

  1. Select the Parent table and column.
  2. Choose the relationship type.
  3. Select the Child table and column.
  4. If the relationship is invalid, an error message will be displayed.
  5. If the relationship is valid, click the "OK" button to confirm.

Create Relation

Note

The M:N relationship will be automatically detected by the system and will be displayed on the right-hand side of the screen.

Once the relationship is created, it will appear in the Model section of the View Models.

1:1 Relationship

When you select a column in the 1:1 relationship table of the model, it generates an SQL JOIN operation between the two tables.

Relation in View Relation in View

1:M Relationship

When you select a column in the 1:M relationship table of the model, it generates a new SQL query to accommodate the relationship.

Relation in View Relation in View

M:N Relationship

An M:N (many-to-many) relationship is established between two tables, where a record in each table can reference multiple records in the other table. An example of this relationship is the UserRole association.

Relation in View

The model will display the M:N relationship if it exists. In the Create or Edit view, the M:N relationship will be represented as checkboxes.

Relation in View