Unanswered: Fetching data of each user for each forum thread message?
Hi people, as I'm designing my own forum database (okay there were reasons behind this) with Microsoft SQL Server 2008, there is something got me very concerned -- performance. Consider the following basic table to store thread messages in the forum:
mid: Message ID (Primary key)
uid: User ID (Foreign key to Users table)
tid: Thread ID (Foreign key to Threads table)
msg: Message content
uid: User ID (Primary key)
name: User name
posts: Number of posts user has made
sig: User signature to show on messages
When I'm displaying messages of one given thread 1234, I'll do a "SELECT * FROM Messages WHERE tid = 1234". That is one query, and then for each of the messages, I need to display user info (e.g. user name, signature, etc...). If there are 10 unique users for the given thread, then I need to make ten additional queries to obtain their information (just to display one thread). I imagine I can do all that with one Stored Procedure, but ultimately there are still 11 queries for this case.
Will that not kill my DB server? Is this considered normal? I'm sorry if I have missed obvious shortcuts, I'm just yet another C++ guy, SQL is not my mother tongue