Welcome Guest, Not a member yet? Register   Sign In
Models and the Normal Form
#1

[eluser]kurucu[/eluser]
Question 2....

If you use a normally formed database structure, you tend to end up with a one-one relationship between models and tables. Right? (maybe wrong)

I have gone down this route, as it saves a lot of confusion and mess. In my model, one discussed briefly elsewhere, has a users table and a posts table.

If you wish to display a list of posts, and with each post the name and some other details about the user, how do you handle that? My thoughts are torn between:

- Joining the information, which seems to 'dirty' the posts table and mean that for other uses I have too much information in the array. Seems fast, but leaves me with more and more specific calls in my models that become unmanageable.

- get_posts, and then somewhere (controller? view?) attach a user object to each post. Slower, but maybe not too slow, but much cleaner and easier to reuse and follow.

- get_posts, and then build a user cache based on the unique users in that post list. Perhaps an optimisation of point 2.

What have/would you done/do? Any other suggestions?


Messages In This Thread
Models and the Normal Form - by El Forum - 09-24-2009, 05:31 AM
Models and the Normal Form - by El Forum - 09-24-2009, 05:41 AM
Models and the Normal Form - by El Forum - 09-24-2009, 05:43 AM
Models and the Normal Form - by El Forum - 09-24-2009, 05:46 AM
Models and the Normal Form - by El Forum - 09-24-2009, 06:25 AM
Models and the Normal Form - by El Forum - 09-24-2009, 07:01 AM
Models and the Normal Form - by El Forum - 09-24-2009, 08:28 AM
Models and the Normal Form - by El Forum - 09-24-2009, 09:03 AM
Models and the Normal Form - by El Forum - 09-24-2009, 09:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB