We are trying to come up with a numbering system for the asset system that we are creating, there were several heated discussions on this topic in the office, so I decided to ask SO experts.
Given the database design below, that would be a better option.

Example 1: Using automatic surrogate keys.
Example 2: Using the generated PK program
================= ================== Road_Number(PK) Segment_Number(PK) ================= ================== "RD00000001WCK" "00000001.1"
( 00000001.1 means the first segment of the road, which increases each time you add a new segment, for example 00000001.2 )
Example 3: Using bits of both (adding a new column)
======================= ========================== ID(PK) Road_Number(UK) ID(PK) Segment_Number(UK) ======================= ========================== 1 "RD00000001WCK" 1 "00000001.1"
With a little background information, we will use the Road Number and Segment Number in reports and other documents, so they must be unique .
I always liked to keep simple things, so I prefer Example 1, but I read that you should not disclose your primary keys in reports / documents. So now I think more about the lines of Example 3.
I also tend to example 3, because if we decide to change the way we create the right amount of assets, he will not need to do cascading updates of the primary key.
What do you think we should do?
Thank.
EDIT: Thanks everyone for the great answers, helped me a lot.
database database-design primary-key
Nathan W Apr 01 '09 at 22:55 2009-04-01 22:55
source share