Flexible data models (by alaric)
One approach I'm wondering about is storing information in databases based on first-order predicate calculus. In these, rather than have a record with a fixed structure (An Address has a street1, a street2, a city, a county, and a postcode), we instead have a list of statements about objects, such as:
- Object123 is an address.
- Object123 has a street1 of '123 Any Street'
- Object123 has a city of 'Mytown'
- Object123 has a county of 'Myfordshire'
- Object123 has a postcode of 'MY1 2PC'
- Object456 is a Customer.
- Object456 has an address of Object123.
The nice thing about this is that it's inherently more flexible than the traditional table-based design; we can add statements to that such as 'Object456 has an address of Object789', and pow, we now have two addresses for one customer. Or 'Object123 is a geographical point; Object123 has latitude XXXXXX; Object123 has longitude YYYYYY', giving Object123 two "types" with all the properties of both.
This is how Prolog and RDF work, with some variations in the structure of their models. Prolog lets you have statements with any number of 'fields' in: 'Object123 has a temperature of 38 and a unit of Centigrade', which RDF does kind of support via reification, but it's messy and you'd otherwise have to represent as 'Object123 has a temperature of Object321; Object321 is a temperature; Object321 has a value of 38; Object321 has a unit of Centigrade'. I'm not sure which approach is best. There's something to be said for the latter, since in Prolog you can do it either way, and it's hard to know in advance which way will be right (thus leading us to have problems with needing to change things down the road...). But on the other hand, the way Prolog lets you do it is much less work to deal with and more efficient to implement.
But I have a hunch there's an even better way of doing it that I've not discovered yet...