Dynamic data-entry value store

Posted by simendsjo on Stack Overflow See other posts from Stack Overflow or by simendsjo
Published on 2010-05-29T09:39:48Z Indexed on 2010/05/29 9:42 UTC
Read the original article Hit count: 317

Filed under:
|
|

I'm creating a data-entry application where users are allowed to create the entry schema.

My first version of this just created a single table per entry schema with each entry spanning a single or multiple columns (for complex types) with the appropriate data type. This allowed for "fast" querying (on small datasets as I didn't index all columns) and simple synchronization where the data-entry was distributed on several databases.

I'm not quite happy with this solution though; the only positive thing is the simplicity... I can only store a fixed number of columns. I need to create indexes on all columns. I need to recreate the table on schema changes.

Some of my key design criterias are:

  • Very fast querying (Using a simple domain specific query language)
  • Writes doesn't have to be fast
  • Many concurrent users
  • Schemas will change often
  • Schemas might contain many thousand columns
  • The data-entries might be distributed and needs syncronization.
  • Preferable MySQL and SQLite - Databases like DB2 and Oracle is out of the question.
  • Using .Net/Mono

I've been thinking of a couple of possible designs, but none of them seems like a good choice.

Solution 1: Union like table containing a Type column and one nullable column per type.

This avoids joins, but will definitly use a lot of space.

Solution 2: Key/value store. All values are stored as string and converted when needed.

Also use a lot of space, and of course, I hate having to convert everything to string.

Solution 3: Use an xml database or store values as xml.

Without any experience I would think this is quite slow (at least for the relational model unless there is some very good xpath support). I also would like to avoid an xml database as other parts of the application fits better as a relational model, and being able to join the data is helpful.

I cannot help to think that someone has solved (some of) this already, but I'm unable to find anything. Not quite sure what to search for either...

I know market research is doing something like this for their questionnaires, but there are few open source implementations, and the ones I've found doesn't quite fit the bill.

PSPP has much of the logic I'm thinking of; primitive column types, many columns, many rows, fast querying and merging. Too bad it doesn't work against a database.. And of course... I don't need 99% of the provided functionality, but a lot of stuff not included.

I'm not sure this is the right place to ask such a design related question, but I hope someone here has some tips, know of any existing work, or can point me to a better place to ask such a question.

Thanks in advance!

© Stack Overflow or respective owner

Related posts about c#

Related posts about database-design