I have a table of city names that are referenced in another table by the primary key:
Table CityList, CityCode as int, City as nvarchar(25)
Other tables that use the CityCode to reference the city name, so to get an address for a customer record, I have to query the customer table for the city ID, then query the city table to get the city name. What I want to do is add a [CityName] field to my customer table to avoid this 2nd query. I did this with a query. Now I want to add triggers to provide for forward and backward compatibility.
Meaning, if I add (or update) a record with a program that uses CityCode, I want the trigger to update the CityName, and if I use a new program that updates the CityName, I need it to update the CityCode.
Any suggestions on the best way to implement this would be appreciated.
Table CityList, CityCode as int, City as nvarchar(25)
Other tables that use the CityCode to reference the city name, so to get an address for a customer record, I have to query the customer table for the city ID, then query the city table to get the city name. What I want to do is add a [CityName] field to my customer table to avoid this 2nd query. I did this with a query. Now I want to add triggers to provide for forward and backward compatibility.
Meaning, if I add (or update) a record with a program that uses CityCode, I want the trigger to update the CityName, and if I use a new program that updates the CityName, I need it to update the CityCode.
Any suggestions on the best way to implement this would be appreciated.