views:

96

answers:

1

A WPF application should be a visualizer front-end for a ERP database (in fact only small part of it). They are connected trough web services.

What are main rules for designing a data model class structure for mapping database tables? For example, should it be a one big flat class with lots of members, or lots of classes representing different tables in database?

+3  A: 

If at all possible, use a standard Object/Relational Mapper (ORM) such as NHibernate, LINQ to SQL or the Entity Framework.

They typically have wizards that can generate the object model based on the database schema. The default approach seems consistently to be to create a class per table, which makes a lot of sense.

If your database is proprietary and you can't work with a standard ORM, I'd still recommend that you take one of them for a spin to understand how they model relational databases. That should quickly answer most of your questions in that regard.

Mark Seemann
Thanks for the tip, Mark. I will dig into the ORM. At first glance LINQ to SQL looks more easy for getting aсquainted with. Yet another issue regarding my case (which I failed to mention in my question) is the fact that we should not connect to SQL database directly but through ERP's business logic. Maybe this fact will have more influence on the final configuration of the data model (I mean, maybe it will better to build structure of classes taking into account not the structure of target database, but the structure of each seperate request to it.
rem
In any case, the best approach would be to define an abstract Repository (or several) and let your app talk to that. This way, you can always implement it in any way you'd like. It's really the standard Adapter design pattern in play.
Mark Seemann