database design - Append data from an existing mdb into another existing mdb -


i'm upgrading existing front-end , back-end set of mdbs. back-end getting bloated , impacting performance. data more 2 years old still needs retained, unlikely ever accessed again. thinking appropriate have active back-end (i.e., current , previous year's worth of data) , archived back-end (i.e., @ beginning of each year, append data active back-end existing, archived back-end).

  • what other approaches should considering?
  • if appropriate approach, how append data active back-end mdb archive back-end, preferably front-end (e.g., start-up function)?
    • the method i've been able identify, go archive back-end, import every table active back-end, append. there way of front-end?

you mentioned bloating. run compact , repair on bloated back-end mdb, if haven't already. in addition shrinking file size, update index statistics can allow query optimizer make better decisions query plans.

you didn't provide details existing databases , tables, made several simplifying assumptions.

  1. your front-end mdb contains links of tables in back-end mdb want archive.
  2. all front-end links links tables. (iow, no links tables don't want archive.
  3. the link names match table names in back-end mdb.
  4. your tables include date field named "date_field". (this field values used determine records archived.)
  5. you have created archive database, c:\db\archive.mdb, includes empty copies of tables want archive. may want convert autonumber fields long integer. if you're not anticipating archived data hardly ever used, drop indexes (which include primary keys, unique constraints, , relationships) ... there considerable space savings if care ... inserting data can faster when don't have indexes update.

so suggest making copy of back-end database, give procedure try. in immediate window check insert , delete statements. if reasonable uncomment 2 currentdb.execute lines , see happens. (you did make backup first, right?)

public sub doarchive()     const cstrarchive string = "c:\db\archive.mdb"     dim db dao.database     dim tdf dao.tabledef     dim strappend string     dim strcutoff string     dim strdelete string     dim strwhere string     dim strmsg string  on error goto errorhandler      set db = currentdb     strcutoff = "#" & year(date) - 1 & "/01/01#"     strwhere = " date_field < " & strcutoff     each tdf in db.tabledefs         if len(tdf.connect) > 0             strappend = "insert [" & tdf.name & "] in '" & _                 cstrarchive & "' select * [" & tdf.name & _                 "]" & strwhere & ";"             debug.print strappend             ''currentdb.execute strappend, dbfailonerror             strdelete = "delete [" & tdf.name & "]" & _                 strwhere & ";"             debug.print strdelete             ''currentdb.execute strdelete, dbfailonerror         end if     next tdf  exithere:     on error goto 0     set tdf = nothing     set db = nothing     exit sub  errorhandler:     strmsg = "error " & err.number & " (" & err.description _         & ") in procedure doarchive"     msgbox strmsg     goto exithere end sub 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -