I want to write a query that groups rows by having overlapping arrays. Consider the following example:
id | name | family_ids --------------------------