Object-Oriented Database Design – Object Model vs Data Model

class-designdatabase-designmodelingobject-oriented

I have heard/read mixed things on whether to start with an object model or a data model. And more people say to starting with an object model as it will ease your data modelling.

My question is, Shouldn't an object model always drive the design of data model? Why and When would a data model design be different than an object model?

If we have a good object model, shouldn't the classes we come up with translate into tables? And class associations as table relationships?

Best Answer

The question is, does your app serve the database or does the database serve the app?

If you can describe your app/website as a "skin" on a database, you can start with the database structure/schema and code the CRUD because the behavior of the app is to manage data on the disk. You may hit a few bumps in the road.

If this isn't the case, you need to address the behavior of the app besides just the CRUD. There will be information held in the app that never makes it to the database. Much of the logic can be coded without the database. This can help with unit testing or maybe as a guide to keep your code organized and separate the data storage needs.

Who knows. Your app may not need a database at all or something as simple as a text file.

Related Topic