3 ms·
If you're using SQL Server, you can use indexed (materialized) views to enforce uniqueness across multiple tables. There's also a neat little trick with indexe
by lazulicurio 7y ago
If you're using SQL Server, you can use indexed (materialized) views to enforce uniqueness across multiple tables.
There's also a neat little trick with indexed views and cross join[1] that you can use for more complex constraints. I've never used it for anything more than reference tables, so I can't comment on its ability to scale.
[1] https://spaghettidba.com/2011/08/03/enforcing-complex-constraints-with-indexed-views/ https://spaghettidba.com/2011/08/03/enforcing-complex-constr...