Hi,

If i did understand what you are trying to achive you could design
your tag relationship in the following way:

Tables

-----------
Tags
id
name
model
created
updated more if needed etc...


then you would have a linking table which would link tags to its
repective  associated model.

Example:

model_tags //name it as you like
foreign_id   //id of associated model
tag_id



Lets say that my users uses tags etc...

User -- model


var $hasAndbelongsToMany = array(
        'Tag' => array(
                'className' => 'Tag',
                'joinTable' => 'model_tags',
                'foreignKey' => 'foreign_id',
                'associationForeignKey' => 'tag_id',
                'unique' => true,
                'conditions'   => array(Tag.model' => 'User'), // Tag.model =>
Associated model class name
                'fields' => '',
                'order' => '',
                'limit' => 5,
                'offset' => '',
                'finderQuery' => '',
                'deleteQuery' => '',
                'insertQuery' => ''
        )
);

In the tag model you could do the same thing.

I know that it works because I used it before ...

Hope it helps you out.

Cheers

On Nov 1, 2:42 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> 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,
> atagmay 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 [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