I am designing a database to hold past and future data of a scientific research project. I tried to simplify the discussion by removing all non-database-related terms :)
Description
Let's say we have a collection of Foo and Bar objects. Each Bar is a child of a Foo, in the sense that it belongs to it. Both Foos and Bars can have an unlimited number of properties (attributes). Different properties can have different data types, which can be numbers, texts, images, files etc. Moreover, each property of each object has an history of values, which must be stored in the database.
I want to be able to add new properties without editing the structure of the database. I am not forced to use any particular database software, but I would like to have a Python interface to it, since everybody in the group can use Python. Finally, it would useful if the database was file-based.
Example
This is a diagram to better represent the description above. Hope it helps.
My attempt
I decided to try with SQLite, to have file-based database that was easily accessible with Python. This is the database schema I adopted:
I am using Python's sqlite3
to connect to it and pickle
to put the different type of data inside the BLOB value
column. The disadvantage with of this approach is of course that SQLite has no idea of what's inside value
, therefore I need to retrieve everything every time to run searches, and I can't take advantage of SQL queries.
The question, finally
Is there a better (e.g. easier to code || faster || already available || ...) solution to this problem? Again, I am not bound to any particular kind of database. I am a physicist with a little background in computer science, so any help is appreciated.