Relation Many to Many
Badaso provides a feature to relate data from a table to other tables. When creating a CRUD, the developer can link a field from one table to another by selecting which field to relate to, the relationship type and the destination table. if you want to use table polymorphism or use relationship Belongs To Many.
To make relation many to many, you must have minimal two table so that can make relation. This feature have two option:
- First, you can directly create a polymorphism table automatically
- Second, you can create your own polymorphism table
#
Set Relation Many to ManyFor use this feature, you can follow the step below:
Click button "set other relation".
Choice relation type, destination table, destination column, and destination column to display.
but, if you have table polymorphism, you can use that with feature advanced setting and choice polymorphism table.
After save, you have row like this
You can save and you have new polymorphism table.
#
Make table polymorphism yourselfFor example, we should create table foo and table boo have relation with table polymorphism. To create a polymorphism table, you can follow the steps below:
Before create table polymorphism, create table foo and table boo.
To make table polymorphism, Open database management, then click add.
Create a table name.
Create two fields with the conditions:
The first table name is the same as the first primary table with this format: firsttablename_id. example "foo_id".
The name of the second table is the same as the second primary table with this format: secondtablename_id. example "boo_id".
Field Type "Big Integer"
Check unsigned
In the "index" option, select "foreign", click the blue button.
First field relation with tabel primary
First field relation with tabel primary
A pop up will appear, select the primary table.
On the "field" menu, select "id".
On the type menu, select on delete and on cascade.
All fields will look like below.
Click the "accept" button and save