resolves mysql relations