I am starting to develop an application in which user can create bets. Given the following scheme
TABLE Player
PlayerID PRIMARY KEY
PlayerName
(...)
TABLE Bet
BetID PRIMARY KEY
BetName
(...)
TABLE plays_in
BetID
PlayerID
PRIMARY KEY(BetID, PlayerID)
FOREIGN KEY BetID
FOREIGN KEY PlayerID
Is it in any way possible to define an uniqueness for (BetName, PlayerID), in order that a Bet can have the same name multiple times, but only once for a player? Meaning that a certain player can participate only once in a bet named "MyFirstBet"? I don't want to define the bet name as a primary key or unique, because any other player that will not play this bet with the player above, should be able to name his bet "MyFirstBet" once too. If possible, I want to avoid to create an extra table for that too. Is this a problem to solve in code and not in the DBMS?