$hasAndBelongsToMany

A User can have many Product(s) in hist "shopping cart" or something.
A Product can be in (have) many User's carts.


On Jun 8, 4:03 pm, Céryl <[email protected]> wrote:
> Hello all,
>
> Little question:
>
> Say, i have two tables, USERS and PRODUCTS, for arguments sake.
>
> Now, all the products in the PRODUCTS table are unique by some value,
> say barcode, so it doesn't allow duplicates of the same product in the
> table.
>
> Now, a user can have several products associated with him. What is the
> best way to do this? Eventually a user would be able to log in and get
> an overview of his selected products, and add/remove products to his
> personal list from all the products in the PRODUCT table.
>
> A table that holds user_id in one column, and product_id in the other,
> maybe? But that would grow to a very large redundant table like this:
> user product
> 1         3
> 1         6
> 2         3
> 2         4
> 2         5
> Etc.
>
> Any idea's?
--~--~---------~--~----~------------~-------~--~----~
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