The first example is sufficient. Even if you were to add attributes to the many-to-many table construct (like is_main_grp
, etc.), there is no real need for a surrogate in the link table, and you'll probably always want a unique constraint on user_id
, group_id
anyway.
Only if you were to hang another many-to-one relationship on the link relationship (like tags), THEN I would think about having a surrogate in the user_group
table, and I would not do it until it was a requirement (since a surrogate is relatively easy to add):
user
id*
name
group
id*
name
user_group
id*
user_id
group_id
is_main_grp
user_group_tags
user_group_id*
tag_id*
tags
id*
tag_txt