[thelist] Merge Duplicate Records in MySQL/PHP

r937 rudy at r937.com
Sun Jul 6 07:54:40 CDT 2008


> What is wrong with using an autoincremented ID?

it lulls you into a false sense of security

many people create one, thinking that this is all they need to do ("because
every table needs a primary key")

they forget to declare UNIQUE constraints for the "real" primary key (i call
it the "real" PK but the correct name is alternate key or candidate key)

thus, one of the more frequently asked questions on database forums is
"omg halp plz, how do i delete all but one of my duplicate rows??!!1!"

naturally, if you can identify a UNIQUE constraint, then this would serve
well as the PK

at that time, having an auto_increment as a surrogate PK is okay, especially
if there are going to be foreign keys referencing it (this is sometimes
problematic when the real PK contains large or multiple columns)

helps?

;o)





More information about the thelist mailing list