Saturday, November 1, 2008

Re: Building "Tagging" feature in my site

Please find my suggested db design below,

tags: id, name
types: id, name
posts: id, name
teachers: id, name
books: id, name, type_id
books_tags: id, book_id, tag_id
All ids are auto increment & primary  fields.

So if, the book with (id, name, type_id) = (6, 'Bookname', 2) has two tags with (id, name) = (11, 'Chemistry') & (23, 'Grade A'), then the entry in the books_tags(book_id, tag_id) table for this will be -  (6, 11) & (6, 23) .

Also read this page from the doc http://book.cakephp.org/view/24/Model-and-Database-Conventions

--
Anupom Syam
http://syamantics.com/

On Sat, Nov 1, 2008 at 8:42 PM, dmouth@gmail.com <dmouth@gmail.com> wrote:

Hi All,

I am trying to build a tagging feature in my site which is a community
site for a school.

In my site, I have various entity types like : Blog Post, Teacher,
Book .

Every entry for these entities will have tags associated with it . So,
a tag may belong to one or more items of different entities.

In a normal core PHP project, I would have designed tables for this in
the following manner :-

1) tags : tag_id, tag_name .
2) entity_types : entity_type_id, entity_type_name .   [(0, Posts),
(1, Teachers), (2, Books)]
3) posts : post_id, post_name .
4) teachers : teacher_id, teacher_name .
5) books : book_id, book_name
6) entities_tags : tag_id, entity_type_id, entity_id .

So, if a book (entity_type_id = 2) with book_id = 6 has 2 tags
(tag_id, tag_name) : (11, 'Chemistry') & (23, 'Grade A') , then the
entry in entities_tags for this will be : (11, 2, 6) & (23, 2, 6) .

I am using CakePHP for my project and I am not able to design the
tables in CakePHP for this Tagging Feature.

It would be great if people could come up with their suggestions.

Thanks a lot !!




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: