Build properties db

This is a full rewrite of #1380 (only the db part), as my git-foo is not good enough to let me do that kind of magic. So please review it carefully.

All data and process stuff has been left out.

I'm keeping #1380 around as reference.
Yes, `checkLength` exists just to avoid MySQL's ever-so-helpful habit of silently truncating inputs.  Other DB engines will either store the entire input, or give an error.