fra
fra

Reputation: 3858

Entity framework with Sql-first development

I'm going to develop a big database for my company. This database will be the core element for future products. My first thought was that of using EF 4 creating a nice, "object-oriented" database with built-in inheritance concept. Then, I read lot of criticism against a database thought with object-oriented paradigm in mind. The database should be built on facts, and not on objects (reference). And we need a database with great performance, first of all. For me, as a long-time C# developer, it is quite difficult to think not in terms of object, since for me everything is an object. Could you suggest me articles, books or just blog entries to get back into the old tabular world of database, with performance in mind more than "usability"? Then, I would like create an EF view out of it, because later I will need "usability" too, comprehensive of inheritance.

Any help appreciated

Upvotes: 0

Views: 247

Answers (2)

Jonathan
Jonathan

Reputation: 2358

What you should be trying to do is create a normalized database. With proper referenential integrity and indexing. It might not be pure OO but there is always the degree of impedance mismatch between your application code and the database. Tools like entity framework go a long way of abstracting this from you and deal pretty well with a database geared for performance and proper normalization. It takes time to learn to do this, so do it properly and try understand what the different forms of normalization mean etc 1st form, 2nd form ... boyce codd normal form and how to implement them.

At the end of the day relational databases don’t store things in objects but in rows and columns. If you are super interested in pure OO from back to front then may be worthwhile checking some of the OO databases out there, although in my experience relational databases with a decent ORM etc (Entity Framework, NHibernate) work fine.

Entity Framework and NHibernate allow you to map things to object models that implement inheritance. This does not mean you necessarily have to implement inheritance on your database. For instance if you have a Person who can be either unemployed, employed, disability. You would model this through two tables instead of four. etc

Person has a EmploymentStatus

instead of 

Person has a table
Unemployed has a table
Employed has a table
Disability has a table

This doesnt mean you will have two object in your code though. Using a tool like EntityFramework you can specify a mapping to four sperate classes that implement inheritance.

I would recommend you have a look at the following article.

Relational Impedance Mismatch

Database Normalization

Normalization

How to normalize your database

Object Database

Upvotes: 1

Sergey Vedernikov
Sergey Vedernikov

Reputation: 7744

You should look at this site: http://ormeter.net/ BLToolkit is fast and powerfull ORM library EntityFramework has some "usability" disadvantages, for example: many-to-many relations

Upvotes: 1

Related Questions