ソースを参照

Pokemon counted and categorized

NedRedmond 6 年 前
コミット
61afcfc2ba
共有6 個のファイルを変更した122 個の追加91 個の削除を含む
  1. 1
    0
      .idea/dataSources.xml
  2. 74
    70
      .idea/workspace.xml
  3. 27
    0
      PokeQueries - Final Report: Tankboys
  4. 3
    19
      PokeQueries - Joins and Groups
  5. 16
    0
      PokeQueries - Selects and Counts
  6. 1
    2
      README.md

+ 1
- 0
.idea/dataSources.xml ファイルの表示

@@ -6,6 +6,7 @@
6 6
       <synchronize>true</synchronize>
7 7
       <jdbc-driver>com.mysql.jdbc.Driver</jdbc-driver>
8 8
       <jdbc-url>jdbc:mysql://localhost:3306</jdbc-url>
9
+      <default-dialect>MySQL</default-dialect>
9 10
       <driver-properties>
10 11
         <property name="autoReconnect" value="true" />
11 12
         <property name="zeroDateTimeBehavior" value="convertToNull" />

+ 74
- 70
.idea/workspace.xml ファイルの表示

@@ -2,10 +2,10 @@
2 2
 <project version="4">
3 3
   <component name="ChangeListManager">
4 4
     <list default="true" id="76612c0d-deb7-46f0-b6ce-d656cb760d28" name="Default Changelist" comment="">
5
-      <change afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
6
-      <change afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" />
7
-      <change afterPath="$PROJECT_DIR$/PokeQueries" afterDir="false" />
8
-      <change afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
5
+      <change beforePath="$PROJECT_DIR$/.idea/dataSources.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.xml" afterDir="false" />
6
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
7
+      <change beforePath="$PROJECT_DIR$/PokeQueries" beforeDir="false" />
8
+      <change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
9 9
     </list>
10 10
     <ignored path="$PROJECT_DIR$/out/" />
11 11
     <ignored path="$PROJECT_DIR$/target/" />
@@ -77,21 +77,21 @@
77 77
     <session id="1981505676">
78 78
       <usages-collector id="statistics.lifecycle.project">
79 79
         <counts>
80
-          <entry key="project.closed" value="3" />
81
-          <entry key="project.open.time.1" value="2" />
80
+          <entry key="project.closed" value="5" />
81
+          <entry key="project.open.time.1" value="3" />
82 82
           <entry key="project.open.time.4" value="1" />
83
-          <entry key="project.open.time.9" value="1" />
84
-          <entry key="project.opened" value="4" />
83
+          <entry key="project.open.time.9" value="2" />
84
+          <entry key="project.opened" value="6" />
85 85
         </counts>
86 86
       </usages-collector>
87 87
       <usages-collector id="statistics.file.extensions.open">
88 88
         <counts>
89 89
           <entry key="PokeQueries" value="2" />
90 90
           <entry key="iml" value="2" />
91
-          <entry key="md" value="2" />
92
-          <entry key="pokemon_trainer" value="1" />
91
+          <entry key="md" value="3" />
92
+          <entry key="pokemon_trainer" value="2" />
93 93
           <entry key="pokemons" value="2" />
94
-          <entry key="sql" value="4" />
94
+          <entry key="sql" value="5" />
95 95
           <entry key="trainers" value="1" />
96 96
           <entry key="types" value="2" />
97 97
           <entry key="xml" value="1" />
@@ -99,24 +99,26 @@
99 99
       </usages-collector>
100 100
       <usages-collector id="statistics.file.types.open">
101 101
         <counts>
102
-          <entry key="Database Element" value="6" />
102
+          <entry key="Database Element" value="7" />
103 103
           <entry key="IDEA_MODULE" value="2" />
104
-          <entry key="Markdown" value="2" />
104
+          <entry key="Markdown" value="3" />
105 105
           <entry key="PLAIN_TEXT" value="2" />
106
-          <entry key="Scratch" value="4" />
106
+          <entry key="Scratch" value="5" />
107 107
           <entry key="XML" value="1" />
108 108
         </counts>
109 109
       </usages-collector>
110 110
       <usages-collector id="statistics.file.extensions.edit">
111 111
         <counts>
112
-          <entry key="PokeQueries" value="227" />
113
-          <entry key="sql" value="1164" />
112
+          <entry key="PokeQueries" value="665" />
113
+          <entry key="md" value="1" />
114
+          <entry key="sql" value="2106" />
114 115
         </counts>
115 116
       </usages-collector>
116 117
       <usages-collector id="statistics.file.types.edit">
117 118
         <counts>
118
-          <entry key="PLAIN_TEXT" value="227" />
119
-          <entry key="Scratch" value="1164" />
119
+          <entry key="Markdown" value="1" />
120
+          <entry key="PLAIN_TEXT" value="665" />
121
+          <entry key="Scratch" value="2106" />
120 122
         </counts>
121 123
       </usages-collector>
122 124
     </session>
@@ -125,21 +127,21 @@
125 127
     <favorites_list name="pokemon" />
126 128
   </component>
127 129
   <component name="FileEditorManager">
128
-    <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
130
+    <leaf>
129 131
       <file pinned="false" current-in-tab="true">
130
-        <entry file="file://$PROJECT_DIR$/PokeQueries">
132
+        <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/75842638-a1d6-4817-a22c-97fcb1056134/console.sql">
131 133
           <provider selected="true" editor-type-id="text-editor">
132
-            <state relative-caret-position="585">
133
-              <caret line="39" column="189" selection-start-line="39" selection-start-column="189" selection-end-line="39" selection-end-column="189" />
134
+            <state>
135
+              <caret selection-end-line="20" selection-end-column="25" />
134 136
             </state>
135 137
           </provider>
136 138
         </entry>
137 139
       </file>
138 140
       <file pinned="false" current-in-tab="false">
139
-        <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/75842638-a1d6-4817-a22c-97fcb1056134/console.sql">
140
-          <provider selected="true" editor-type-id="text-editor">
141
+        <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/pokemon_trainer">
142
+          <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
141 143
             <state>
142
-              <caret column="246" selection-start-column="246" selection-end-column="246" />
144
+              <filtering enabled="true" />
143 145
             </state>
144 146
           </provider>
145 147
         </entry>
@@ -153,8 +155,9 @@
153 155
     <option name="CHANGED_PATHS">
154 156
       <list>
155 157
         <option value="$PROJECT_DIR$/pom.xml" />
156
-        <option value="$PROJECT_DIR$/PokeQueries" />
158
+        <option value="$PROJECT_DIR$/README.md" />
157 159
         <option value="$APPLICATION_CONFIG_DIR$/consoles/db/75842638-a1d6-4817-a22c-97fcb1056134/console.sql" />
160
+        <option value="$PROJECT_DIR$/PokeQueries" />
158 161
       </list>
159 162
     </option>
160 163
   </component>
@@ -171,10 +174,10 @@
171 174
       </MavenImportingSettings>
172 175
     </option>
173 176
   </component>
174
-  <component name="ProjectFrameBounds" fullScreen="true">
177
+  <component name="ProjectFrameBounds" extendedState="6" fullScreen="true">
175 178
     <option name="y" value="23" />
176 179
     <option name="width" value="1440" />
177
-    <option name="height" value="797" />
180
+    <option name="height" value="900" />
178 181
   </component>
179 182
   <component name="ProjectView">
180 183
     <navigator proportions="" version="1">
@@ -189,6 +192,21 @@
189 192
               <item name="pokemon" type="b2602c69:ProjectViewProjectNode" />
190 193
               <item name="PokemonSqlLab" type="462c0819:PsiDirectoryNode" />
191 194
             </path>
195
+            <path>
196
+              <item name="pokemon" type="b2602c69:ProjectViewProjectNode" />
197
+              <item name="Scratches and Consoles" type="1a2a3e82:ScratchProjectViewPane$MyProjectNode" />
198
+            </path>
199
+            <path>
200
+              <item name="pokemon" type="b2602c69:ProjectViewProjectNode" />
201
+              <item name="Scratches and Consoles" type="1a2a3e82:ScratchProjectViewPane$MyProjectNode" />
202
+              <item name="Database Consoles" type="d62648e6:ScratchProjectViewPane$MyRootNode" />
203
+            </path>
204
+            <path>
205
+              <item name="pokemon" type="b2602c69:ProjectViewProjectNode" />
206
+              <item name="Scratches and Consoles" type="1a2a3e82:ScratchProjectViewPane$MyProjectNode" />
207
+              <item name="Database Consoles" type="d62648e6:ScratchProjectViewPane$MyRootNode" />
208
+              <item name="75842638-a1d6-4817-a22c-97fcb1056134" type="1e004dc1:ScratchProjectViewPane$MyRootNode$1$1" />
209
+            </path>
192 210
           </expand>
193 211
           <select />
194 212
         </subPane>
@@ -200,8 +218,9 @@
200 218
     <property name="DatabaseDriversLRU" value="mysql" />
201 219
     <property name="WebServerToolWindowFactoryState" value="false" />
202 220
     <property name="aspect.path.notification.shown" value="true" />
203
-    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541553451275" />
204
-    <property name="database.console.LAST_STATE" value="true" />
221
+    <property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1541620260764" />
222
+    <property name="com.intellij.ide.scratch.LRUPopupBuilder$1/SQL Dialect" value="MySQL" />
223
+    <property name="database.console.LAST_STATE" value="false" />
205 224
     <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
206 225
     <property name="nodejs_npm_path_reset_for_default_project" value="true" />
207 226
     <property name="project.structure.last.edited" value="Modules" />
@@ -235,16 +254,19 @@
235 254
       <workItem from="1541513944370" duration="961000" />
236 255
       <workItem from="1541528697727" duration="646000" />
237 256
       <workItem from="1541543463370" duration="7330000" />
257
+      <workItem from="1541597042065" duration="239000" />
258
+      <workItem from="1541597377071" duration="6365000" />
238 259
     </task>
239 260
     <servers />
240 261
   </component>
241 262
   <component name="TimeTrackingManager">
242
-    <option name="totallyTimeSpent" value="10219000" />
263
+    <option name="totallyTimeSpent" value="16823000" />
243 264
   </component>
244 265
   <component name="ToolWindowManager">
245 266
     <frame x="0" y="0" width="1440" height="900" extended-state="6" />
267
+    <editor active="true" />
246 268
     <layout>
247
-      <window_info content_ui="combo" id="Project" order="0" weight="0.2532189" />
269
+      <window_info content_ui="combo" id="Project" order="0" weight="0.25679544" />
248 270
       <window_info id="Structure" order="1" side_tool="true" weight="0.24964234" />
249 271
       <window_info id="Designer" order="2" />
250 272
       <window_info id="Image Layers" order="3" />
@@ -259,7 +281,7 @@
259 281
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
260 282
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
261 283
       <window_info anchor="bottom" id="TODO" order="6" />
262
-      <window_info active="true" anchor="bottom" id="Database Console" order="7" visible="true" weight="0.32891566" />
284
+      <window_info anchor="bottom" id="Database Console" order="7" weight="0.32891566" />
263 285
       <window_info anchor="bottom" id="Version Control" order="8" />
264 286
       <window_info anchor="bottom" id="Database Changes" order="9" />
265 287
       <window_info anchor="bottom" id="Terminal" order="10" />
@@ -271,11 +293,11 @@
271 293
       <window_info anchor="right" id="Capture Analysis" order="4" />
272 294
       <window_info anchor="right" id="Theme Preview" order="5" />
273 295
       <window_info anchor="right" id="Palette&#9;" order="6" />
274
-      <window_info anchor="right" id="Database" order="7" visible="true" weight="0.16094421" />
296
+      <window_info anchor="right" id="Database" order="7" weight="0.16094421" />
275 297
       <window_info anchor="right" id="Maven Projects" order="8" />
276 298
     </layout>
277 299
     <layout-to-restore>
278
-      <window_info content_ui="combo" id="Project" order="0" weight="0.2532189" />
300
+      <window_info content_ui="combo" id="Project" order="0" weight="0.25679544" />
279 301
       <window_info id="Structure" order="1" side_tool="true" weight="0.24964234" />
280 302
       <window_info id="Designer" order="2" />
281 303
       <window_info id="Image Layers" order="3" />
@@ -290,7 +312,7 @@
290 312
       <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
291 313
       <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
292 314
       <window_info anchor="bottom" id="TODO" order="6" />
293
-      <window_info active="true" anchor="bottom" id="Database Console" order="7" visible="true" weight="0.32891566" />
315
+      <window_info anchor="bottom" id="Database Console" order="7" visible="true" weight="0.32891566" />
294 316
       <window_info anchor="bottom" id="Version Control" order="8" />
295 317
       <window_info anchor="bottom" id="Database Changes" order="9" />
296 318
       <window_info anchor="bottom" id="Terminal" order="10" />
@@ -330,55 +352,37 @@
330 352
         </state>
331 353
       </provider>
332 354
     </entry>
333
-    <entry file="file://$PROJECT_DIR$/README.md">
334
-      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
335
-        <state split_layout="SPLIT">
336
-          <first_editor relative-caret-position="32">
337
-            <caret line="9" column="26" lean-forward="true" selection-start-line="9" selection-start-column="26" selection-end-line="9" selection-end-column="26" />
338
-          </first_editor>
339
-          <second_editor />
340
-        </state>
341
-      </provider>
342
-    </entry>
343
-    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/trainers">
344
-      <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
345
-        <state>
346
-          <filtering enabled="true" />
347
-        </state>
348
-      </provider>
349
-    </entry>
350
-    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/types">
355
+    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/trainers" />
356
+    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/types" />
357
+    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/pokemons" />
358
+    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/pokemon_trainer">
351 359
       <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
352 360
         <state>
353 361
           <filtering enabled="true" />
354 362
         </state>
355 363
       </provider>
356 364
     </entry>
357
-    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/pokemons">
358
-      <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
359
-        <state>
360
-          <filtering enabled="true" />
365
+    <entry file="file://$PROJECT_DIR$/PokeQueries">
366
+      <provider selected="true" editor-type-id="text-editor">
367
+        <state relative-caret-position="720">
368
+          <caret line="48" column="2" selection-start-line="48" selection-start-column="2" selection-end-line="48" selection-end-column="2" />
361 369
         </state>
362 370
       </provider>
363 371
     </entry>
364
-    <entry file="das://75842638-a1d6-4817-a22c-97fcb1056134/schema/pokemon/table/pokemon_trainer">
365
-      <provider selected="true" editor-type-id="com.intellij.database.editor.DatabaseTableFileEditorProvider">
366
-        <state>
367
-          <filtering enabled="true" />
372
+    <entry file="file://$PROJECT_DIR$/README.md">
373
+      <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
374
+        <state split_layout="SECOND">
375
+          <first_editor relative-caret-position="95">
376
+            <caret line="41" column="1" selection-start-line="41" selection-start-column="1" selection-end-line="41" selection-end-column="1" />
377
+          </first_editor>
378
+          <second_editor />
368 379
         </state>
369 380
       </provider>
370 381
     </entry>
371 382
     <entry file="file://$APPLICATION_CONFIG_DIR$/consoles/db/75842638-a1d6-4817-a22c-97fcb1056134/console.sql">
372 383
       <provider selected="true" editor-type-id="text-editor">
373 384
         <state>
374
-          <caret column="246" selection-start-column="246" selection-end-column="246" />
375
-        </state>
376
-      </provider>
377
-    </entry>
378
-    <entry file="file://$PROJECT_DIR$/PokeQueries">
379
-      <provider selected="true" editor-type-id="text-editor">
380
-        <state relative-caret-position="585">
381
-          <caret line="39" column="189" selection-start-line="39" selection-start-column="189" selection-end-line="39" selection-end-column="189" />
385
+          <caret selection-end-line="20" selection-end-column="25" />
382 386
         </state>
383 387
       </provider>
384 388
     </entry>

+ 27
- 0
PokeQueries - Final Report: Tankboys ファイルの表示

@@ -0,0 +1,27 @@
1
+### Final Report
2
+
3
+* BEST TANKBOYS OF RUBY.
4
+* Every party needs a tank.
5
+* These boys eat damage for breakfast and kick ass for dessert.
6
+
7
+SELECT
8
+       p.name as "Pokemon Name",
9
+       tr.trainername as "Trainer Name",
10
+       pt.pokelevel as "Level",
11
+       ANY_VALUE(ty1.name) as "Primary Type",
12
+       ANY_VALUE(ty2.name) as "Secondary Type"
13
+FROM
14
+     pokemon.pokemon_trainer pt
15
+       JOIN
16
+         pokemon.trainers tr ON pt.trainerID = tr.trainerID
17
+       JOIN
18
+         pokemon.pokemons p ON pt.pokemon_id = p.id
19
+       JOIN
20
+         pokemon.types ty1 ON p.primary_type = ty1.id
21
+       LEFT JOIN
22
+         pokemon.types ty2 ON p.secondary_type = ty2.id
23
+GROUP BY
24
+        p.name, pt.trainerID, pt.pokelevel
25
+ORDER BY
26
+       SUM(pt.maxhp + pt.defense) DESC,
27
+       pt.pokelevel DESC;

PokeQueries → PokeQueries - Joins and Groups ファイルの表示

@@ -1,21 +1,3 @@
1
-### Simple Selects and Counts
2
-
3
-* What are all the types of pokemon that a pokemon can have?
4
-SELECT t.name FROM pokemon.types t;
5
-
6
-* What is the name of the pokemon with id 45?
7
-SELECT t.name FROM pokemon.pokemons t WHERE id=45;
8
-
9
-* How many pokemon are there?
10
-SELECT COUNT(*) as "count" FROM pokemon.pokemons;
11
-
12
-* How many types are there?
13
-SELECT COUNT(*) as "count" from pokemon.types;
14
-
15
-* How many pokemon have a secondary type?
16
-SELECT COUNT(secondary_type) as "count" from pokemon.pokemons WHERE secondary_type IS NOT NULL;
17
-
18
-
19 1
 ### Joins and Groups
20 2
 
21 3
 * What is each pokemon's primary type?
@@ -37,4 +19,6 @@ SELECT t.name as "Type", COUNT(p.id) as "PokeCount" FROM pokemon.types t JOIN po
37 19
 SELECT COUNT(pokelevel) as "The Count" from pokemon.pokemon_trainer WHERE pokelevel>=100 GROUP BY trainerID;
38 20
 
39 21
 * How many pokemon only belong to one trainer and no other?
40
-SELECT p.name, COUNT(t.pokemon_id) as "trainer count" from pokemon.pokemon_trainer t JOIN pokemon.pokemons p ON t.pokemon_id = p.id GROUP BY pokemon_id HAVING COUNT(DISTINCT trainerID) = 1;
22
+SELECT p.name, COUNT(t.pokemon_id) as "trainer count" from pokemon.pokemon_trainer t JOIN pokemon.pokemons p ON t.pokemon_id = p.id GROUP BY pokemon_id HAVING COUNT(DISTINCT trainerID) = 1;
23
+* Or, for just the number of distinct Pokemon held by only one trainer:
24
+SELECT COUNT(name) as "Pokemon held by 1 trainer in the game" FROM (SELECT p.name, COUNT(t.pokemon_id) as "trainer count" from pokemon.pokemon_trainer t JOIN pokemon.pokemons p ON t.pokemon_id = p.id GROUP BY pokemon_id HAVING COUNT(DISTINCT trainerID) = 1) heck;

+ 16
- 0
PokeQueries - Selects and Counts ファイルの表示

@@ -0,0 +1,16 @@
1
+### Simple Selects and Counts
2
+
3
+* What are all the types of pokemon that a pokemon can have?
4
+SELECT t.name FROM pokemon.types t;
5
+
6
+* What is the name of the pokemon with id 45?
7
+SELECT t.name FROM pokemon.pokemons t WHERE id=45;
8
+
9
+* How many pokemon are there?
10
+SELECT COUNT(*) as "count" FROM pokemon.pokemons;
11
+
12
+* How many types are there?
13
+SELECT COUNT(*) as "count" from pokemon.types;
14
+
15
+* How many pokemon have a secondary type?
16
+SELECT COUNT(secondary_type) as "count" from pokemon.pokemons WHERE secondary_type IS NOT NULL;

+ 1
- 2
README.md ファイルの表示

@@ -39,8 +39,7 @@ Directions: Write a sql query or sql queries that can answer the following quest
39 39
 * How many pokemon at level 100 does each trainer with at least one level 100 pokemone have? (Hint: your query should not display a trainer
40 40
 * How many pokemon only belong to one trainer and no other?
41 41
 
42
-### Part 4: Final Report
43
-
42
+s
44 43
 Directions: Write a query that returns the following collumns:
45 44
 
46 45
 | Pokemon Name | Trainer Name | Level | Primary Type | Secondary Type |