Data Model - ignacioch/GameSetMatch.firebase GitHub Wiki
Leagues
Leagues (Collection)
│
└── league123 (Document)
├── league_name: "North City League"
├── area: "area1_id" # Reference to Areas Collection
├── current_round: 2
├── running: False
├── Groups (Subcollection)
│ ├── group1 (Document)
│ │ ├── players (Subcollection)
│ │ │ ├── player1_id (Document)
│ │ │ ├── player2_id (Document)
│ │ ├── Matches (Subcollection)
│ │ │ ├── match1_id (Document)
│ │ │ │ ├── player_a_id: "player1_id"
│ │ │ │ ├── player_b_id: "player2_id"
│ │ │ │ ├── score: "6-3, 6-4"
│ │ │ │ ├── location: "Court 1"
│ │ │ ├── match2_id (Document)
│ │ └── ...
│ └── group2 (Document)
│ ├── players (Subcollection)
│ │ ├── player4_id (Document)
│ │ ├── player5_id (Document)
│ ├── Matches (Subcollection)
│ │ ├── match3_id (Document)
│ │ ├── match4_id (Document)
│ └── ...
├── UnallocatedPlayers (Subcollection)
│ ├── player6_id (Document)
│ ├── player7_id (Document)
│ └── ...
├── ArchivedRounds (Subcollection)
├── round1 (Document)
│ ├── Groups (Subcollection)
│ │ ├── group1 (Document)
│ │ │ ├── players (Subcollection)
│ │ │ │ ├── player1_id (Document)
│ │ │ │ ├── player2_id (Document)
│ │ │ ├── Matches (Subcollection)
│ │ │ │ ├── match1_id (Document)
│ │ │ │ │ ├── player_a_id: "player1_id"
│ │ │ │ │ ├── player_b_id: "player2_id"
│ │ │ │ │ ├── score: "6-3, 6-4"
│ │ │ │ │ ├── location: "Court 1"
│ │ │ │ ├── match2_id (Document)
│ │ │ └── ...
│ │ └── group2 (Document)
│ │ ├── players (Subcollection)
│ │ │ ├── player4_id (Document)
│ │ │ ├── player5_id (Document)
│ │ ├── Matches (Subcollection)
│ │ │ ├── match3_id (Document)
│ │ │ ├── match4_id (Document)
│ │ └── ...
└── round2 (Document)
├── Groups (Subcollection)
│ ├── [Similar structure as round1]
└── ...
This collection stores information about various leagues.
-
Document ID: Each document in the Leagues collection represents a unique league, identified by a unique league_id. Fields in Each League Document
-
league_name
: The name of the league (e.g., "North City League"). -
location
: The geographical location of the league (e.g., "North City"). -
current_round
: The current round number of the league. Increments as rounds progress. -
running
: A boolean flag indicating if the league is currently active (True) or not (False).
Subcollections in Each League Document
groups (Subcollection): Represents the groups within the current round of the league.
Each document in the Groups subcollection represents a group. Each group document contains:
players
(Subcollection): A list of players in the group, each represented by a document.matches
(Subcollection): A list of matches played in the group, each represented by a document containing match details like player_a_id, player_b_id, score, and location.
unallocatedPlayers (Subcollection): Contains documents representing players who have joined the league but have not yet been allocated to a group.
archivedRounds (Subcollection): Stores historical data of completed rounds.
Each document represents a completed round (e.g., round1, round2) and contains: Groups (Subcollection): A structure similar to the active groups, preserving the details of groups and matches for historical reference.
Players
├── Players (Collection)
│ ├── player1_id (Document)
│ │ ├── name: "John Doe"
│ │ ├── email: "[email protected]"
│ │ ├── DOB: "1990-01-01"
│ │ ├── level: "Intermediate"
│ │ └── leagues: ["league123", "league456"]
| │ └── areas: ["area1_id", "area2_id"] # References to Areas Collection
| | └── ranking : 1200
│ ├── player2_id (Document)
│ │ └── ... (other player details)
│ └── ... (more player documents)
This collection stores information about players participating in the leagues.
Document ID: Unique identifier for each player (player_id).
Fields in Each Player Document
name
: The player's name.email
: The player's email address.DOB
: The player's date of birth.level
: The player's skill level (e.g., "beginner", "intermediate").leagues
: A list of league IDs that the player is participating in.
Matches
└── Matches (Collection)
├── match1_id (Document)
│ ├── player_a_id: "player1_id"
│ ├── player_b_id: "player2_id"
│ ├── score: "6-3, 6-4"
│ ├── date: "2023-03-28"
│ └── location: "area1_id" # Reference to Areas Collection
├── match2_id (Document)
│ └── ... (other match details)
└── ... (more match documents)
This collection stores information about individual matches played in the leagues.
Document ID: Unique identifier for each match (match_id).
Fields in Each Match Document
player_a_id
: Player ID of the first player.player_b_id
: Player ID of the second player.score
: The score of the match.date
: The date on which the match was played.location
: The location of the match.
Areas
Areas (Collection)
|
|-- area1_id (Document)
| |-- country: "Country A"
| |-- subarea: "Subarea A1"
|
|-- area2_id (Document)
|-- country: "Country A"
|-- subarea: "Subarea A2"