Tuesday, November 18, 2014

an interesting trick with a primary key

On an application I'm working upon there is a column with a numeric value which references the numeric key in another table. The other table has a plain-text explanation for what each of the ids (a 1, a 2, and a 3) mean in a different column, but this other column with varchar data is never joined into any queries. This separate table exists ONLY to restrain what the values back at the first table are and to make sure they are each a 1, a 2, or a 3! The one, two, and three are made sense of in code on the C# side where they are cast to an enum.

No comments:

Post a Comment