There are several entities that we want to hide from clients with an exact identifier - the main reason is that we do not want clients to know how many of them are in the database.
eg. from the URL, http: // mydomain / user / get / 27 , he says that this is the 27th user.
Therefore, I am implementing a solution that assigns a random identifier (which must be unique). In other words, instead of using a unique serial number, I am going for a unique solution without a sequence + random number.
eg. from the URL, http: // mydomain / user / get / 8534023 , which is actually the 27th user.
My question is here, knowing that some users may have experienced a similar problem, use a card, or assign a random identifier in the primary key column?
eg.
CREATE TABLE IF NOT EXISTS `test` (
`id` int (10) unsigned NOT NULL AUTO_INCREMENT,
`somethingElse` varchar (255) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE IF NOT EXISTS `map` (
`id` int (10) unsigned NOT NULL,
/ * Foreign Key to test table * /
`parent` int (11) NOT NULL,
PRIMARY KEY (`id`),
KEY `parent` (` parent`)
)
VS.
CREATE TABLE IF NOT EXISTS `test` (
/ * Assign random ID here * /
`id` int (10) unsigned NOT NULL,
`somethingElse` varchar (255) NOT NULL
PRIMARY KEY (`id`)
)
, , DAO/ ID ( ). .