About Data Driven Websites and Object Relation Modeling

I’ve reinstalled my machine of last night with Windows 7. I’m very happy with this new platform! Thank you Microsoft. One of the final reasons to start yesterday was that my database integration in Visual Studio was broken. Of course there where many more reasons, but that was the issue which made me do it yesterday evening.

So far so good. This morning I started of with a clean and very fast machine. Visual Studio 2008 was ready to roll. I’ve installed the Developer Edition of VSTS yesterday eve.

Today I decided to spent a little bit of time on getting the Entity Framework to work for a small, highly data-driven portal I’ve to develop. One of the issues with the portal is that it should be ready by yesterday. Not so much pressure, but I wanted to be highly productive. Unfortunately I’m highly disappointed.

While we all still claim that simplistic data driven websites should be online in a couple of hours, the truth is the opposite. I’ve got an app where you’ve got users. Users can be in a WorkGroup and some of those these users are leaders of the group. In objects:

  • User.WorkGroups –> List<WorkGroup>
  • WorkGroup.Users –> List<User> –> All users associated, incl leaders.
  • WorkGroup.Leaders –> List<User> –> All leaders

In the database you’ll store this as 3 tables: User, WorkGroup and an AssociationTable with a property ‘IsLeader’ (bit).

The database design was easily made, as I told you before, I decided to use the Entity Framework. But somehow I was absolutely unable to get this to work. I could get the User <-> WorkGroup(many to many relation) to work, but the Leader-relation couldn’t be made without modifying the generated code(or maybe the XML?). 

I’m sure one of you guys will give me the solution how to get this to work. And once again absolutely sure that this is not impossible. But I’m in general wondering why I couldn’t figure this out during the 2 hour R&D I’ve spent on it. The designer doesn’t seem to support something like that. Or it is hidden, somewhere. I’m not sure if this is just a limitation of the Entity Framework or of many O/R mappers.

I do know I generally dislike my whole process. I’ve been switching over and over between the different designers for my entities and database. This makes me wondering. What if this is your daily task? Getting a model designed by business users(interpretation I), normalize this(interpretation II), fit this into an object design(interpretation III) and maybe redo some of these part during one of the stages.

Let’s look from a perspective of a developer. I do not care about the database. It should just be stored. I care about the way I can access the data, so I want to control the types in my entities. My illusion: create a model(we’ve got a language for that: UML). Hit a button, and code + database should be ready.

Optimizations for storage and in the data access code should be done by the generation. The computer is way smarter when it comes to optimizing, it can calc all data access roads and ask if I want to flag more often used data. When I want to create a specific method(for example: GetById) I can define it in OCL.

The solution seems to be so obvious. Why can’t I find such a tool? I can find database generation tools, I can find O/R mappers. I can even find frameworks which should be O/R mappers(isn’t the Entity Framework the framework to be?). But none of these support my vision.

What can I do know? I can use a CMS to store my relational data. All my relational data, maybe thousands of records. I’ve to find a way how to store it internally as CMS’s use all kind of structures, but never a relational one.

I’ll end up in this project using an heavily modified Sitecore installation with lots of custom code to get around the limitations(I’m able to write that quickly as you can imagine). But hopefully you’ve seen my point. I gives me a huge headache in this age of data generation, web service generation for out scaling, advanced cache structures, cloud computing, etc.

Do you got a solution in mind for me?

Note: This is a post written out of my experience as an architect in many projects. I’m involved in general in Sitecore projects, but rarely I’ve got the opportunity to ‘work’ a little outside of this boxed environment. Often these high level problems arise as well in project where Sitecore is involved. I won’t blame a vendor, but I’m wondering why we smart guys are not able to solve issues like productivity without doing concessions on the business requirements.

3 thoughts on “About Data Driven Websites and Object Relation Modeling”

  1. Hi Alex,

    I don’t have a solution for you, but I understand where you’re coming from. I’m working on a large project myself and I have looked at a number of data frameworks and ORM mappers. I went through CSLA, my own framework, nHibernate, Spring, Linq to SQL, Telerik’s OpenAccess and have arrived at Entity Framework.

    My experience with EF is that is pretty good, but does have some frustrating experiences. I really struggled (believe it or not) to get a simple 1..* relationship working. Whether it was the designer or me being dumb, I don’t know. When someone suggested a solution (I ended up removing the foreign key field) it just made no sense to me. Today, I have a similar relationship for another couple of tables and it works fine.

    Hopefully EF 2.0 will be better.

    And there are times when I have wanted to use Sitecore just as a database, too! It maps so much better! How about a data engine without the UI layer? Fast, cached, field type flexibility, XMLy, better mapping to OO and scalable – add a UI when you’re ready as an extra layer. (Of course this should be free or very cheap!)

  2. Hi Alex,
    How did you install Sitecore on Windows 7? I am having the same challenge. I could not find any articles on this…
    Your help is much appreciated.
    Thanks

  3. Hi, has anyone used the ASR module (http://trac.sitecore.net/AdvancedSystemReporter/). I want to write a Command that will change things in some Items.

    As per the guide in http://trac.sitecore.net/AdvancedSystemReporter/wiki/Commands, it says all I have to do is write one method of the ICommand interface, but I cannot find this interface in the ASR dlls provided!? Is this a very old documentation, and if ICommand is deprecated then what do I use to write the command

    Has anyone written Commands in ASR and can help?

    (In particular, in the http://trac.sitecore.net/AdvancedSystemReporter/wiki/Commands, the picture shows a “References” section to enter the name of the class and dll assembly, where does that “references” even come from? A version of sitecore on another planet perhaps?

Comments are closed.