Click to See Complete Forum and Search --> : GUID's as Keys
rliq
May 22nd, 2006, 07:16 PM
.NET 1.x, C#, SQL 2000, ASP.NET and Windows Forms
I've come across 2 database applications recently (one I am currently taking ownership of) that use GUID's as primary keys to rows inv a table.
Apart from making them more secure by being harder to type in/remember, can anybody tell me a good reason (or two) for doing this?
Thanks
Rob
f_eriksen
May 24th, 2006, 06:30 AM
It is generally not a good idea to use as pk, due to its size etc..
but there are legitimate reasons for why one would use them, the one that comes to mind being consistency and uniqueness across several servers etc..
ovidiucucu
May 26th, 2006, 07:23 AM
Not only as a performance issue, but using GUIDs as primary key is not the best solution as long as there are other mechanisms to asure unique values like (depending on database type) sequences or auto-number fields.
hspc
June 2nd, 2006, 07:55 AM
Some advantages :
They are needed anyway in merge replication. So If you plan yo use merge replication you can consider using GUID as a PK as SQL server will add it anyway.
using GUID as a PK allows you to create the PK at the client side in a data entry from. This can improve performance as you don't have to store the master record , return its ID then save the details.
They are guaranteed to be usnique accross many databases.
Disadvantages :
Using GUID as a PK can slow performance a bit..
It is 4 times larger than int
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.