Alpha Net Developers

Library & Articles
Dealing With Database Corruption

Home >> Library & Articles >> Dealing With Database Corruption

Library & Articles

Dealing With Database Corruption

Database corruption consists of errors or damage to a database. A corrupt database may lose data, fail to perform correctly or become inaccessible. Databases of all kinds can become corrupted. Some are more vulnerable to corruption than others.

As an example, a Microsoft Access database, which is intended for smaller databases on smaller networks, is more vulnerable than Microsoft SQL Server, which is intended for larger databases on larger networks. Microsoft SQL Server has built-in functionality to provide greater protection against database corruption.

A database can become corrupt due to various reasons such as:

  • Hardware problems such as memory problems, hard disk errors or network errors.
  • Power problems, such as power loss, dips or surges.
  • Lightning storms.
  • Switching a computer off when a database is open.
  • System crashes and reboots.
  • Poor database design or programming.
  • If one or more of the following problems are occurring, the database may be corrupt:

  • Data becomes inaccessible.
  • Backups cannot be made.
  • Data cannot be modified.
  • Certain database files are missing from backups.
  • Record retrieval fails or is incomplete.
  • Database size is unusually large.
  • Database tasks cannot be performed.
  • Error messages come up when reports are generated.
  • Weird characters appear in printouts to the screen or to reports.
  • Performance degrades.
  • Unusual behavior or questionable output is observed.
  • A database can be severely damaged, yet show no symptoms. It may even continue to run without apparent problems. Yet it may be damaged beyond repair.

Do not ignore database corruption. Take immediate steps to preserve and recover the data in the database and to repair the database. If the database is prone to corruption, consider investing in a more fault tolerant database application.

Avoiding Corruption:

There are many steps that can be taken to avoid database corruption.

  • Keep your server's hard disk cleaned up by using hard disk maintenance tools.
  • Ensure that every computer on your network is using the same version of your database application, with the same updates and the same patches throughout. The same goes for the operating systems.
  • Check your network setup. Make sure it is set up correctly.
  • Take steps to protect network cables from physical damage.
  • Protect the system from power problems by using UPS (Uninterruptible Power Supply) systems.
  • Shut down during lightning storms if possible.
  • Use good database design and programming practices.
  • Do not leave databases open when they are not in use.
  • Do not "tinker" with the design of your databases and if you do, make sure that you have backed up your database before commencing on the work. Consult the documentation for your particular database application to ensure that your design changes are being correctly implemented and will not themselves cause corruption.
  • When altering a database design, always make a backup of the original design first and then make a backup of the new design. That way you will always have a database structure that you can restore to.

Backing Up Databases:

The first and best protection against database corruption is to routinely and frequently backup a database.

Where data is vital, this should be done at least daily. Invest in a good tape backup system and set it up to perform backups every day. Rotate to a new tape each day - do not simply overwrite the same tape over and over again.

As a precaution, backup the database to CD.

Store the tape backups in a safe place, preferably off-site. Keep the CD copy on site. Test the backups to make sure that they are functional. Do not just assume that they are. If data is critical, consider investing in more sophisticated backup systems such as creating mirrors of the database in real-time.

Repairing Database Corruption:

The data recovery options available to you depend on what tools you have for your database application. Read the documentation thoroughly before you start using the recovery tools and follow the instructions carefully.

The first thing you must do when you suspect you have a damaged database is to set aside any old backups of the database. Do not overwrite them. If possible, work from a copy of the backup in case the recovery process fails and further damage occurs.

If you successfully recover a database, you should immediately back it up. Then run through the list of possible reasons for database corruption and see if you can find what might have caused the problem.

Once a database has been corrupted, you must take extra precautions with your data. This is because even though recovery may seem to be successful and your database may appear to be functioning normally, the database may still be damaged.

In extreme situations, you may have to extract and repair your data and then restore it to a fresh, undamaged copy of the database design.

Conclusion:

Your database is always vulnerable. This just goes with using electronic data systems. A database can become corrupted at any time for no discernible reason.

Your first line of defense is always your backup strategy. Make sure it is adequate. Do not assume that your backups are functional. Test your backups to make sure that they are viable.

Finally, keep in mind that database applications are not created equally. More sophisticated database applications have fault tolerance built into them and are less prone to corruption. If your data is important, you should be using a system that provides greater protection and capability.