views:

24

answers:

1

What would be the best database/technique to use if I'd like to create a database that can "add", "remove" and "edit" tables and columns?

I'd like it to be scaleable and fast.

Should I use one table and four columns for this (Id, Table, Column, Type, Value) - Is there any good articles about this. Or is there any other solutions?

Maybe three tables: One that holds the tables, one that holds the columns and one for the values?

Maybe someone already has created a db for this purpose?

My requirements is that I'm using .NET (I guess the database don't have to be on windows, but I would prefer that)

A: 

Since (in comments on the question) you are aware of the pitfalls of the "inner platform effect", it is also true that this is a very common requirement - in particular to store custom user-defined columns. And indeed, most teams have needed this. Having tried various approaches, the one which I have found most successful is to keep the extra data in-line with the record - in particular, this makes it simple to obtain the data without requiring extra steps like a second complex query on an external table, and it means that all the values share things like timestamp/rowversion for concurrency.

In particular, I've found a CustomValues column (for example text or binary; typically json / xml, but could be more exotic) a very effective way to work, acting as a property-bag for the additional data. And you don't have to parse it (or indeed, SELECT it) until you know you need the extra data.

All you then need is a way to tie named keys to expected types, but you need that metadata anyway.

I will, however, stress the importance of making the data portable; don't (for example) store any specific platform-bespoke serialization (for example, BinaryFormatter for .NET) - things like xml / json are fine.

Finally, your RDBMS may also work with this column; for example, SQL Server has the xml data type that allows you to run specific queries and other operations on xml data. You must make your own decision whether that is a help or a hindrance ;p


If you also need to add tables, I wonder if you are truly using the RDBMS as an RDBMS; at that point I would consider switching from an RDBMS to a document-database such as CouchDB or Raven DB

Marc Gravell
Thanks, I will look into your suggestions and RavenDB. And RDBMS was never a requirement :)
Andreas