I have not had time to work on the project much lately because of a trip to Boston, but I figured I would post our Models. Maybe people can give some feedback on the schema we're moving forward with presently.
Code:
from google.appengine.ext import db
class Team(db.Model):
"""
Teams represent FIRST Robotics Competition teams.
key_name is like 'frc177'
"""
team_number = db.IntegerProperty(required=True)
name = db.StringProperty()
nickname = db.StringProperty()
address = db.PostalAddressProperty() # If we can scrape this.
website = db.LinkProperty()
first_tpid = db.IntegerProperty() #from USFIRST. FIRST team ID number. -greg 5/20/2010
class Event(db.Model):
"""
Events represent FIRST Robotics Competition events, both official and unofficial.
key_name is like '2010ct'
"""
name = db.StringProperty()
event_type = db.StringProperty() # From USFIRST
short_name = db.StringProperty() # Should not contain "Regional" or "Division", like "Hartford"
event_short = db.StringProperty(required=True) # Smaller abbreviation like "CT"
year = db.IntegerProperty(required=True)
start_date = db.DateTimeProperty()
end_date = db.DateTimeProperty()
venue = db.StringProperty()
venue_address = db.PostalAddressProperty() # We can scrape this.
location = db.StringProperty()
official = db.BooleanProperty(default=False) # Is the event FIRST-official?
first_eid = db.StringProperty() #from USFIRST
website = db.StringProperty()
class EventTeam(db.Model):
"""
EventTeam serves as a join model between Events and Teams, indicating that
a team will or has competed in an Event.
"""
event = db.ReferenceProperty(Event,
collection_name='teams')
team = db.ReferenceProperty(Team,
collection_name='events')
class Match(db.Model):
"""
Matches represent individual matches at Events.
Matches have many Videos.
Matches have many Alliances.
key_name is like 2010ct_qm10 or 2010ct_sf1m2
"""
event = db.ReferenceProperty(Event,
collection_name='matches',
required=True)
time = db.DateTimeProperty()
comp_level = db.StringProperty(required=True,choices=set(["Qualifications", "Quarterfinals", "Semifinals", "Finals"])) # This choices set should probably become a global Constant somewhere. How do you do that in Python properly? -greg 5/20/2010
set_number = db.IntegerProperty(required=True)
match_number = db.IntegerProperty(required=True)
class MatchTeam(db.Model):
"""
A join class between Teams and Matches. Serves to store alliance information
Based on code from: http://code.google.com/appengine/articles/modeling.html
"""
match = db.ReferenceProperty(Match,
collection_name='teams',
required=True)
team = db.ReferenceProperty(Team,
collection_name='matches',
required=True)
alliance = db.StringProperty(choices=set(["red", "blue"]),
required=True)
substitute = db.BooleanProperty(default=False) #indicate the team was a substitute on the Alliance
class MatchScore(db.Model):
"""
A one to many relationship class that stores alliance scores for each Match
"""
match = db.ReferenceProperty(Match,
collection_name='scores',
required=True)
alliance = db.StringProperty(choices=set(["red", "blue"]),
required=True)
score = db.IntegerProperty()
class TBAVideo(db.Model):
"""
Store information related to videos of Matches hosted on
The Blue Alliance.
"""
match = db.ReferenceProperty(Match,
collection_name='tba_videos',
required=True)
location = db.StringProperty()
class YoutubeVideo(db.Model):
"""
Store information related to videos of Matches hosted on YouTube.
"""
match = db.ReferenceProperty(Match,
collection_name='youtube_videos',
required=True)
youtube_id = db.StringProperty()