dbinit.py (2665:a124942bacb8) dbinit.py (2716:b9114064d77a)
1# Copyright (c) 2003-2004 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 86 unchanged lines hidden (view full) ---

95 rn_project VARCHAR(100) NOT NULL,
96 rn_date TIMESTAMP NOT NULL,
97 rn_expire TIMESTAMP NOT NULL,
98 PRIMARY KEY (rn_id),
99 UNIQUE (rn_name,rn_sample)
100 ) TYPE=InnoDB''')
101
102 #
1# Copyright (c) 2003-2004 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 86 unchanged lines hidden (view full) ---

95 rn_project VARCHAR(100) NOT NULL,
96 rn_date TIMESTAMP NOT NULL,
97 rn_expire TIMESTAMP NOT NULL,
98 PRIMARY KEY (rn_id),
99 UNIQUE (rn_name,rn_sample)
100 ) TYPE=InnoDB''')
101
102 #
103 # We keep the bin names separate so that the data table doesn't get
104 # huge since bin names are frequently repeated.
105 #
106 # COLUMNS:
107 # 'id' is the unique bin identifer.
108 # 'name' is the string name for the bin.
109 #
110 # INDEXES:
111 # 'bin' is indexed to get the name of a bin when data is retrieved
112 # via the data table.
113 # 'name' is indexed to get the bin id for a named bin when you want
114 # to search the data table based on a specific bin.
115 #
116 self.query('''
117 CREATE TABLE bins(
118 bn_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
119 bn_name VARCHAR(255) NOT NULL,
120 PRIMARY KEY(bn_id),
121 UNIQUE (bn_name)
122 ) TYPE=InnoDB''')
123
124 #
125 # The stat table gives us all of the data for a particular stat.
126 #
127 # COLUMNS:
128 # 'stat' is a unique identifier for each stat to be used in other
129 # tables for references.
130 # 'name' is simply the simulator derived name for a given
131 # statistic.
132 # 'descr' is the description of the statistic and what it tells

--- 84 unchanged lines hidden (view full) ---

217 # -5: maximum value
218 # -6: underflow
219 # -7: overflow
220 # 'y' is used by a VECTORDIST and the VECTOR2D to describe the second
221 # dimension.
222 # 'run' is the run that the data was generated from. Details up in
223 # the run table
224 # 'tick' is a timestamp generated by the simulator.
103 # The stat table gives us all of the data for a particular stat.
104 #
105 # COLUMNS:
106 # 'stat' is a unique identifier for each stat to be used in other
107 # tables for references.
108 # 'name' is simply the simulator derived name for a given
109 # statistic.
110 # 'descr' is the description of the statistic and what it tells

--- 84 unchanged lines hidden (view full) ---

195 # -5: maximum value
196 # -6: underflow
197 # -7: overflow
198 # 'y' is used by a VECTORDIST and the VECTOR2D to describe the second
199 # dimension.
200 # 'run' is the run that the data was generated from. Details up in
201 # the run table
202 # 'tick' is a timestamp generated by the simulator.
225 # 'bin' is the name of the bin that the data was generated in, if
226 # any.
227 # 'data' is the actual stat value.
228 #
229 # INDEXES:
230 # 'stat' is indexed so that a user can find all of the data for a
231 # particular stat. It is not unique, because that specific stat
203 # 'data' is the actual stat value.
204 #
205 # INDEXES:
206 # 'stat' is indexed so that a user can find all of the data for a
207 # particular stat. It is not unique, because that specific stat
232 # can be found in many runs, bins, and samples, in addition to
208 # can be found in many runs and samples, in addition to
233 # having entries for the mulidimensional cases.
234 # 'run' is indexed to allow a user to remove all of the data for a
235 # particular execution run. It can also be used to allow the
236 # user to print out all of the data for a given run.
237 #
238 self.query('''
239 CREATE TABLE data(
240 dt_stat SMALLINT UNSIGNED NOT NULL,
241 dt_x SMALLINT NOT NULL,
242 dt_y SMALLINT NOT NULL,
243 dt_run SMALLINT UNSIGNED NOT NULL,
244 dt_tick BIGINT UNSIGNED NOT NULL,
209 # having entries for the mulidimensional cases.
210 # 'run' is indexed to allow a user to remove all of the data for a
211 # particular execution run. It can also be used to allow the
212 # user to print out all of the data for a given run.
213 #
214 self.query('''
215 CREATE TABLE data(
216 dt_stat SMALLINT UNSIGNED NOT NULL,
217 dt_x SMALLINT NOT NULL,
218 dt_y SMALLINT NOT NULL,
219 dt_run SMALLINT UNSIGNED NOT NULL,
220 dt_tick BIGINT UNSIGNED NOT NULL,
245 dt_bin SMALLINT UNSIGNED NOT NULL,
246 dt_data DOUBLE NOT NULL,
247 INDEX (dt_stat),
248 INDEX (dt_run),
221 dt_data DOUBLE NOT NULL,
222 INDEX (dt_stat),
223 INDEX (dt_run),
249 UNIQUE (dt_stat,dt_x,dt_y,dt_run,dt_tick,dt_bin)
224 UNIQUE (dt_stat,dt_x,dt_y,dt_run,dt_tick)
250 ) TYPE=InnoDB;''')
251
252 #
253 # Names and descriptions for multi-dimensional stats (vectors, etc.)
254 # are stored here instead of having their own entry in the statistics
255 # table. This allows all parts of a single stat to easily share a
256 # single id.
257 #

--- 135 unchanged lines hidden (view full) ---

393
394 self.query('''
395 DELETE subdata
396 FROM subdata
397 LEFT JOIN data ON sd_stat=dt_stat
398 WHERE dt_stat IS NULL''')
399
400 self.query('''
225 ) TYPE=InnoDB;''')
226
227 #
228 # Names and descriptions for multi-dimensional stats (vectors, etc.)
229 # are stored here instead of having their own entry in the statistics
230 # table. This allows all parts of a single stat to easily share a
231 # single id.
232 #

--- 135 unchanged lines hidden (view full) ---

368
369 self.query('''
370 DELETE subdata
371 FROM subdata
372 LEFT JOIN data ON sd_stat=dt_stat
373 WHERE dt_stat IS NULL''')
374
375 self.query('''
401 DELETE bins
402 FROM bins
403 LEFT JOIN data ON bn_id=dt_bin
404 WHERE dt_bin IS NULL''')
405
406 self.query('''
407 DELETE events
408 FROM events
409 LEFT JOIN runs ON ev_run=rn_id
410 WHERE rn_id IS NULL''')
411
412 self.query('''
413 DELETE event_names
414 FROM event_names
415 LEFT JOIN events ON en_id=ev_event
416 WHERE ev_event IS NULL''')
376 DELETE events
377 FROM events
378 LEFT JOIN runs ON ev_run=rn_id
379 WHERE rn_id IS NULL''')
380
381 self.query('''
382 DELETE event_names
383 FROM event_names
384 LEFT JOIN events ON en_id=ev_event
385 WHERE ev_event IS NULL''')