Hi
Both approaches have pros and cons as always is the case. It is probably a good idea to mix both together.
You mentioned code generation as a benefit of databas-first. But similarily you can generate database schema using your model and mapping files. Considering the effort required I think that model-first approach is better in this regard. You write your model as you normally would. Map using hbm.xml, fluent nhibernate, mapping attributes, castle activerecord or whatever means you can come up with and Schema Export creates the schema for you. On the other hand, if you start with database schema it is easy to mess up naming convention and either end up with much more mapping to write or an ugly ugly model. I must admin though, that I have never used any code generators you mention, so I may underestimate them.
Other than that one may try to compare the final database performance. Model-first approach probably ends up with more associations and inheritance and thus more joined tables, which could affect how your application performs. Designing the database schema first inhibits creating too many tables but it is also not object-oriented so the object model outcome of both approaches could be different, which again makes the two harder to compare.
Other than the above, what comes to my mind is using the full potential of a relational database has. I have noticed, that designing model first makes me forget about views, triggers and stored procedures for example. And I certainly never forget about them when designing database-first.
Not sure wht you can make out of it. The choice is hard but it's your to make ;).
Personally I prefer model-first approach, because I find it easier to update the schame, as model changes. And if you would choose this path, try not to neglect what your server of choice has to offer.
Regards Tomasz
|