CREATE OR REPLACE VIEW optimized_robots AS
SELECT
  r.path,
  array_agg(ua.user_agent ORDER BY ua.user_agent) AS user_agents
FROM
  robots AS r
JOIN
  robots_user_agents AS rua ON r.id = rua.robots_id
JOIN
  user_agents AS ua ON rua.user_agents_id = ua.id
GROUP BY
  r.path;