translation
translation copied to clipboard
Wrong DB table example?
In docs, there is this DB table example:
CREATE TABLE `messages` (
`id` varchar(191) NOT NULL,
`locale` char(5) NOT NULL,
`message` varchar(191) NOT NULL,
UNIQUE KEY `id` (`id`),
KEY `locale` (`locale`),
KEY `message` (`message`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
But maybe the UNIQUE KEY should be multi-column (id, locale)? This example would work for only one language.
Also, why the varchars are set to exactly 191 chars?
You are right, UNIQUE key must be over id-locale, but it is possible without any unique key. And no idea, why varchar set for 191 characters.
How the table will look, it is only on you.
@zraly Hi, varchar 191 is max that u can use when adding key on that column in UTF8MB4 table, at least in some versions of MySQL or MariaDB database, so it´s because of compatibility. http://mysql.rjweb.org/doc.php/limits#767_limit_in_innodb_indexes