cakephp Model Hierarchy

320 views Asked by At

I am using CakePHP for a web application. And I am in very initial stage of development. I am doing designing and developing side by side.

So far, I have 7 tables.

--Site
|--ABC
|--|--BCD [hasMany]
|--|--TED [hasMany]
|--|--NOC [hasOne]
|--|--GED [hasMany]
|--|--LOC [hasMany]

I am confused about what should be heirarchy of all these classes.

Currently I am defining relationships Site hasMany ABC and ABC hasMany BCD...LOC and viceversa. I am able to retrieve and save data currently.

What worries me is if the system is flexible enough to include any future changes easily.

About the hierarchy of my classes, Should Site extends AppModel and ABC extends Site and so on. OR Defining relationships will give me everything I need.

Everything is driven by ABC Controller.

Any suggestion?

Thank you in advance.

1

There are 1 answers

2
Dave On BEST ANSWER

It's tough to really give feedback on fictitious or acronym models, but - all models should extend the AppModel, and just let your associations/relationships do all the work. I don't see any reason why this doesn't leave it completely flexible and has worked fine for me on every project thus far.