'Entity relations JDL-Studio
I´m creating a project in jhipster and I need to access to this metrics and structure:
Structure:
Of the players we want to save:
- Nickname (unique) can only be formed by: letters, numbers and underscore.
 - Name
 - Surname
 - Date of birth
 
Secondly, we must create the necessary structure to host the games. For each game played we want to save:
- Player who has won the game
 - Player who has lost the game
 - Number of points of the winner
 - Game played
 
Metrics:
- For a specific player, whose nickname must be provided, list of games won.
 - For a given player, number of games won.
 - List of players who have won playing a given game.
 
My problem is that the list of players to match with the list of winner and losers and right now this is not happening. The is a list of players with nickname etc and a different one not related of winners and losers.
How can I create the relationship in this case?
This is my code so far in JDL-Studio. It doesn´t work.
entity Player {
    nickname String unique pattern(/[a-zA-Z0-9_]+/),
    name String,
    surname String,
    dateOfBirth LocalDate
}
entity Game {
    winnerPoints Integer,
    loser String,
    winner String,
    game String
}
relationship ManyToMany {
    Game{player(nickname)} to Player{game}
}
							
						Solution 1:[1]
Winner and loser should not be strings, they should be 2 relationships to Player. Also it seems strange that Game entity has a game field, either the entity is badly named or it's the field.
entity Player {
    nickname String unique pattern(/[a-zA-Z0-9_]+/),
    name String,
    surname String,
    dateOfBirth LocalDate
}
entity Game {
    winnerPoints Integer,
    game String
}
relationship ManyToOne {
    Game{winner(nickname)} to Player,
    Game{loser(nickname)} to Player
}
    					Solution 2:[2]
Regarding the last question, try making the relationship required:
relationship ManyToOne {
    Game{winner(nickname) required} to Player,
    Game{loser(nickname) required} to Player
}
    					Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | |
| Solution 2 | 
