EAV and the .NET Framework

Posted: June 2nd, 2010 | Author: | Filed under: .NET General, Database | Tags: , | 7 Comments »

Recently I’ve been working on a web application’s database model in which I had different types of products and services that my client is going to offer in his eShop. The problem was different nature of attributes each type had and I should have defined a relationship between them and my online order pipleline. Using the common relational database approach I finished up with an OrderDetail table which had multiple foreign keys related to tables which was representing different kinds of products. Anyway, I’m not going to explain my project details here. That was a preface to explain a concept that Farid Arzpeyma introduced to me: Entity-Attribute-Value (EAV) Model, an approach that is widely used in enterprise eCommerce platforms like Magento.

There are many documents and articles out there describing EAV, its concept, principals and usages and I’m not going to talk about it here but quoting this which describes it shortly:

Entity-Attribute-Value model (EAV), also known as object-attribute-value model and open schema is a data model that is used in circumstances where the number of attributes (properties, parameters) that can be used to describe a thing (an “entity” or “object”) is potentially vast, but the number that will actually apply to a given entity is relatively modest. In mathematics, this model is known as a sparse matrix.

What I came up with in my mind was possible existing frameworks for .NET developers to implement this model in their applications. Because EAV breaks the rule in which we’re urged to use a vertical data representation (using columns) – by introducing another method of collecting data records and their types in table rows – it’s necessary to adopt our OOP code to smoothly interact with this new structure. By the time Microsoft hadn’t released SQL Server 2005, storing hierarchical data structures was a painful handy job for database developers but at the time Microsoft introduced XML datatype with SQL Server 2005 it became easier for them to natively store such structures right inside a column in a database. EAV is a similar concept and its main goal is to enable developers store attribute/value information in a table in a hierarchical manner.

Unfortunately it seems that there have been very few interests in the .NET community to work on open source frameworks in order to work with EAV database models. My searches shows a disappointing number of articles, blog posts and tools for this purpose.

The first article I found was Entity-Attribute-Value (EAV) model with SQL Server 2005 xml datatype that is talking about how to implement an EAV-like model using the new XML datatype in SQL Server 2005 and later. Mladen Prajdić has also referenced to another article explaining EAV in SQL Server more generally.

The second was a newer talking about a solution with Entity Framwork: Generic Entity Attribute Value Model – A POCO Implementation. This is closer to what I had in my mind because it’s talking about EAV in general and how to implement our data layer, built on EAV pattern, using EF.

And finally the third was an open source project on CodePlex but unfortunately it seems that it’s no longer active and there isn’t even a public release out.

My conclusion is, the .NET community hasn’t done much efforts on EAV concept and in my opinion it is because Microsoft policy – since creation of .NET Framework – has been just to spread this technology and best practices have rarely gone further on advanced and enterprise topics.


7 Comments on “EAV and the .NET Framework”

  1. 1 Tweets that mention Blogged: EAV and the .NET Framework -- Topsy.com said at 2:30 pm on June 2nd, 2010:

    [...] This post was mentioned on Twitter by mohamadreza, Mahdi. Mahdi said: Blogged: EAV and the .NET Framework http://bit.ly/bgkqsd [...]

    [WORDPRESS HASHCASH] The comment’s server IP (74.112.128.46) doesn’t match the comment’s URL host IP (74.112.128.10) and so is spam.

  2. 2 John Kings said at 10:16 pm on June 2nd, 2010:

    I point you to nopCommerce, an open source project that does exactly what you are looking for.

  3. 3 Mahdi Taghizadeh said at 10:49 pm on June 2nd, 2010:

    Thank you John. I’ll take a look at it.

    [WORDPRESS HASHCASH] The poster sent us ’0 which is not a hashcash value.

  4. 4 af said at 2:39 am on June 3rd, 2010:

    I don’t think this is as much a MS or .net thing as systems design in general. I’ve googled for days trying to find any real framework for EAV that would scale in the millions of records and found nothing. Hopefully some good hybrid frameworks will arise with the NOSQL movement.

  5. 5 Neal Blomfield said at 3:34 am on June 3rd, 2010:

    EAV has a number of problems and is, in reality, a hack for storing schema-less data in a schema bound mechanism ( RDBMS ).

    Where possible, a better approach may be to identify a schema-less datastore that fits into your system ( i.e. MongoDB / CouchDB / RavenDB ).

  6. 6 Mahdi Taghizadeh said at 9:32 am on June 3rd, 2010:

    @af
    @Neal

    Yes! NoSQL products like MongoDB and specially RavenDB have recently catched all sights and I hope it would be a good solution.

    Thank you for your comment.

  7. 7 ASP.NET MVC Framework Tutorial 2010 Part 2 | Download Free Ebook … | .NET WebDev Insider said at 5:01 pm on June 3rd, 2010:

    [...] EAV and the .NET Framework « Mahdi Taghizadeh [...]

    [WORDPRESS HASHCASH] The comment’s server IP (174.120.40.34) doesn’t match the comment’s URL host IP (174.120.40.62) and so is spam.


Leave a Reply

  •