I need some advice from experienced coders.
What I’m trying to do:
I have 3 tables - Countries, Cities & Languages.
All 3 tables are populated with data through 3 different api calls.
Each city belongs to a country. Each language belongs to several countries. Each country has it;s own languages.
Where I need help:
I don’t know what’s the best way to structure my tables for linking.
And I don’t know how to update the rows to link the tables because all three APIs are called separately.
What I can do:
I know how to update single data records like in this tutorial Anvil | News Aggregator.
That sounds like it should be a field in the city table that links to a single country row.
When you call the API to add a city, you’d need to give enough information to identify a country. Then in the API look up the country row and use it as the value for that linking field.
What makes sense to me is a multi-link field in country that links to all the languages that country uses. So a single field, but multiple links.
Updating a multiple-link field needs a little care. It looks like a list, but you can’t just append to it. The docs have an example: Anvil Docs | Links Between Tables
With a multiple link field you’d be able to add or remove languages from a country easily enough.
There are lots of other options, too.
2 Likes
Thanks @jshaffstall. I appreciate the advice.
It makes sense how you explained it.