title: Flask SQLAlchemy: Child table with multiple parents?
body: <p>I'm new to flask_sqlalchemy, and while I understand how the one-to-many, and many-to-many relationships work, I'm struggling to understand how I can apply them to my specific data types. I have the following three tables: TeamStat, PlayerStat, and Stat which are loosely described as follows</p>
  
  <pre><code>class PlayerStat(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      date = db.Column(db.DateTime, nullable=False, default=datetime.datetime)
      player_id = db.Column(db.Integer, db.ForeignKey('player.player_id'), nullable=False)
  
  class TeamStat(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      date = db.Column(db.DateTime, nullable=False, default=datetime.datetime)
      team_id = db.Column(db.Integer, db.ForeignKey('team.team_id'), nullable=False)
  
  
  class Stat(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      value = db.Column(db.String(80), nullable=False)
  </code></pre>
  
  <p>Since Stat is a generic table type, I would like to use it by both the PlayerStat table (for individual player stats), as well as the TeamStat table (as a sum of the stats for all players on a team). Can someone help me understand how I can refer one child table to multiple parent tables in this fashion?</p>