Whether to store data in SQL as key value pairs

It can be tempting to store unstructured data as key value pairs to avoid lots of schema changes and capture dynamic data.  But it can lead to problems.

  • Overly complex queries/reporting
  • No type support

This article explains some of the issues.

My conclusion is that it is fine if you will only be accessing the data rather than querying it, or as a temporary capture means until you’ve identified where the data really belongs.

If you have another way to query, like a Lucene index it may also be perfectly fine.

Update:

A key value store NoSQL solution may be appropriate, but that brings with it other baggage.  Depending on the NoSQL solution you choose, you may have to do some extra work to get the type of search you need or use a Lucene style indexing solution anyway.

If you are using PostgreSQL, you can get much of the best of both worlds using hstore.

And you can easily use it with rails!

This will have the drawback of not being portable to other SQL backends, but that may be a tradeoff worth making.

With the PostgreSQL solution, you can retain one datastore and still allow some ability to store unstructured key values.  Then as needed, you can integrate these back into the schema to permanent normalized columns.

Snow Leopard Apache Web Server SSL Pass phrase Error

If you are getting errors “Pass phrase incorrect” in your apache logs on Snow Leopard server, it is because the key is protected by a password.  I found the answer here.

The password for the key is stored in the System Keychain.  It is a password entry called “Mac OS X Server certificate management”.  You can open the entry and select “Show Password”.  You may also use the security command line tool to dump the password.

security find-generic-password -l "Mac OS X Server certificate management" -g

or

security dump-keychain -d # look in data for password which will look like a GUID

Once you have the password, you can create a copy of the key without the password using openssl:

openssl rsa -in /etc/certificates/server.domain.com.uniqueid.key.pem \
 -out /etc/certificates/server.domain.com.uniqueid.passwordlesskey.pem

You can then replace the password protected key with the passwordless key or point apache to the passwordless key in your /etc/apache2/sites/sitename.conf file.