refactor db code

The `tbl_places` code doesn't work; and needs fixing.