Entity Framework

Entity framework is the new kid on the block on the ORM realm. It’s Microsoft new technology for data access, and although it didn’t receive very good comments on its first version, things have been greatly improved in its latest release. It now looks really interesting, with some features which surpass the most seasoned ORM frameworks that have been in the game for years.

Here’s what Entity Framework (EF) has to offer:

Read the rest of this entry »

Persistance layer: object-relational mapping tools

Nowadays it’s very usual to work with object-oriented programming and relational data bases. Relational data bases are all about tables, relations and groups. However, the object-oriented programming paradigm consists of objects, attributes and inter-object relationships. When these objects need to be stored using a relational data base, it’s very obvious that these two models of representing information are very different from each other. We need some kind of translation to transfer data from one to the other.

If we’re using objects in our application and we want to save them, we’ll probably use some data base system. We’ll most likely establish a connection to the data base, create a SQL sentence with the values of the object (or call some kind of stored procedure), and save them to some table. Easy enough, right? Well, this may seem trivial for a small object with 4 or 5 properties. Just consider an object not so small, with 40 or 50 properties. But… what happens with associations? And… what if the object itself contains some other objects? We’ll store them in the data base as well? All of them or just some? What will we do with foreign keys? We can see that, as the application gets more complex, this translation is not so trivial anymore… As a matter of fact, storing objects in the database can become a very usual source of headaches. There are some studies which state that up to 35% of code is dedicated to the role of translating data between the application and the data warehouse.

Read the rest of this entry »

Which database to use for a personal project?

When starting a new project, the choice of which database to use usually boils down to the one the company usually uses. The systems that are usually considered are just Oracle and Microsoft’s SQL server (MS-SQL). There’s no doubt that big bucks companies have the resources to make the best-of-its-breed products, and almost no other database system comes close to what Oracle and MS-SQL can offer in terms of quality, features, and highly skilled professionals around their products. Yes, all this is true, but there’s a price. And usually this price tag can only be afforded by a company, not by a sole individual.

So, what if I want to develop my own personal project and I require a RDBMS (Relational DataBase Management System)? Oracle and MS-SQL are out of the question because of their high cost. MS-SQL Express has great limitations, so, although it is free, we won’t be considering it for our purpose. Which is the best open source RDBMS?

Read the rest of this entry »

Sluggish database view? Materialize it!

The other day we were having some slow database view at our project. It was the main view of the new module we were developing, and it was slowing down the whole application to an unacceptable point. It was a rather complex view and could not be optimized much more. So, what was the solution we adopted? We materialized the view.

Regular views store just the SQL script needed to retrieve the data, and every time they are consulted the stored SQL query is executed. However, materialized views not only store the script, but the retrieved records as well, making it much faster.

Read the rest of this entry »