Page 1 of 1

Best way to store the forum thread creator?

Posted: Wed Oct 08, 2008 6:56 am
by someberry
I am making a small forum based system and was wondering where would be best to store the ID of the user to created the thread. At the moment, to reduce data redundancy, I am not storing the data in the thread table and only in the post table (the first post of the thread is obviously the person who made it).

However, I ran into a few problems with the SQL. Is it possible, by using joins, to get the first post ID of the thread?

Thanks :)

Re: Best way to store the forum thread creator?

Posted: Wed Oct 08, 2008 7:05 am
by onion2k
This is the sort of thing that a natural language key is good for ... basically store the user's name in the thread table and use it as a key to join to the users table if necessary. Most of the time you won't need to because you can just use the name as it is, saving you having to do a join at all.

The problem with this approach is that you'd have to update all the names in the threads table if a user ever changes their name...

EDIT: It was discussed in this thread - viewtopic.php?f=2&t=87385

Re: Best way to store the forum thread creator?

Posted: Wed Oct 08, 2008 7:15 am
by someberry
I was thinking of storing the user ID in the thread table, but I was really hoping to not have to, which is why I was wondering if I could achieve the same effect through joins.