Implemented database handling code

If the database were to have the correct format, there might be the
correct output. So now I'll have to change the database creation code to
take into account the general situation.