Am I thinking about this the wrong way? How would you manage a system with a table for users and tables for various resources and the need to track which users used which resources for how long (so that they can be billed for it)?
On Jan 16, 2011, at 06:20, Ryan Schmidt wrote: > Consider a system modeling a library. There are users who can check out > books. Logically we want to be able to create an association between a user > and a book when they check that book out. And of course a book that's already > checked out to a user cannot be checked out to a different user until it's > returned. Naively, when a user returns a book, we might delete the > association. But imagine I want to be able to answer questions like which > users have ever checked out this book and when? Which books has this user > ever checked out and when? What books did this user have checked out during > May? And so on. Clearly, to answer these questions, association needs to > remain in some form after one might otherwise have deleted it. How is this > type of situation typically modeled in CakePHP? Is there sample code or a > section in the book I should refer to for this? > > I imagine there would be a separate table (and model?) for checking out a > book. It would have an autoincrement id, the book id, the user id, the > checkout date, and the return date. What I'm not sure about is how much of > that Cake will manage for me and how much I need to manage myself; whether > such a table would replace, or be in addition to, a regular hasMany > relationship, etc. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
