All the tags are lowercased.

Sure you can have "1" or "One" but how does a separate table avoid
that? What about spelling mistakes? How are you going to handle your
tags? A mother of all drop down lists? Will you create christian name
and surname tables in case there are two Johns? There are sensible
limits to normalisation and in this instance I felt it was another
table too far.

If I make a blog entry a day, 10000 will take me beyond my life
expectancy.100000 beyond that of my children's great grand children.

A loop in a loop is naughty but we're talking about half a dozen
iterations. You're talking about two table lookups.
Sometimes purity of code and religious normalisation are just too much
tub thumping. Get the job done. If it breaks fix it.

On Jan 19, 10:11 pm, RichardAtHome <[email protected]> wrote:
> "I couldn't see the point in a separate tags table"
>
> What about 2 articles that share the same tags? You run the risk of
> tagging either with "one" or "1" (for example) or "CakePHP",
> "cakephp", "Cakephp", "cakePHP"...
>
> There's an awful lot of processing happening in your foreach loop.
> What happens when you get 10,000 records? or 100,000? A relational
> database eats this kind of aggregation for breakfast :-)
>
> On Jan 19, 4:20 pm, leo <[email protected]> wrote:
>
> > I couldn't see the point in a separate tags table, so I have a tags
> > column on the table that requires it.
>
> > To retrieve the tags and tag count, I do this:
>
> >         function getTagsWithCounts($conditions = array())
> >         {
> >                 // Return assoc_array(tags) for all records in
> > database. Keyed on tagword,
> >                 // value = tagcount
>
> >                 $tagCounts = array();
> >                 $tagRows = $this->findAll($conditions, 'tags');
>
> >                 foreach ($tagRows as $row):
> >                   $tags = explode(',',$row['Event']['tags']);
> >                   foreach ($tags as $tag):
> >                     $tag = trim($tag);
> >                     if (array_key_exists($tag, $tagCounts)):
> >                       $tagCounts[$tag]++;
> >                     else:
> >                       $tagCounts[$tag] = 1;
> >                     endif;
> >                   endforeach;
> >                 endforeach;
> >                 return $tagCounts;
> >         }
>
> > It's simple and it is working on two commercial sites, soon to be four.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to