Hi, i hope this is the right place for this basic question.
i have a table like this:

TABLE elements
`id_element` INT UNSIGNED NOT NULL ,
`name`  VARCHAR(100),
`date` DATE
...

and other table with the comments of every element.

TABLE elements_comments
`id_element` INT UNSIGNED NOT NULL ,
`comment` TEXT

each element can have a lot of comments, so,
what's more efficient, unnormalize the database and keep track of the amount
of comments (using a trigger fired when a comment is wrote or deleted) such
as

TABLE elements
`id_element` INT UNSIGNED NOT NULL ,
`name`  VARCHAR(100),
`date` DATE,
`comments`  SMALLINT UNSIGNED
...

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.

can someone help me with that?

thanks a lot

Reply via email to