Forum Moderators: open

Message Too Old, No Replies

names by id, or text in database?

         

StickeR

10:50 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Hello,
I am building a community site for a client.
As research I have gone through the database/tables for an InvisionPowerBoard installment I have running.

For example, in IPB each forum-thread has the thread starter's / last replier's Username in text in the thread's rows in the table.

I thought this would be better to do with username_id's (INT) instead of text (Varchar),
and then run a query to retreive the name to that id.

But since IPB is a rather professional system, I have my doubts on doing the INT thing.
Plus this would require several queries (at once probably), I don't know if server resources would ba a problem for that.

I would appreciate some information on what's the best way to do this.

mcibor

12:48 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Better would be to use id, cause username may change. Moreover int takes less space than string.

To retrieve then username from id you can use JOIN tables or just
SELECT data.*, users.user WHERE data.userid=users.id;

Regards
Michal

aspdaddy

3:35 pm on Mar 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use a combination of both, depending on the requirements.

I use actual usernames if I need to delete the user accounts and keep the related content, I use ID if I only need to disable the account or if I delete the content when the user is deleted.

lammert

2:48 pm on Mar 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



On forums, storing the username is in general a good idea, especially in situations where a username can be deleted while the posts for that username will remain, and when the forum allows to post as guest with an ad hoc username.

StickeR

3:16 am on Apr 1, 2007 (gmt 0)

10+ Year Member



heh, never received a reply notification :(
Thanks for the response,
I've read some good arguments which would make sense to use names instead, I decided to go for id-based though.