Welcome Guest, Not a member yet? Register   Sign In
Should each database table have its own distinct model?
#1

[eluser]peterbz[/eluser]
Should each table have its own distinct model? Or can several similar databases be grouped under one model? Which is the right convention in the MVC approach?

For example, I have tables "invitations" and "invitations_pending". Now both of them are linked and call from one of them usually links to another call of the other database. Should I make a model called "invitations_model" that uses both of these databases?
#2

[eluser]Developer13[/eluser]
I'm not going to answer the "which is the right convention in the MVC approach" portion of the question. I do what works for me and for the application (which often changes), so I can't necessarily answer that part.

Generally, if the tables are closely related (as it seems your two tables would be), I would just stick them in the same model.

I'd also say to not get so caught up in the strict specifications of MVC -- just do what works Smile
#3

[eluser]wiredesignz[/eluser]
[quote author="peterbz" date="1227965065"]Should each table have its own distinct model? Or can several similar databases be grouped under one model? Which is the right convention in the MVC approach?[/quote]

MVC doesn't specify what constitutes a model, only that it encapsulates your data sources.

If you need to retrieve information from more than one table then by all means you can use a single model to do the job.




Theme © iAndrew 2016 - Forum software by © MyBB