G’s Weblog

August 19, 2007

The use of GUID instead of auto-increment index

Filed under: Uncategorized — dnasand @ 1:30 pm

I’m not a big fan of using an auto-increment index in my database tables. So the alternative? Using GUID (Globally Unique Identifier) instead of auto-increment indexes. It’s an unique 128-bit number that can be used to identify unique objects, database entries, … . When you open the registry of Windows you’ll see alot of GUID’s, they’re used to uniquely identify applications. In most of my application I use MS SQL databases. MS SQL has a datatype named ‘unique identifier‘ used to store a GUID. So it has integrated the use of GUID’s. Now the show how to generate a GUID in .NET, I’ll explain it with a code example in C#.

Generate GUID’s

Output:

GUID Output

So I use these globally unique identifier for unique indexing my database entries.

I love it, so you’ll love it…

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.