Question

I apologize in advance if this is a duplicate, I'm not sure exactly what I should be searching for.

Recently I watched this nifty video on Channel 9 about database federation in SQL Azure. At first I was surprised by the fact that identity columns are not supported by SQL Azure Federation, but it makes sense. If you have a table that is split between 2 (or more) databases, and they have no way to share their identity increment value, you could end up with 2 (or more) entities sharing the same primary key.

The video touched lightly on how to deal with this problem, mentioning using something like a Guid for a PK instead of an integer-based identity column. I know that at least MSSQL will create a clustered index on the PK by default, and it is bad to have a clustered index on a Guid (or uniqueidentifier) type. I'm by no means a relational expert, but I also believe that Guid's have a performance degradation when compared to integer-based types for PK-based lookups.

So this got me wondering, what might an integer-based PK pattern look like for a horizontally federated database look like? Back when I wrote old school EJB's and we needed to generate an integer for a primary key, we had to have a separate sequence lookup table to replace the rdbms identity/auto-increment features. I recall this was was painful, as many other things with EJB's were back then.

What are the commonly-accepted patterns, if any, for assigning primary keys in a horizontally federated database table? Given my current knowledge I would lean away from Guid's because of performance degradation, and I would lean away from sequential lookup indices because of development cost and added complexity (mostly development cost). What should I be leaning toward?

Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top