I'm trying to work out a way to prevent against a data integrity issue we've identified in our SQL Server 2012 DB. We implement the logic in the application, but I wanted to know if there was a way to lock it down at the DB.
Consider a business which provides our company with licenses we can print on our products. A product is always associated with one of these businesses. A product can optionally be associated with one of that businesses' licenses.
For example, consider the Business Marvel who provides us Licenses "Spiderman" and "Iron Man". We could print a Product (tshirt) with just "Marvel" on it (Business: Marvel, License: Null) or a Product with "Spiderman" on it (Business: Marvel: License: Spiderman).
Here's the schema:
The issue is how to ensure that a product associated with one business is not associated with a license for a another business.