Re: Database Tables Relation Issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I have thought of using comma-separated ID's in special field in the lists
> table of the users who have joined that specific list, but I have also
> thought of doing the same at the users table, then I had another solution
> which is to create new table:
>
> create table `relations` (
>  `listid` int(11),
>  `userid` int (11)
> );
>
> Which will contain the relations.
>
> I want it to be optimised so when I'm fetching the mailinglists that a
> specific user is registered (by user id) to and when I'm fetching the users
> in specific mailinglist (by mailinglist id) it will be the fastest.

Always use an extra table unless you have an extremely good reason not to.

For example, someone unsubscribes from the list - you would have to
regenerate the whole comma separated list (you might be able to do it
through a query but it'd be very painful). With an extra table, you
just delete the row from the relations table (guess which is going to
be faster).  Same for signup - you just add a new row into the
relations table.

With an extra table, you could also add a field for when they
subscribed to that list, so if they say you're spamming you could show
when they signed up and so on.

-- 
Postgresql & php tutorials
http://www.designmagick.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux