I am currently trying to improve the design of an old db, and I have the following situation.
I currently have a SalesLead table in which we store a LeadSource.
Create Table SalesLead( .... LeadSource varchar(20) .... )
Data sources are useful in a table.
Create Table LeadSource ( LeadSourceId int, LeadSource varchar(20) )
And so I just want to create a foreign key from one to another and delete the irregular column.
All standard things, hopefully.
Here is my problem. I can't seem to get away from the question that instead of writing
SELECT * FROM SalesLead Where LeadSource = 'foo'
Which is very clear, I now have to write
SELECT * FROM SalesLead where FK_LeadSourceID = 1
or
SELECT * FROM SalesLead INNER JOIN LeadSource ON SalesLead.FK_LeadSourceID = LeadSource.LeadSourceId where LeadSource.LeadSource = "foo"
What happens if we ever change the contents of the LeadSource field.
In my application, when ever I want to change the value of SalesLead LeadSource, I do not want to update from 1 to 2 (for example), since I do not want developers to have to remember these magic numbers . Ides are arbitrary and must be preserved.
How to remove or deny dependency on them in the application code?
Change Languages whose solution will support
- .NET 2.0 + 3 (what is asp.net, vb.net and C # for)
- vba (access)
- db (MSSQL 2000)
Change 2.0 . The connection is fine, so "foo" can change on request to "foobar", and I don't want to iterate over requests.