Your app’s database will probably have more than one table. You want to store tasks together with their tags, or maybe recipes and their authors. No matter what you store, it’s usually the case that some of the tables are quite interconnected and it would be perfect to get just the right data from both tables at the same time. That’s what SQL joins are for.

To make joins safe, it’s a good idea to use foreign keys. Otherwise you might end up trying to get a tag or a recipe which doesn’t exist… and that’s not all that good.

Finally, adding new columns or whole tables requires you to provide a migration to let the previous versions of the database upgrade themselves.

We’re building a task list application in this series, so we will add tags to the mix. They will be stored inside a separate table. Every task can have a tag and to get the tasks together with tags, we will utilize foreign keys and table joins. The user interface will also change a bit.

#flutter #dart #database #developer

Moor (Room for Flutter) –  Foreign Keys, Joins & Migrations – Fluent SQLite Database
21.50 GEEK