OK, I'm inexperienced in terms of database design, so hopefully my question isn't too silly.
I have 2 tables users and 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 user_profiles table.
And, when I'm displaying a user's profile in the web app I'm creating I have to do two SELECT statements(or 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.
users schema:
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`)
)
user_profiles schema:
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:
- Use
JOINorSELECTand hopefully my website won't be too slow because of this. Will this have huge impact on the performance of my web app anyway? - Remove
user_profilestable and keep all user's personal data in one table. - Duplicate columns in two tables, so for example the
emailcolumn will be present inusersanduser_profiles. Which will result in doubleINSERTSat the time of user registration.
Looking forward to hear your opinions.

user_profilesdepends only onuser_id, than merge the tables. This will depend on your use case.) – dezso Aug 3 '12 at 10:21