Updated to_database() method.