views:

123

answers:

1

Hello. While deciding upon the keys for a table, is it good to have an INT primary key (autoincrement) for the table and a GUID (in addition to the INT) for the scope of the database? Given that there will be more table DML statements it will be faster to operate on INT whereas if any pan-database DMLs statements are to be executed, GUID will come handy. Please note I am using MySQL, just in case if it matters. Please opine.

+2  A: 

I've done that before and it worked successfully: as you point out, using a GUID meant that we avoided conflicts when merging, say, data from one database with another, and the int provided us with efficient joining etc. I would just never use a GUID as a key when you're dealing with OLAP, as that will performance.

davek