I wasn't sure how to ask this question and it's likely a simple answer.
I have two tables like this.
Office
------
PK OficeId
OfficeName
Location
--------
PK LocationId
FK OfficeId
And one table like this where I store related information.
PurchaseOrder
-------------
PK PurchaseOrderId
FK OfficeId
FK LocationId
So my database will contain a list of Offices that have locations. That's a 1 Office to multiple locations. Office could be company or what ever.
So when I insert a purchase order I wanted to store the OfficeId really for convience, but the OfficeId and LocationId must be a configuration that would satisfy the 1 to many relationship in the other tables. I understand that I could simply just store the LocationId and join inside a query and I might end up doing this, however wanted to ask some experts about this first.
I'm using SQL Server 2012. Is there a constraint to do this without creating a trigger that will simply check if that's a valid configuration?