Re: How to setup multiple HABTM relationships between two tables
On Thu, Jan 13, 2011 at 3:55 PM, mklappen wrote: > Thanks for replies... I added a two boolean columns to join table for > "owns" and "wants" You might be interested in modelizing the join table like this: http://book.cakephp.org/view/1650/hasMany-through-The-Join-Model Also, as Jeremy suggested, consider using a single column if a User cannot both own and want an Item. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to setup multiple HABTM relationships between two tables
Thanks for replies... I added a two boolean columns to join table for "owns" and "wants" Thanks again!! On Jan 13, 3:13 am, Jeremy Burns | Class Outfit wrote: > You could consider adding a new column to your joining table that contains a > tinyint. By default the value of that field is 0 (which indicates wants) but > changes to 1 when he owns it. This assumes that someone can no longer 'want' > something when they already 'own' it. > > Jeremy Burns > Class Outfit > > jeremybu...@classoutfit.comhttp://www.classoutfit.com > > On 13 Jan 2011, at 07:14, Zaky Katalan-Ezra wrote: > > > If you go with the status columns you need two boolean columns one for own > > and one for want, its a possible solution. > > If you want to use two table you can create users_want and users_own. > > The relation for each table should looks like it would be for items_users. > > The reason to prefer one implementation depend on your over all design and > > data distribution. > > > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.com For more options, visit this group > > athttp://groups.google.com/group/cake-php?hl=en 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to setup multiple HABTM relationships between two tables
You could consider adding a new column to your joining table that contains a tinyint. By default the value of that field is 0 (which indicates wants) but changes to 1 when he owns it. This assumes that someone can no longer 'want' something when they already 'own' it. Jeremy Burns Class Outfit jeremybu...@classoutfit.com http://www.classoutfit.com On 13 Jan 2011, at 07:14, Zaky Katalan-Ezra wrote: > If you go with the status columns you need two boolean columns one for own > and one for want, its a possible solution. > If you want to use two table you can create users_want and users_own. > The relation for each table should looks like it would be for items_users. > The reason to prefer one implementation depend on your over all design and > data distribution. > > 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+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to setup multiple HABTM relationships between two tables
If you go with the status columns you need two boolean columns one for own and one for want, its a possible solution. If you want to use two table you can create users_want and users_own. The relation for each table should looks like it would be for items_users. The reason to prefer one implementation depend on your over all design and data distribution. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How to setup multiple HABTM relationships between two tables
It all depends! What is the requirement for owning items? Can a user own more than one of the same item? What is the requirement for wanting items? Can a user want more than one of the same item? Can a want record expire - ie. the user wants the item, but only if the user can get it within X days/months/years? I would probably go for the two intersection tables between users and items, with the first storing all the owned items, one record each, and the second storing all the wanted items. When then the user gets the wanted item, I would remove it from the second and insert it into the first. Well, you can think about it. Enjoy, John On 12 Jan., 21:13, mklappen wrote: > Hi All > > I'm having a little difficulty conceptualizing the relationships when > setting up a database/models, for a app I'm starting to develop. If > I'm creating a basic inventory management application I have the > following: > > Table Name | Columns > users | id, user_name, email, etc... > items | id, name, description, etc... > items_users | id, item_id, user_id > > I want a user to be able to mark items as "owns" or "wants" and a user > can own many items and items can be owned my many users. Similarly > "wants" would have same HABTM relationship between users and items. > > Now I can set up the HABTM relationship table "items_users" but that > will only get me one relationship between users and items. (either the > "owns" or "wants"). In order to get the second relationship type do I > need to set up a second relationship table? if so what would the > naming conventions be? > > Or do I add a another column to "items_users" table called > "itemstatus" and have values such as "owns", "wants", "owns & > wants"... > > More or less looking for the best approach and/or other suggestions. > > Thanks in advance. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en