By model, I assume you mean table. Then I think it is nice to have two table and have a foreign key to relate them. Also you can have many columns in the second table so that it could address most of the data.
But yes, if you feel there will be many many columns then you may have more table with association.
On Mon, Jun 25, 2012 at 10:12 AM, Poyan Nabati <poyan.nabati@gmail.com> wrote:
I have a question regarding more the design of the back-end rather than specifically how to implement it.
I'm creating a life tracker of sorts. The purpose is to have a single application to help you keep track of things that are important to you long term.
I want to be able to track a wide array of different things.
For instance;
- What type of exercise did I do? (Fixed: Gym, Running or Other)
- Did I meditate today? (Boolean measurement)
- What was my weight today? (Numeric measurement)
- What's one good thing about today? (String "measurement")
So for each goal you have a single specific type of measurements.
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment