Search Postgresql Archives

Re: Modelling tags

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

 



Hello,

> I am thinking about how to model tags for a web site in the database.
> Is tsearch2 the way to do it?

Yes, tsearch2 is the ultimate thing for all your text work in the PostgreSQL.

> Each site entry could then store its tags
> in a tsvector. That would make me able to perform partial matches and
> rate them.

Each site entry should store its tags in tsvector definitely but for
the reasons of search only, not for ratings. It's better to separate
ratings/counters from text work usually. Default pattern I use is
inheritance of all tables from one parent table e.g. to make use of
global across entities id column. After then you create "tag" and
~"entity2tag" table which stores links to tags for your users to be
able to tag every entity stored in the database. Then couple of
triggers (for counters/ratings and full-text stuff) finish the work.
You finally are able to draw tag clouds, organize ajax suggest when
user tags smth, select entities by tag rapidly, search across entities
using tsearch2 avantages, make partial matches, etc.

Schema can be more complex if you need to store personal tags and show
them to user but one can easily extend the basic idea to get the
features needed.

Regards,
 Ivan

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org/

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux