Made regions first-class objects.

This commit is contained in:
Eevee 2010-01-24 20:39:33 -08:00
parent e3c6cf7d10
commit 81eaf4a9ef
5 changed files with 141 additions and 100 deletions

View file

@ -1,5 +1,5 @@
id,name,main_region id,main_region_id,name
1,Generation I,Kanto 1,1,Generation I
2,Generation II,Johto 2,2,Generation II
3,Generation III,Hoenn 3,3,Generation III
4,Generation IV,Sinnoh 4,4,Generation IV

1 id main_region_id main_region name
2 1 1 Kanto Generation I
3 2 2 Johto Generation II
4 3 3 Hoenn Generation III
5 4 4 Sinnoh Generation IV

View file

@ -1,4 +1,4 @@
id,generation_id,name id,region_id,name
1,4,Canalave City 1,4,Canalave City
2,4,Eterna City 2,4,Eterna City
3,4,Pastoria City 3,4,Pastoria City
@ -62,95 +62,95 @@ id,generation_id,name
62,4,Sea Route 223 62,4,Sea Route 223
63,4,Sea Route 226 63,4,Sea Route 226
64,4,Sea Route 230 64,4,Sea Route 230
65,4,Blackthorn City 65,2,Blackthorn City
66,4,Burned Tower 66,2,Burned Tower
67,4,Celadon City 67,1,Celadon City
68,4,Cerulean City 68,1,Cerulean City
69,4,Cherrygrove City 69,2,Cherrygrove City
70,4,Cianwood City 70,2,Cianwood City
71,4,Cinnabar Island 71,1,Cinnabar Island
72,4,Dark Cave 72,2,Dark Cave
73,4,Diglett's Cave 73,1,Diglett's Cave
74,4,Dragon's Den 74,2,Dragon's Den
75,4,Ecruteak City 75,2,Ecruteak City
76,4,Fuchsia City 76,1,Fuchsia City
77,4,Ice Cave 77,2,Ice Cave
78,4,Ilex Forest 78,2,Ilex Forest
79,4,Lake of Rage 79,2,Lake of Rage
80,4,Mt. Moon 80,1,Mt. Moon
81,4,Mt. Mortar 81,2,Mt. Mortar
82,4,Mt. Silver 82,2,Mt. Silver
83,4,National Park 83,2,National Park
84,4,New Bark Town 84,2,New Bark Town
85,4,Olivine City 85,2,Olivine City
86,4,Pallet Town 86,1,Pallet Town
87,4,Rock Tunnel 87,1,Rock Tunnel
88,4,Route 1 88,1,Route 1
89,4,Route 10 89,1,Route 10
90,4,Route 11 90,1,Route 11
91,4,Route 12 91,1,Route 12
92,4,Route 13 92,1,Route 13
93,4,Route 14 93,1,Route 14
94,4,Route 15 94,1,Route 15
95,4,Route 16 95,1,Route 16
96,4,Route 17 96,1,Route 17
97,4,Route 18 97,1,Route 18
98,4,Route 19 98,1,Route 19
99,4,Route 2 99,1,Route 2
100,4,Route 20 100,1,Route 20
101,4,Route 21 101,1,Route 21
102,4,Route 22 102,1,Route 22
103,4,Route 24 103,1,Route 24
104,4,Route 25 104,1,Route 25
105,4,Route 26 105,1,Route 26
106,4,Route 27 106,1,Route 27
107,4,Route 28 107,1,Route 28
108,4,Route 29 108,2,Route 29
109,4,Route 3 109,1,Route 3
110,4,Route 30 110,2,Route 30
111,4,Route 31 111,2,Route 31
112,4,Route 32 112,2,Route 32
113,4,Route 33 113,2,Route 33
114,4,Route 34 114,2,Route 34
115,4,Route 35 115,2,Route 35
116,4,Route 36 116,2,Route 36
117,4,Route 37 117,2,Route 37
118,4,Route 38 118,2,Route 38
119,4,Route 39 119,2,Route 39
120,4,Route 4 120,1,Route 4
121,4,Route 40 121,2,Route 40
122,4,Route 41 122,2,Route 41
123,4,Route 42 123,2,Route 42
124,4,Route 43 124,2,Route 43
125,4,Route 44 125,2,Route 44
126,4,Route 45 126,2,Route 45
127,4,Route 46 127,2,Route 46
128,4,Route 47 128,2,Route 47
129,4,Route 48 129,2,Route 48
130,4,Route 5 130,1,Route 5
131,4,Route 6 131,1,Route 6
132,4,Route 7 132,1,Route 7
133,4,Route 8 133,1,Route 8
134,4,Route 9 134,1,Route 9
135,4,Ruins of Alph 135,2,Ruins of Alph
136,4,Seafoam Islands 136,1,Seafoam Islands
137,4,Slowpoke Well 137,2,Slowpoke Well
138,4,Sprout Tower 138,2,Sprout Tower
139,4,Tin Tower 139,2,Tin Tower
140,4,Tohjo Falls 140,2,Tohjo Falls
141,4,Union Cave 141,2,Union Cave
142,4,Unknown 138 142,2,Unknown 138
143,4,Unknown 49 143,2,Unknown 49
144,4,Unknown 50 144,2,Unknown 50
145,4,Unknown 64 145,2,Unknown 64
146,4,Unknown 90 146,2,Unknown 90
147,4,Unknown Dungeon 147,2,Unknown Dungeon
148,4,Unknown; all Poliwag 148,2,Unknown; all Poliwag
149,4,Unknown; all Rattata 149,2,Unknown; all Rattata
150,4,Unknown; all bugs 150,2,Unknown; all bugs
151,4,Vermilion City 151,1,Vermilion City
152,4,Victory Road 152,1,Victory Road
153,4,Violet City 153,2,Violet City
154,4,Viridian City 154,1,Viridian City
155,4,Viridian Forest 155,1,Viridian Forest
156,4,Whirl Islands 156,2,Whirl Islands

1 id generation_id region_id name
2 1 4 Canalave City
3 2 4 Eterna City
4 3 4 Pastoria City
62 62 4 Sea Route 223
63 63 4 Sea Route 226
64 64 4 Sea Route 230
65 65 4 2 Blackthorn City
66 66 4 2 Burned Tower
67 67 4 1 Celadon City
68 68 4 1 Cerulean City
69 69 4 2 Cherrygrove City
70 70 4 2 Cianwood City
71 71 4 1 Cinnabar Island
72 72 4 2 Dark Cave
73 73 4 1 Diglett's Cave
74 74 4 2 Dragon's Den
75 75 4 2 Ecruteak City
76 76 4 1 Fuchsia City
77 77 4 2 Ice Cave
78 78 4 2 Ilex Forest
79 79 4 2 Lake of Rage
80 80 4 1 Mt. Moon
81 81 4 2 Mt. Mortar
82 82 4 2 Mt. Silver
83 83 4 2 National Park
84 84 4 2 New Bark Town
85 85 4 2 Olivine City
86 86 4 1 Pallet Town
87 87 4 1 Rock Tunnel
88 88 4 1 Route 1
89 89 4 1 Route 10
90 90 4 1 Route 11
91 91 4 1 Route 12
92 92 4 1 Route 13
93 93 4 1 Route 14
94 94 4 1 Route 15
95 95 4 1 Route 16
96 96 4 1 Route 17
97 97 4 1 Route 18
98 98 4 1 Route 19
99 99 4 1 Route 2
100 100 4 1 Route 20
101 101 4 1 Route 21
102 102 4 1 Route 22
103 103 4 1 Route 24
104 104 4 1 Route 25
105 105 4 1 Route 26
106 106 4 1 Route 27
107 107 4 1 Route 28
108 108 4 2 Route 29
109 109 4 1 Route 3
110 110 4 2 Route 30
111 111 4 2 Route 31
112 112 4 2 Route 32
113 113 4 2 Route 33
114 114 4 2 Route 34
115 115 4 2 Route 35
116 116 4 2 Route 36
117 117 4 2 Route 37
118 118 4 2 Route 38
119 119 4 2 Route 39
120 120 4 1 Route 4
121 121 4 2 Route 40
122 122 4 2 Route 41
123 123 4 2 Route 42
124 124 4 2 Route 43
125 125 4 2 Route 44
126 126 4 2 Route 45
127 127 4 2 Route 46
128 128 4 2 Route 47
129 129 4 2 Route 48
130 130 4 1 Route 5
131 131 4 1 Route 6
132 132 4 1 Route 7
133 133 4 1 Route 8
134 134 4 1 Route 9
135 135 4 2 Ruins of Alph
136 136 4 1 Seafoam Islands
137 137 4 2 Slowpoke Well
138 138 4 2 Sprout Tower
139 139 4 2 Tin Tower
140 140 4 2 Tohjo Falls
141 141 4 2 Union Cave
142 142 4 2 Unknown 138
143 143 4 2 Unknown 49
144 144 4 2 Unknown 50
145 145 4 2 Unknown 64
146 146 4 2 Unknown 90
147 147 4 2 Unknown Dungeon
148 148 4 2 Unknown; all Poliwag
149 149 4 2 Unknown; all Rattata
150 150 4 2 Unknown; all bugs
151 151 4 1 Vermilion City
152 152 4 1 Victory Road
153 153 4 2 Violet City
154 154 4 1 Viridian City
155 155 4 1 Viridian Forest
156 156 4 2 Whirl Islands

View file

@ -0,0 +1,5 @@
id,name
1,Kanto
2,Johto
3,Hoenn
4,Sinnoh
1 id name
2 1 Kanto
3 2 Johto
4 3 Hoenn
5 4 Sinnoh

View file

@ -0,0 +1,14 @@
version_group_id,region_id
1,1
2,1
3,1
3,2
4,1
4,2
5,3
6,3
7,1
8,4
9,4
10,1
10,2
1 version_group_id region_id
2 1 1
3 2 1
4 3 1
5 3 2
6 4 1
7 4 2
8 5 3
9 6 3
10 7 1
11 8 4
12 9 4
13 10 1
14 10 2

View file

@ -144,8 +144,8 @@ class EvolutionMethod(TableBase):
class Generation(TableBase): class Generation(TableBase):
__tablename__ = 'generations' __tablename__ = 'generations'
id = Column(Integer, primary_key=True, nullable=False) id = Column(Integer, primary_key=True, nullable=False)
main_region_id = Column(Integer, ForeignKey('regions.id'))
name = Column(Unicode(16), nullable=False) name = Column(Unicode(16), nullable=False)
main_region = Column(Unicode(16), nullable=False)
class GrowthRate(TableBase): class GrowthRate(TableBase):
"""`formula` is written in LaTeX math notation.""" """`formula` is written in LaTeX math notation."""
@ -170,7 +170,7 @@ class Location(TableBase):
__tablename__ = 'locations' __tablename__ = 'locations'
__singlename__ = 'location' __singlename__ = 'location'
id = Column(Integer, primary_key=True, nullable=False) id = Column(Integer, primary_key=True, nullable=False)
generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False) region_id = Column(Integer, ForeignKey('regions.id'))
name = Column(Unicode(64), nullable=False) name = Column(Unicode(64), nullable=False)
class LocationArea(TableBase): class LocationArea(TableBase):
@ -412,6 +412,12 @@ class PokemonType(TableBase):
type_id = Column(Integer, ForeignKey('types.id'), nullable=False) type_id = Column(Integer, ForeignKey('types.id'), nullable=False)
slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False) slot = Column(Integer, primary_key=True, nullable=False, autoincrement=False)
class Region(TableBase):
"""Major areas of the world: Kanto, Johto, etc."""
__tablename__ = 'regions'
id = Column(Integer, primary_key=True, nullable=False)
name = Column(Unicode(16), nullable=False)
class Stat(TableBase): class Stat(TableBase):
__tablename__ = 'stats' __tablename__ = 'stats'
id = Column(Integer, primary_key=True, nullable=False) id = Column(Integer, primary_key=True, nullable=False)
@ -448,6 +454,11 @@ class VersionGroup(TableBase):
id = Column(Integer, primary_key=True, nullable=False) id = Column(Integer, primary_key=True, nullable=False)
generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False) generation_id = Column(Integer, ForeignKey('generations.id'), nullable=False)
class VersionGroupRegion(TableBase):
__tablename__ = 'version_group_regions'
version_group_id = Column(Integer, ForeignKey('version_groups.id'), primary_key=True, nullable=False)
region_id = Column(Integer, ForeignKey('regions.id'), primary_key=True, nullable=False)
class Version(TableBase): class Version(TableBase):
__tablename__ = 'versions' __tablename__ = 'versions'
id = Column(Integer, primary_key=True, nullable=False) id = Column(Integer, primary_key=True, nullable=False)
@ -483,6 +494,9 @@ EncounterSlotCondition.condition = relation(EncounterCondition,
EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains') EvolutionChain.growth_rate = relation(GrowthRate, backref='evolution_chains')
Generation.versions = relation(Version, secondary=VersionGroup.__table__) Generation.versions = relation(Version, secondary=VersionGroup.__table__)
Generation.main_region = relation(Region)
Location.region = relation(Region, backref='locations')
LocationArea.location = relation(Location, backref='areas') LocationArea.location = relation(Location, backref='areas')
@ -568,6 +582,12 @@ PokemonName.language = relation(Language)
PokemonStat.stat = relation(Stat) PokemonStat.stat = relation(Stat)
# This is technically a has-many; Generation.main_region_id -> Region.id
Region.generation = relation(Generation, uselist=False)
Region.version_group_regions = relation(VersionGroupRegion, backref='region',
order_by='VersionGroupRegion.version_group_id')
Region.version_groups = association_proxy('version_group_regions', 'version_group')
SuperContestCombo.first = relation(Move, primaryjoin=SuperContestCombo.first_move_id==Move.id, SuperContestCombo.first = relation(Move, primaryjoin=SuperContestCombo.first_move_id==Move.id,
backref='super_contest_combo_first') backref='super_contest_combo_first')
SuperContestCombo.second = relation(Move, primaryjoin=SuperContestCombo.second_move_id==Move.id, SuperContestCombo.second = relation(Move, primaryjoin=SuperContestCombo.second_move_id==Move.id,
@ -589,3 +609,5 @@ Version.version_group = relation(VersionGroup, backref='versions')
Version.generation = association_proxy('version_group', 'generation') Version.generation = association_proxy('version_group', 'generation')
VersionGroup.generation = relation(Generation, backref='version_groups') VersionGroup.generation = relation(Generation, backref='version_groups')
VersionGroup.version_group_regions = relation(VersionGroupRegion, backref='version_group')
VersionGroup.regions = association_proxy('version_group_regions', 'region')