Re: TZF - The time has come - restructuring databases on end users machines
Homer <[email protected]> Mon, 9 Feb 2004 19:35:18 -0800
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. ------=_NextPart_000_0043_01C3EF43.D9426400 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Here is a way to automate the process. If you have many customers, you will not want to be involved with every update. It only trains them to rely on you for other things they shouldn't. This procedure will let the program update its own data. This can be important, because a user could restore an out-dated backup over the file you just modified. If the program updates the files automatically, it won't make any difference. Here is the concept: 1. In addition to the necessary structure changes, add a field to the new .dbf file that will contain Version Number. You will use this field in the future. Make it an integer field because there will be redundant values stored, and Integers don't take up much space. 2. When your program launches, compare the Version Number in any record, with a constant that contains the Version Number the program expects. 3. If the Version Number field is not there, or the contents of the field is out of date, then run a procedure that will create an empty data file with the "correct" structure. Code to create a new table can be created with EGBrowse.exe. Simply create the structure you need, then have EGBrowse create the Delphi code that will create a new data file with that structure. Include that code in your application as outlined in step 4, below. 4. The procedure that creates the new file is only called when the installed data file is out-of-date. Once the file is created, you must move the data from the old file into the new. You should be able to use the AppendFrom function for this. Then you must update the Version Number field with the new Version Number. If the amount of data in the data file is large, you may want to consider using Poke to insert the new version number into all records. 5. After the new file has been created and populated, you must copy the new file over the old, replacing the old one. Naturally, you will need exclusive access during this process. The time required to accomplish all this is normally not worth mentioning. Your user may not even know it happened. If you want to be safe, copy the original data file into a "backup" file before you start so you can recover from an unexpected event. I have been using this technique for a number of years, and it has proven to be nearly foolproof. I use a variation of this even when I'm dealing with an SQL database. I understand that with .DBF files, you could modify the header to contain the file's version number, but I don't know how to do that. If it is actually possible to put the version number in the .DBF file's header, it would eliminate the redundant storage of the version number in each record. Perhaps someone else can help with this idea. Agency Business Systems, Inc. (503) 659 6752 www.AgencyBusinessSystems.com -------------------------------------------------------------- "If you want a better answer, ask a better question." -- Unknown. ----- Original Message ----- From: Ken Knight To: [email protected] Sent: Monday, February 09, 2004 2:32 PM Subject: TZF - The time has come - restructuring databases on end users machines Hi all, A while back I posted a question "How do you folks handle this" regarding restructuring databases on end users machines once the program was in commission. The point has finally come where I need to make data structure changes and add / remove fields etc and wanted to again get some feedback from you all to see exactly how you're doing it. thanks, Ken --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004 --^---------------------------------------------------------------- This email was sent to: [email protected] EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt Or send an email to: [email protected] TOPICA - Start your own email discussion group. FREE! http://www.topica.com/partner/tag02/create/index2.html --^---------------------------------------------------------------- ------=_NextPart_000_0043_01C3EF43.D9426400 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> <META content="MSHTML 6.00.2800.1170" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><FONT size=2>Here is a way to automate the process. If you have many customers, you will not want to be involved with every update. It only trains them to rely on you for other things they shouldn't. This procedure will let the program update its own data. This can be important, because a user could restore an out-dated backup over the file you just modified. If the program updates the files automatically, it won't make any difference. Here is the concept:</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>1. In addition to the necessary structure changes, add a field to the new .dbf file that will contain Version Number. You will use this field in the future. Make it an integer field because there will be redundant values stored, and Integers don't take up much space.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>2. When your program launches, compare the Version Number in any record, with a constant that contains the Version Number the program expects.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>3. If the Version Number field is not there, or the contents of the field is out of date, then run a procedure that will create an empty data file with the "correct" structure. Code to create a new table can be created with EGBrowse.exe. Simply create the structure you need, then have EGBrowse create the Delphi code that will create a new data file with that structure. Include that code in your application as outlined in step 4, below.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>4. The procedure that creates the new file is only called when the installed data file is out-of-date. Once the file is created, you must move the data from the old file into the new. You should be able to use the AppendFrom function for this. Then you must update the Version Number field with the new Version Number. If the amount of data in the data file is large, you may want to consider using Poke to insert the new version number into all records.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>5. After the new file has been created and populated, you must copy the new file over the old, replacing the old one. Naturally, you will need exclusive access during this process.</FONT> <FONT size=2>The time required to accomplish all this is normally not worth mentioning. Your user may not even know it happened. If you want to be safe, copy the original data file into a "backup" file before you start so you can recover from an unexpected event.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>I have been using this technique for a number of years, and it has proven to be nearly foolproof. I use a variation of this even when I'm dealing with an SQL database. </FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2>I understand that with .DBF files, you could modify the header to contain the file's version number, but I don't know how to do that. If it is actually possible to put the version number in the .DBF file's header, it would eliminate the redundant storage of the version number in each record. Perhaps someone else can help with this idea.</FONT></DIV> <DIV><FONT size=2></FONT> </DIV> <DIV> </DIV> <DIV><FONT size=2></FONT> </DIV> <DIV><FONT size=2></FONT> </DIV> <DIV>Agency Business Systems, Inc.<BR>(503) 659 6752<BR><A href="http://www.AgencyBusinessSystems.com">www.AgencyBusinessSystems.com</A><BR>--------------------------------------------------------------<BR>"If you want a better answer, <BR> ask a better question." -- Unknown.</DIV> <BLOCKQUOTE dir=ltr style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px"> <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV> <DIV style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> <A [email protected] href="mailto:[email protected]">Ken Knight</A> </DIV> <DIV style="FONT: 10pt arial"><B>To:</B> <A [email protected] href="mailto:[email protected]">[email protected]</A> </DIV> <DIV style="FONT: 10pt arial"><B>Sent:</B> Monday, February 09, 2004 2:32 PM</DIV> <DIV style="FONT: 10pt arial"><B>Subject:</B> TZF - The time has come - restructuring databases on end users machines</DIV> <DIV><BR></DIV> <DIV><FONT face=Arial size=2>Hi all,</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>A while back I posted a question "How do you folks handle this" regarding restructuring databases on end users machines once the program was in commission. The point has finally come where I need to make data structure changes and add / remove fields etc and wanted to again get some feedback from you all to see exactly how you're doing it.</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>thanks,</FONT></DIV> <DIV><FONT face=Arial size=2>Ken</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV> </DIV> <DIV><FONT face=Arial size=2><BR>---<BR>Outgoing mail is certified Virus Free.<BR>Checked by AVG anti-virus system (<A href="http://www.grisoft.com">http://www.grisoft.com</A>).<BR>Version: 6.0.572 / Virus Database: 362 - Release Date: 1/27/2004</FONT></DIV></BLOCKQUOTE><PRE>--^^--------------------------------------------------------------- This email was sent to: [email protected] EASY UNSUBSCRIBE click here: <A HREF="http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt">http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt</A> Or send an email to: [email protected] TOPICA - Start your own email discussion group. FREE! <A HREF="http://www.topica.com/partner/tag02/create/index2.html">http://www.topica.com/partner/tag02/create/index2.html</A> --^^---------------------------------------------------------------</PRE> </BODY></HTML> ------=_NextPart_000_0043_01C3EF43.D9426400--