You could consider storing your measurement data in a single column in the measurements table as a JSON string. Thus the logic would be very simple as you only need to convert to and from JSON. The downside is you won't be able to easily query against values in the measurement data. Anything you want to include in a query should be in a separate column.
Mark On Monday, June 25, 2012 4:12:43 AM UTC-4, Poyan Nabati wrote: > > *How should I implement this on the backend?* > > > - *Two models.* I thought of having two models, Goal and Measurement, > where Measurement has a corresponding field in the database called "value" > that's agnostic of it's contents (in other words, a VARCHAR that I > interpret differently depending on context). I believe, however, that this > approach will create a lot of special code for each of the different cases > down the line. > - *Many models.* Another way to do it would be to create > NumericMeasurement, BooleanMeasurement etc etc for each of the different > measurement-types. In Goal I could have a field that indicates the type > and > create the association Goal hasMany (each of the measurement types). Do > you > see any problems with this approach? > > Is there another, better approach that I haven't thought about? > > How would you solve this? > -- 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
