Should I store user id's and profile data (10-15 columns) separately?
I am using PHP and MyISAM, currently I have a profile page for users and am unsure of how I should exactly lay out the tables.
I have tables for users (and every bit of their profile including a pair of MEDIUMTEXT fields for their long description or custom stylesheet,) a table for friends (userid+friendid) and of course a table for comments that ma开发者_StackOverflowy have been placed on their page.
Would it be wise to separate the profile/extra user data from the user table and purely use it for checking with the other tables?
I am unsure if many/or some long fields in each of the rows would be inappropriate if I were just checking for their friends to display or something on another page.
Short answer is maybe. Seperating the tables will save space because if the field is not used space will not be allocated. Space probably wont be a concern ( depending on the server and userbase ) but joining tables can slow performance down but again this depends on the userbase and the server. I think primary keys indexes are stored in memory so lookups shouldnt be affected by the number of columns / size of a row.
speed / performance ... denormalize
space normalize
Basically your questions can not be really answered as it's very subjective, so this is more or less some opinion to chime in:
Would it be wise to separate the profile/extra user data from the user column and purely use it for checking with the other tables?
It seems so, because you call it extra user data. So it does not belong to user and should be kept apart of it.
I am unsure if many/or some long fields in each of the rows would be inappropriate if I were just checking for their friends to display or something on another page.
That's hard to answer as well with the information you provide. If you've only doing SELECT * FROM TABLE;
queries however, then it would be definitely inappropriate.
I think it is good to create a separate table for the profile/extra user data. Keep frequently used column in the user table and move other columns in the new user_profile table. Currently you have 10 - 15 columns but in future it may grow to 50+ columns. So it is better to separate now.
HTH,
精彩评论