Two limitations of the linked tables in Anvil are that they are in one direction only and that they can’t be used in searches.
For example, you can create an SQL query that joins two or more tables, uses columns of one table in the filter and reads columns of another table. In such SQL query there is no “direction” in the link.
In Anvil instead, your project would know its products, but your products wouldn’t know their project. You could search for a project and find its products, but you can’t search for a product and find its projects. You would need to explicitly add a linked column in the other direction.
Because of these limitations, I have never used linked tables. I have used either tons of simple object columns or columns with ids. And then found the products of a project with a second query. A second query is usually only twice as slow (two queries rather than one), while a badly behaving query going wild on linked tables may be hundreds of times slower (one query that fetches thousands of useless rows).
Today there are accelerated tables. They are faster and they allow to specify what’s loaded immediately, which makes them even faster, so I may start using linked tables in the future.
But reducing the number of tables from 50 to 5 just using simple objects rather than linked tables will remain one of my main strategies. For example I have an app that has the Project → Trucks → Crates → Layers → Panels hierarchy. 5 panels sit on the same layer, 10 layers fill a crate, 5 crates fill a truck, 15 trucks make up a project. Using a well designed database I would have the following tables:
- Projects
- Trucks
- Crates
- Layers
- Panels
Instead I have only 1 Projects table with 3 simple object columns:
This is because I will never need to search a panel or a truck or a crate without knowing the project first. Every interaction with the app starts from the project. Once the project is selected, I may need to manage panels or crates or trucks. Each truck is a dictionary and has the list of crate ids (together with many other properties). Similarly, each crate is a dictionary and has the list of panel ids.
So my answer is yes, those links may work very well, and will do even better if you do good use of the q.fetch_only()
option. But it could be much better not to link the tables, or not to even have them and work with simple object columns instead.
It all depends on what you will need to search and how many items each category will have.