Defined latest group and building db functions and implemented db.py to the routes.

- Edited db.py queries.
- two new db.py functions 
- imported db.py to density.py and implemented to routes
can we standardize this to the format used elsewhere?

something like:
```python
query = """SELECT *
            FROM {table_name}
            WHERE dump_time=(
                SELECT MAX(dump_time)
                FROM {table_name}
            );""".format(table_name=TABLE_NAME)"
```