On Tue, 04 Mar 2008 15:04:30 +0100, Nacho Garcia wrote:

> or count the comments on elements_comments table. I guess the last
> option could be very slow with lot of rows because mysql has to scan all
> of them .. and the first option seems to be very fast.


I would certainly want to be able to:

SELECT e.element, c.comment FROM elements, comments AS e, c WHERE 
e.id=c.element_id;


Surely elements.id should be a primary key?  And, comments.element_id 
would be a foreign key?

The only way to be able to get a result like:


elements                comments
=================================
earth                   a comment on the earth
wind                    a comment of the wind
fire                    a comment on fire
water                   a comment on water
water                   another comment on water
water                   yet another comment on water
earth                   again, with the earth!



and *not* have problems with redundant data is to decompose into multiple 
tables.  Perhaps an index would speed things up?  There's a calculation 
involved?  I didn't follow what was be calculated.  Perhaps GROUP BY and 
COUNT can be used to do the calculation you want.



-Thufir



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to