How to add relationship between table

To add relationship you must have at least one table for self relation. To add relations is open table details, In this tutorial is show how to relation for class and teacher. In this article teacher can teach many class. This is relation one to many. For do this in dynobird, open table class for open table details and then click column teacher_id for open details. in details of teacher id will be show foreign key check box. Click it for checked after check it will show ref table, ref column, relationship type, on delete and on update. Select teacher for relation of this table. And Ref. Column and Relationship will be auto fill as id and many to one

Building robust databases often involves establishing relationships between tables. In this tutorial, we'll guide you through the process of adding a relationship between tables using DynoBird Online Database Designer. For illustration, we'll use the example of creating a one-to-many relationship between the "Class" and "Teacher" tables.

Step 1: Preparing for Relationship:

Preparation two tables
  1. Ensure you have at least two tables, one of which will serve as the reference table for the relationship.

Step 2: Open Table Details:

Open details of class table
  1. Navigate to the table you want to create a relationship for; in our example, let's choose the "Class" table.
  2. Double-click on the "Class" table to open its details.

Step 3: Identify Foreign Key Column:

  1. Locate the column that will act as the foreign key. For our scenario, let's use the "teacher_id" column in the "Class" table.

Step 4: Enable Foreign Key:

Enable foreign key
  1. Click on the "teacher_id" column to open its details.
  2. Look for the "Foreign Key" checkbox and check it.

Step 5: Define Relationship Details:

  1. Once the foreign key checkbox is selected, additional fields will appear:
    • Ref Table: Choose the table to which the foreign key refers; in our case, select the "Teacher" table.
    • Ref Column: This will be auto-filled based on the primary key of the referenced table (usually "id" in many cases).
    • Relationship Type: Choose "Many to One" for a one-to-many relationship.

Step 6: Optional Settings:

  1. Optionally, set "On Delete" and "On Update" actions based on your requirements. These actions define how changes to the referenced table affect the current table.
Relation in design created


Congratulations! You've successfully created a relationship between the "Class" and "Teacher" tables in DynoBird. This one-to-many relationship enables a teacher to teach multiple classes, enhancing the overall structure of your database.

Loading comment system....