> Fra: Nick Arnett [mailto:[EMAIL PROTECTED]] > Sendt: 3. maj 2002 04:30 > Emne: Strategies for maintaining tables calculated from other tables? > > > I'm finding that it's not quite as simple as I had imagined to maintain a > table whose values are calculated by analyzing other tables. The source > tables contain time series data, which can is updated several times a day. > To calculate totals by day, week, month, etc., I don't want to > have to start > over from scratch, so I want to keep track of which records in the source > tables have already been analyzed. Further complicating things, there are > several analyses that take place and I may add others later. I > don't always > want to have to do all of them at the same time.
<snip> add a datetime field to each of your source tables that shows the date/time when the record was inserted/last updated. Then create another table containing these fields calcs -------- id int unsigned auto_increment primary key calculation varchar(100) last_run datetime For each type of calculation, you insert a record into this new table. You now have a way to register when your calculation was last run. The next time one of your calculations are run, select all source-records with a datetime value newer than your "last_run". - Carsten #¤&@&¤&#%#%¤ filter!!! (sql,database,query) --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php