This is a great idea in practice, but it really points to how sql could improve.
You have a library of useful joins that you've checked for correctness. Saving the library as reusable code would be even more useful.
You have a library of useful joins that you've checked for correctness. Saving the library as reusable code would be even more useful.
I typically keep all JOINs I've ever used on that schema in a single file, one per line.
Before writing a new query I can just copy paste some JOINs, simply skimming through table names like lego bricks.
That way it's surprisingly easy to beam from domain problem to a new query that uses 10 or 20 tables.
I've just realized that it might be all archaic now, in LLM era.