V
V
Vladislav2015-09-03 21:57:59
SQL
Vladislav, 2015-09-03 21:57:59

Need help building tables and organizing a grid?

There are a couple of tables
Tournaments
Matches
Players
Teams
a stripped down version of their relationship:
Tournaments:
id | name |
1 | abc |
Matches:
id | team | tournament | is Winner |
0 | A | 1 | false |
1 | b | 1 | true |
a small explanation - according to the table above:
within the same tournament (id = 1) there can be several matches, the table shows that team B won against A.
tell me if I store tournament matches correctly?
And the second question is how to build a tournament bracket on the client and how to determine what stage the match is final or semi-final or 1/8?
If it's important use spring-data-jpa, hibernate > java,
base is not important postgres, mysql, H2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
heartdevil, 2015-09-04
@heartdevil

Hello.
According to your truncated structure, it is not clear who played with whom.
To oppose the two teams, add another link field to the team table.
If you have a knockout tournament, then the structure, in my opinion, is normal. Add one more link field to the Tournament Stage (values ​​1/8, 1/4, 1/2, 1). And when adding teams to the Matches table, just specify the stage.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question