Normally you would set it up as a many to many between User and Site, with a relationship table “sites_users”. And with a many to many between this relationship table and Group.
Alternatively you could setup a relationship table with a compound key, where you create relations between any combination of user_id and site_id, an a Group.
But both scenario’s are currently not supported by DataMapper.
As a workaround, you could create a model for your “sites_users” table, and have that relate to Group. You can then define a one to many between User and this model, and between Site and this model, and give this model a many to many relation with Group
You can than then get a user, get the related “sites_users” record on site_id, and with that record, fetch all related groups.
I hope I made this clear, it’s quite a complicated workaround.