What is the real diference between each one?
I think auto inc is easy to hack vs uuid
Uuid is slow than autoincrement in a query with to many records, but is there a huge difference in it?
What is the real diference between each one?
I think auto inc is easy to hack vs uuid
Uuid is slow than autoincrement in a query with to many records, but is there a huge difference in it?
An increment ID is not "easy to hack" in itself, it just provides entry-points that are obscured (but not entirely hidden) when you use a big random ID. There still needs to be badly implemented and exploitable software for there to be a real danger. As you can see in the URL in your address bar, this very site uses incremental IDs with no problems.
Apart from security thoughts though, a random unique ID is sometimes helpful when you don't want users to easily guess the URL of other (albeit public) content. For example, on a real estate site, you may not want to offer the possibility of going "up and down" in the IDs, looking at competitors' entries, even though they could find them all through searching. A bit of obstruction might be a good thing.
Why not use both? A numeric auto-increment key for speed in indexing and relations; a random UID for outside access.
some thoughts:
The primary key is very important from point of view of relational model
The smaller the PK, the better. That's why numeric PK is the best.
If your concern is that it's easy to "hack", you can add an additional UUID as a natural key
That's what I've seen in a couple of projects and it worked like a charm.
Take care of the LENGTH of your PK column... UUIDs and GUIDs are extremely long... strings. An INT or even BIGINT autoincement column can ensure uniqueness in a much smaller space.
BEWARE that autoincement columns have a few issues of their own around table management. If you truncate/drop-create tables then an auto-increment will be hard to maintain. ALSO, only 1 auto-increment column in MySQL is allowed for a single table.
If your data allows it, use some kind of HASH derived from the data for indexing and performance.