I have two tables/entities:
One table Users with these 3 fields : id | login | external_id
There is a unique constraint on external_id but not on login
And another table User_Platforms that have these 3 fields : id | user_id | platform_name
There is a @OneToMany relation between Users and Platforms. ( One user can have multiple platforms). Is there a way to put a unique constraint on the fields login ( from Users table) and platform_name ( from User_Platforms table) to avoid having multiple users with the same login on the same platform ?
I was thinking of duplicating login field inside User_Platforms table to be able to do it easily. Is there a better way ?