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