Ok.
Let’s say A is company, and C is template. It’s a many to many relationship. Companies and templates are both in the low thousands.
Previously, all companies got all templates, there was no link table. Now I am introducing a filter so companies get the templates appropriate to them. However this is only being implemented for some companies at the moment.
So if there are records in the link table with a specified company ID I want only those templates that apply to the company. If there are NO records in the link table with that ID then I want all the templates.
I could write a script to populate the link table with everything for all the companies that aren’t being filtered but that’ll result in millions of rows.
It has to be done every time a user hits a screen, and there are quite a few users. Performance is not critical but I don’t want to be creating temp tables and so on.