On Sun, Dec 26, 2021, at 22:24, Joel Jacobson wrote:
> FROM permission p
> LEFT JOIN ON KEY p.permission_role_id_fkey r
> LEFT JOIN team_role tr ON KEY team_role_role_id_fkey TO r
> LEFT JOIN ON KEY tr.team_role_team_id_fkey t
> LEFT JOIN user_role ur ON KEY user_role_role_id_fkey TO r
> LEFT JOIN ON KEY ur.user_role_user_id_fkey u
I think readability can be improved by giving the foreign keys the same names as the referenced tables:
FROM permission p
LEFT JOIN ON KEY p.role r
LEFT JOIN team_role tr ON KEY role TO r
LEFT JOIN ON KEY tr.team t
LEFT JOIN user_role ur ON KEY role TO r
LEFT JOIN ON KEY ur.user u
Toughts?
/Joel