You are right: Anvil directly supports a one-to-many relationship with its “Link” column type. “Many-to-many” has many possible variations, so it is something you should construct, in a manner that suits your uses.
When I think “many-to-many”, I think of it at the row level, not the table level: one row in Table 1 can be associated with many rows in Table 2, and vice versa. I believe this is what you have in mind, too.
It may not be good to think of Tables as “containing” rows from other tables. Some databases do allow that, but in Anvil, Tables don’t nest like that. Even at the row level, rows don’t “contain” other rows. Rather, they can contain references (“links” or “pointers”) to other rows. But the syntax, row_x['row_y']['price']
, can make it look like containment.
If you really do have a “containment” situation, a hierarchy of records, then there may be another option: the Simple Object column. A Simple Object value is essentially a JSON document: JSON objects/lists, that can literally contain other JSON objects/lists, nested as deeply as you want to go.
This specifies a third kind of entity: information (quantity, price, etc.) that is specific to the relationship between two specific rows. Standard relational database practice would create a Table (your Table 3) to contain such entities. That is perfectly sensible to me.
Table 3 would appear in the Anvil IDE just like any other Table in your App.
It is certainly possible for a row in Table 1 to contain links to corresponding rows in Table 3 (“backwards” links). Technically, however, that’s redundant. Keeping redundant data is likely more work than it is worth. It also makes new kinds of inconsistencies possible. On that basis, I would recommend against it.