OK, I'm inexperienced in terms of database design, so hopefully my question isn't too silly.
I have 2 tables
user_profiles these two tables has one-to-one relation between them. so(obviously) each row in
users table will be linked to a row in
And, when I'm displaying a user's profile in the web app I'm creating I have to do two
JOIN) to get the required data, which is -somehow- overkill for me, and I'm looking for an alternative to it, I'm trying to get the required data with one
SELECET statment from one table.
CREATE TABLE IF NOT EXISTS `users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) COLLATE utf8_bin NOT NULL, `password` varchar(255) COLLATE utf8_bin NOT NULL, `email` varchar(100) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) )
CREATE TABLE IF NOT EXISTS `user_profiles` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `nickname` varchar(50) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) )
So for example, if I want to grab the nickname, user and email I'll definitely use
JOIN or double
SELECT. Which will lead me to use two tables for such a simple query.
So, I have currently three solutions in mind:
SELECTand hopefully my website won't be too slow because of this. Will this have huge impact on the performance of my web app anyway?
user_profilestable and keep all user's personal data in one table.
- Duplicate columns in two tables, so for example the
user_profiles. Which will result in double
INSERTSat the time of user registration.
Looking forward to hear your opinions.