Couple of changes on postgreSQL tables structure to make it working