Forum Moderators: open

Message Too Old, No Replies

User System: Implementation of a BLOCK method

         

asantos

9:54 pm on Jan 6, 2009 (gmt 0)

10+ Year Member



Hi, i have a user table (around 50k users). A user should now have the possibility to block other users.

What should be the best table structure implementation for this matter?

This is my user table:

CREATE TABLE `user` (
`id_user` int(11) NOT NULL auto_increment,
`email` varchar(50) NOT NULL default '',
`name` varchar(25) NOT NULL default '',
`lastname` varchar(25) NOT NULL default '',
`birthdate` int(14) default NULL,
`id_country` int(11) default NULL,
PRIMARY KEY (`id_user`)
);

And this is my temporal block table (temporal because i still dont know if this is the best way to do it):

CREATE TABLE `block` (
`id_block` int(11) NOT NULL auto_increment,
`id_user` int(11) default NULL,
`id_user_blocked` int(11) default NULL,
`date` int(14) default '0',
PRIMARY KEY (`id_block`)
);

Points to consider:
* If A blocks B, B shouldnt be able to find or message user A in the future.
* If A blocks B, A also shouldnt be able to find or message user A in the future (unless he unblocks him from another interface).

Is there any way to optimize this? Thanks!

maximillianos

12:34 pm on Jan 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since a user cannot block someone twice I would consider making the 2 user id fields part of the key, and scrap the autoincrement field.

Or you could simply leave it as-is and create an index on the table for the column(s) you use most when searching the table.