Friday, December 18, 2009

Re: Best practise to manage user's selections and user's views

I use the following ER model in order to register when an item was
viewed, downloaded, etc.

Collection HABTM Item
Collection hasMany CollectionItem
Item HABTM Collection
Item hasMany CollectionItem

So I have the following CakePHP models:
Collection
CollectionItem
Item

The Collection is a classifier, identifying whether an Item was viewed
or downloaded, etc. It is defined as (id, name) and contains the
records:
1, "view"
2, "download"

The Item contains all the - items :)

The CollectionItem is used to register the fact of viewing or
downloading the items. It is defined as (id, collection_id, item_id,
created)

Whenever I want, I can turn on the registration of users or visitors
viewing or downloading an item.

You want to register also the users id, so should add the user_id
column to the CollectionItem.

Hope this helps you on the way :)
John


On Dec 18, 1:47 pm, "marco.rizze...@gmail.com"
<marco.rizze...@gmail.com> wrote:
> Hi
> In my application I have the model "Item" and the model "User".
> Every item is visible by some users and it isn't visible by other
> users. So I have a HABTM between "User" and "Item".
> Now I must register when a user views an item and when a user selects
> a item (a user can select some visible items if he wants).
> To do this I have found 2 solutions:
> 1)  Created two models "ItemSelection" and "ItemView" but if I must
> use INNER JOIN (for example If I would the list(with paginate) of
> users that have viewed and selected and certainly item)  I have very
> very bad performance.
> 2)  Add to the users_items table fields "viewed" and "selected" but I
> have a big table with many and many record with null value
>
> I would ask if someone has this problom in the past and how he has
> resolved it.
> Many Thanks
> Bye

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate