+instance ToDb ScoreGameXml where
+ -- | The database representation of a 'ScoreGameXml' is a
+ -- 'ScoreGame'.
+ --
+ type Db ScoreGameXml = ScoreGame
+
+
+instance Child ScoreGameXml where
+ -- | Each 'ScoreGameXml' is contained in (i.e. has a foreign key to)
+ -- a 'Score'.
+ --
+ type Parent ScoreGameXml = Score
+
+
+instance FromXmlFkTeams ScoreGameXml where
+ -- | To create a 'ScoreGame' from a 'ScoreGameXml', we need three
+ -- foreign keys: the parent message, and the away/home teams.
+ --
+ from_xml_fk_teams fk fk_away fk_home ScoreGameXml{..} =
+ ScoreGame {
+ db_scores_id = fk,
+ db_away_team_id = fk_away,
+ db_home_team_id = fk_home,
+ db_away_team_score = xml_away_team_score,
+ db_home_team_score = xml_home_team_score,
+ db_away_team_pitcher = xml_vpitcher xml_vteam,
+ db_home_team_pitcher = xml_hpitcher xml_hteam,
+ db_time_r = xml_time_r,
+ db_status = xml_status,
+ db_notes = xml_notes }
+
+-- | This lets us import the database representation 'ScoreGameXml'
+-- directly.
+--
+instance XmlImportFkTeams ScoreGameXml
+
+
+
+-- * Score_Location
+
+-- | Join each 'Score' with its 'Location's. Database-only. We use a
+-- join table because the locations are kept unique but there are
+-- multiple locations per 'Score'.
+--
+data Score_Location =
+ Score_Location
+ (DefaultKey Score)
+ (DefaultKey Location)