I've been revisiting why I've been doing certain things in SQL Server 2005 data modeling.
I've habitually used identities for table keys, making unique indexes for the actual data that should be unique instead of keying off that.
So, if I had a student table, I might have:
ID identity primary key,
StudentIdentifier char(8)
I'd put a unique index on StudentIdentifier since this is the code that the university would use to reference a student, but I'd store Student.ID in any tables that referenced Student.
Is using an autoNumber Identity field still a good practice in SQL Server (version 2005)?
Also -
I use int codes for lookup values and store those ints in the corresponding referencing tables.
For example, I might have a workflow table like this:
id statuscode DESCRIPTION
1 CIProgress CI Grade in Progress
2 Finalized Finalized
3 NeedsSingle Needs Single Read
4 NeedsFirst Needs First Read
5 SingleProgress Single Read in Progress
In a table that had a workflow attribute, I'd store the id (1) and then join against the workflow table to get the statuscode or description.
Is it okay to store the statuscode, for example, instead? How much efficiency am I gaining by using the int over a short code?
I've seen a lot of implementations in the 15 years since I started coding, and it occurs to me that maybe i'm taking old "rules" to heart without thinking about practice.