Answer the question
In order to leave comments, you need to log in
Does MySQL's table structure look correct?
Hello! Are these tables properly configured in terms of proper data storage and optimization? What errors and shortcomings can occur? What to fix?
I use TINYINT instead of bool, the value will always be 1/0
DATETIME naturally for date and time. Maybe it's better to use UNIX time with integers? restore
table for password recovery
`id` int(11) NOT NULL,
`user_id` int(11) NOT NULL DEFAULT 0,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`restore_key` varchar(191) COLLATE utf8_unicode_ci NOT NULL, -- ключ, который отправится на email
`changed` tinyint(1) NOT NULL DEFAULT 0, -- при следующем переходе по той же ссылке, проверяется это значение, менялся ли уже пароль
`created_at` datetime NOT NULL
`user_id` int(11) UNSIGNED NOT NULL,
`username` varchar(64) COLLATE utf8_unicode_ci NOT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
`password` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`password_salt` varchar(64) COLLATE utf8_unicode_ci NOT NULL, -- динамическая соль
`token` varchar(191) COLLATE utf8_unicode_ci NOT NULL, -- ключ для доступа к API
`hwid` varchar(128) COLLATE utf8_unicode_ci NOT NULL, -- хеш
`activation_key` varchar(191) COLLATE utf8_unicode_ci NOT NULL, -- ключ для подтверждения email'a
`status` tinyint(1) NOT NULL DEFAULT 0, -- подтвержден ли email
`password_changed_date` datetime NOT NULL DEFAULT current_timestamp(),
`join_date` datetime NOT NULL
`id` int(11) NOT NULL,
`user_id` int(11) UNSIGNED NOT NULL,
`level` int(11) NOT NULL DEFAULT 1
Indices
ADD PRIMARY KEY (`id`);
ADD PRIMARY KEY (`user_id`),
ADD KEY `username` (`username`),
ADD KEY `email` (`email`),
ADD KEY `hwid` (`hwid`),
ADD KEY `token` (`token`);
AUTO_INCREMENT attribute
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
MODIFY `user_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question