tags:

views:

44

answers:

1

assume that i start coding an application from scratch, is the best way to create tables when using an ORM (doctrine), to manually create tables in mysql and then generate models from the tables, or is it the other way around, that is to create the models in php and then generate tables from models?

and if i already have a database, will the models created be optimal? cause i have heard some say that its best to create the database from scratch when using ORM, so that the relations are optimized for OOD.

share your thoughts!

+1  A: 

I think that ORM promotes an OO approach i.e. to start with the object model and to generate the tables from it. And this is usually what I do when starting from scratch. But once the database goes live, I don't generate things anymore, I use changes scripts. This applies also if you need to tune the database (with indices, denormalized columns) and can't handle that with your ORM.

But some prefer the other way around, especially DBAs, and there is nothing really bad with this unless the model is heavily denormalized in which case it may not map to a nice OO model. In such cases, you may get better results with a data mapper than with an ORM.

Pascal Thivent