Database
Our Home Control System (HCS) needs a database to store persistent data and in some rare cases to allow exchange information between processes. We started out with a simple Java class, with the intention of using this as a wrapper to a commercial or open-source database. We rapidly realised that all we needed was a simple way or reading and writing name-value pairs. The kind of data we store in our database are things like house status, alarm status, network status, etc. and generally these don't result in large volumes of reads or writes.
To enable initial testing and development, we wrote a simple database Java class that stores data in text files. The text files are also written as Javascript code, so that they can be directly included in web pages on our HCS web interface. To make the reads and writes as quick as possible, these files are stored on a USB Flash drive. The advantage of this approach is that we can also test scenarios by editing these text files manually. This approach has been 100% reliable for more than eight years, so (following the engineering first law) we have left it alone. There have been no issues with file locking either. It's very simple and it does the job required.
The latest Java source code is here for those interested. When we fnd this approach no longer meets our needs, we will deploy a proper database onto our Home Control System (HCS) server. Something like MySQL is the most likely candidate but, this will probably require another server upgrade.
