relations between tables to json