parsing data into database and joing various tables