There's a lot of solutions to this fairly common problem, with object oriented databases being the solution that most directly relates to it.
Object oriented databases was a very hot topic about 8-10 years ago, but never made it into the mainstream programming world. They are still out there, but I think they're typically very expensive, and not broadly used.
Here's an approach I've used for datastructures that can be made serializable, and doesn't require foreing key relations (a concept the in itself implies relational databases):
- Make your datastructure serializable so that every instance of the object kan be serialized.
- Create a table with some common fields that all custom datastructures can provide, like a Name, a type, DateCreated, DateModified, the table should also contain a blob field for binary data
- Create an interface that corresponds to the table created above, but doesn't have property for the blob field
- Create a helper class with a method that recieves an object that implements the above mentioned interface, does a binary serialization on it, and then stores it in the table mentioned above, using the interface properties for the table fields, and the serialized object for the blob field.
- This class should also contain a method that fetches the object from the database on criteria based on the interface, and returns the deserialized object.
This method has some drawbacks:
- You'll have to have some way of identifying the objects that does not vary between different datastructures, this could be a guid, put on every object on creation time.
- You'll only be able to search for objects in the database based on the common criteria defined by the interface.
- You'll only be able to store objects that are serializable, but after all a row in a database table is a serialization of some set of data.
ORM's work by creating and managing your database from the code you write. A lot of them requires complex xml-files defining your datastructures, and won't give your developers much freedom.
Again if your datastructures are fairly simple, but you need to be able to change them while developing your product, there's a free, open sourced .NET product called SubSonic, which in V3 has something called SimpleRepository. This enables you to define your database from code, it doesn't require complex xml-files to setup, and if you change your datastructures, the SimpleRepository will make the necessary changes in your DB on the fly. Check it out on www.subsonicproject.com
Regards
Jesper Hauge