Extracted storage to database class.

Have the old files as database_flatfile and a new database_mysql now.