update implementation of Database.
added documentation.