Treat meta keywords as tags: ideas for database approach?

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Treat meta keywords as tags: ideas for database approach?

Post by JAB Creations »

While Yahoo is the only one of the big three to take meta keywords in to consideration they are also necessary for WAI AAA compliance. I'd like to store them in a database table though treat them as tags. Each page may have up to a maximum of seven tags. The issue is how would I best approach such a setup? I could setup seven columns though I'm not sure that would be necessary.

Thoughts please?
User avatar
VirtuosiMedia
Forum Contributor
Posts: 133
Joined: Thu Jun 12, 2008 6:16 pm

Re: Treat meta keywords as tags: ideas for database approach?

Post by VirtuosiMedia »

JAB Creations wrote:While Yahoo is the only one of the big three to take meta keywords in to consideration they are also necessary for WAI AAA compliance. I'd like to store them in a database table though treat them as tags. Each page may have up to a maximum of seven tags. The issue is how would I best approach such a setup? I could setup seven columns though I'm not sure that would be necessary.

Thoughts please?
How about this approach: Each page has an ID as a primary key, in addition to other properties. The tags would be stored in a separate table, each tag with an ID and then the tag text. Then a third table would contain the associations between the pages and tags and would consist of the associationId (as a primary key), pageId (as a foreign key), and the tagId (as a foreign key).
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Treat meta keywords as tags: ideas for database approach?

Post by alex.barylski »

Not sure I understand but it sounds like you want to express an 1:n relationship in which case it's best done:

Code: Select all

Pages:
------
pkid, title, description, primary_content
 
Pages_Tags:
------------
pkid, fkid, tag_name
Alternatively you could store each keyword/tag in a CSV field but if you want to generate tag clouds like Yahoo the above scehma will make it much easier and more efficient I would imagine.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Treat meta keywords as tags: ideas for database approach?

Post by JAB Creations »

VirtuosiMedia's idea makes me wonder why I hadn't thought of that...

I'm not thinking about tag clouds...I just want to make sure if there is some benefit I see in the future that I'll have a system already implemented that I can take advantage of.

The three table solution sounds beautiful. :)

CSV, comment separated values?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Treat meta keywords as tags: ideas for database approach?

Post by alex.barylski »

Three tables is the most flexible approach...
CSV, comment separated values?
Comma separated values...like a CSV file or XLS
Post Reply