Reworked database definitions to get just ONE query

No more three tables for you sorry. 

I also removed the two mysql connections. Don't know why they were there. You can change them if you want to. 

You won't have duplicate entries anymore, since I put unique key on them.