views:

101

answers:

1

Good Morning SO!

We've been scratching our heads with with this interesting scenario at the office, and we're anxious to hear your ideas and approaches:

  1. We have a database, whose schema is prone to changes -lets call it Prony-. (is used to store configuration parameters for embedded devices. so if the embedded devices guy need a new table, property or relationship for the model, he should be able to adapt the schema in a easy way -happens so often- ).

  2. Prony needs a web interface to create/edit its data (a set of simple CRUDs would be enough).

  3. We have another database containing data that also need to be loaded to the devices, after making some transformations - lets call this one Oddy- (this data it's generated by an already existent administrative web application).

  4. Finally we have Tracy, a server that communicates our DBs and our embedded devices. She should to auto-adapt herself, to our dbs schema changes and serialize the data to the devices.

Nice puzzle, don't think so? : )


Our current candidate:

  • Rady: The fast

    Lets create some views in Prony that make the data transformation from Oddy. then use DynamicData (or some RAD tool) to create/update a simple web interface for Prony (so he can even consult the transformated data from coming from Prony : ). About Tracy, she will need to be recompiled to update her DB schema (Entity framework should work) and use Reflection to explore recursively the schema and serialize data.

    Cons:

    • We would have to recompile Tracy and the Prony's web interface.

What do you think of the candidate?

Any ideas?

+2  A: 

One way to deal with a data model that is constantly changing after product release is to use the EAV Database Model, in whole or in part, of your database design. The EAV structure adds rows rather than columns or tables and allows for much less frequent schema changes (or none at all.)

It does come with its own set of caveats of course, such as the need to often pivot the data, but they can be managed. There are plenty of EAV dbs out there in production.

Performance note: People often worry about the performance of EAVs. i've have a number of EAVs with the EAV tables running well over 10 million records. Reads, inserts, updates and deletes are fine. The trouble comes in when you start doing heavy reporting on such a data structure. In your case you're storing config info for devices. That's not innocuous or trivial but I would say that that part of the db sounds like a great candidate for EAV since your reads and writes are going to be limited and i'm guessing that your reporting needs simple.

Paul Sasik
Hi Paul,Hey that's a nice idea, so schema changes could be done without recompiling : ) +1
SDReyes
Absolutely right. You just have to make sure that your code is as flexible as the persistence model. E.g. do you need to deal with new entities or will you only be adding/modifying the attributes of a set of known entities?
Paul Sasik
Hi Paul, in this case, Yes, we would also need to create new entities. nice point +1 again : ). I'm considering Umbraco for this (is already EAV and has a nice web interface too : ). we would just need to find out a way to integrate Umbraco with external DBS (Oddy). what do you think?
SDReyes
Does Oddy need to be a database? Seems like this is where you would put a web service which presents a config API and pulls the data from Prony? Or is Oddy a some flavor of compact db running on mobile devices? Btw, EAV is just fine for small dbs as well. i just wouldn't try OLAP-style reporting with it.
Paul Sasik
Hi again Paul, Oddy is already a DB, but we can expose a web service API. great idea : ) -we're ashamed to discover someone of the team proposed it since the start, how could we ignore it? lol-. EAV would be fine, this is just a config parameters db. thanks again : ) +1
SDReyes