OldWolf Posted January 27, 2009 Share Posted January 27, 2009 Howdy all, I'll say right off the bat that I can use mysql very proficiently when it comes to the basics, but I've never really pushed myself to learn much beyond that (even so much as joins), so I may be missing something incredibly obvious here. Here's my basic problem... at a lot of points around the site, things will be credited to a specific person. An example might be a post (in the form of a blog of sorts) on the index page. It will indicate not only who wrote it, but what their user level is. Originally, my plan was to put only the userid into the table for each row, and when collecting posts, I would just get the user's info out of the user table using their id. However, I was looking at how phpbb does it, and I see that they actually include the username and color (the color ends up being about equivalent to the userlevel) in the actual row for the post. If a user's color is changed, they perform an update on all the rows containing that user's id. Now assuming a potential of a million users (yea right, lol), what's the most efficient way for me to go about this? Put the username and userlevel in the post table? Select it after I get the posts? Something else I'm not thinking of? Thank you! James Quote Link to comment https://forums.phpfreaks.com/topic/142559-usernameuserlevel-in-individual-posts/ Share on other sites More sharing options...
corbin Posted January 27, 2009 Share Posted January 27, 2009 The logic behind PHPBB is actually fairly sound as long as the number of users is small. If you have to pull it each page load, well... that is an extra query for each name for each page. That could add up quickly. But, of course updating can become a pain if there are 10000 things that have that person's name in it. Also, the name prestored would of course take up more space. So basically it's their way of caching. Quote Link to comment https://forums.phpfreaks.com/topic/142559-usernameuserlevel-in-individual-posts/#findComment-747140 Share on other sites More sharing options...
OldWolf Posted January 27, 2009 Author Share Posted January 27, 2009 So you would recomend I follow their lead with that? If I don't go that route, would a left join select from the two tables be the next best approach? Thank you! James Quote Link to comment https://forums.phpfreaks.com/topic/142559-usernameuserlevel-in-individual-posts/#findComment-747199 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.