Skip to content

Tournaments ~ Tables.md

Riyush edited this page Nov 14, 2023 · 1 revision

Table: User

  • Columns
  • name (string) PRIMARY KEY
  • first_name (string)
  • last_name (string)
  • email (string)
  • username (string)
  • USERNAME_FIELD (string) // Not sure what this is exactly but it's in existing model
  • Required_Fields (List)
  • objects (UserManager)
  • Constraints
  • Unique: username, email

Table: Tournament

  • Columns
  • TournmantID (autoincrementing integer) PRIMARY KEY
  • GameID (int) references Game (GameID)
  • Users (ManytoManyField)
  • Name (string)
  • StartDate (datetime)
  • EndDate (datetime)
  • MaxPlayers (integer)
  • Description(string)
  • Rules (string)
  • DrawRule(string)
  • Constraints
  • Unique: TournamentID
  • auto_now_add: StartDate, EndDate
  • ManytoManyField: Users
  • Foreign Key: GameID

Table: Tournament - User (M-N table)

  • Columns
  • TournamentID (int)
  • UserID (int)
  • Status (string, one of ('pending', 'approved', 'rejected'))
  • Constraints
  • TournamentID, UserID

Table: Match

  • Columns
  • MatchID (autoincrementing integer) PRIMARY KEY
  • TournamentID (int) references Tournament (TournamentID)
  • Users (ManytoManyField) references User (UserID)
  • MatchStatus (string, one of ('Ongoing', 'Completed, 'Draw'))
  • MatchStartDate (datetime)
  • MatchEndDate (datetime)
  • MatchDuration (string)
  • Score (string)
  • Constraints
  • Unique: MatchID
  • auto_now_add: MatchStartDate, MatchEndDate
  • Foreign key: TournamentID

Table: Match - User (N-M Table)

  • Columns
  • MatchID (int)
  • UserID (int) references User (UserID)
  • Status (string, one of ('Player', 'Spectator'))

Table: Game

  • Columns
  • GameID (autoincrementing integer) PRIMARY KEY
  • GameName (string)

Table: Notification

  • Columns:
  • NotificationID (autoincrementing integer) PRIMARY KEY
  • Content (string)
  • TimeStamp (datetime) # DateTimeField with auto_now_add=True
  • Visibility (string, one of ('Spectators Only', 'Players Only', 'Both'))
  • Users (ManytoManyfield)

Table: Notifications - Users (N-M Tables)

  • Columns
  • NotificationID (int)
  • UserID (int)
  • Status (string, one of ('Pending', 'Sent', 'Received'))

Table: Chat

  • Columns
  • ChatID (autoincrementing integer) PRIMARY KEY
  • MatchID (OnetoOneField) references Match (MatchID)

Table: Message

  • Columns
  • MessageID (autoincrementing integer) PRIMARY KEY
  • ChatID (int) references Chat (ChatID)
  • UserID (int) references User (UserID)
  • Content (string)
  • TimeStamp (datetime) # DateTimeField with auto_now_add=True
  • Constraints:
  • Foreign Key: ChatID, UserID
Clone this wiki locally