From: Michael Orlitzky Date: Mon, 20 Jan 2014 16:05:31 +0000 (-0500) Subject: Update the schema documentation. X-Git-Tag: 0.0.1~34 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=9f3133c83b714b9068f01e8d508023bdbed70aa9;p=dead%2Fhtsn-import.git Update the schema documentation. Add ON DELETE CASCADE for the references in TSN.XML.Odds. --- diff --git a/doc/man1/htsn-import.1 b/doc/man1/htsn-import.1 index 66506c6..957382d 100644 --- a/doc/man1/htsn-import.1 +++ b/doc/man1/htsn-import.1 @@ -68,19 +68,27 @@ that we import. For example, the documents corresponding to These top-level tables will often have children. For example, each news item has zero or more locations associated with it. The child table will be named _, which in this case -corresponsds to \(dqnews_locations\(dq. +corresponds to \(dqnews_locations\(dq. .P -To relate the two, a third table exists with name __. Note the two underscores. This prevents -ambiguity when the child table itself contains underscores. As long we -never go more than one level down, this system should suffice. The -table joining \(dqnews\(dq with \(dqnews_locations\(dq is thus called +ambiguity when the child table itself contains underscores. The table +joining \(dqnews\(dq with \(dqnews_locations\(dq is thus called \(dqnews__news_locations\(dq. .P -Wherever possible, children are kept unique to prevent pointless -duplication. This slows down inserts, and speeds up reads (which we -assume are much more frequent). The current rate at which the feed -transmits XML is much too slow to cause problems inserting. +Where it makes sense, children are kept unique to prevent pointless +duplication. This slows down inserts, and speeds up reads (which are +much more frequent). There is a tradeoff to be made, however. For a +table with a small, fixed upper bound on the number of rows (like +\(dqodds_casinos\(dq), there is great benefit to de-duplication. The +total number of rows stays small, so inserts are still quick, and many +duplicate rows are eliminated. +.P +But, with a table like \(dqodds_games\(dq, the number of games grows +quickly and without bound. It is therefore more beneficial to be able +to delete the old games (though an ON DELETE CASCADE, tied to +\(dqodds\(dq) than it is to eliminate duplication. A table like +\(dqnews_locations\(dq is somewhere in-between. .P UML diagrams of the resulting database schema for each XML document type are provided with the \fBhtsn-import\fR documentation. diff --git a/src/TSN/XML/Odds.hs b/src/TSN/XML/Odds.hs index 10d34a4..67ddbd4 100644 --- a/src/TSN/XML/Odds.hs +++ b/src/TSN/XML/Odds.hs @@ -434,11 +434,27 @@ mkPersist tsn_codegen_config [groundhog| fields: - name: odds_OddsGame0 # Default created by mkNormalFieldName dbName: odds_id + reference: + onDelete: cascade - name: odds_OddsGame1 # Default created by mkNormalFieldName dbName: odds_games_id + reference: + onDelete: cascade - entity: OddsGame_OddsGameTeam dbName: odds_games__odds_games_teams + constructors: + - name: OddsGame_OddsGameTeam + fields: + - name: ogogt_odds_games_id + reference: + onDelete: cascade + - name: ogogt_away_team_id + reference: + onDelete: cascade + - name: ogogt_home_team_id + reference: + onDelete: cascade |] instance DbImport Message where