checking a corrupted database typed file 
Author Message
 checking a corrupted database typed file

Hi,
I'm currently writing a simple inventory program(I admit, its for my
assignment)  and was thinking of creating a procedure that would create a
backup copy of the database file (which is a simple typed file) every time
the program was executed but only  if the database file is not 'damage' (or
corrupted). So I was wondering if there was a procedure or some way to find
out whether a database file(typed file) is corrupted. Thanks in advance, :)

TDR



Wed, 18 Jun 1902 08:00:00 GMT  
 checking a corrupted database typed file


Quote:
> Hi,
> I'm currently writing a simple inventory program(I admit, its for my
> assignment)  and was thinking of creating a procedure that would
create a
> backup copy of the database file (which is a simple typed file) every
time
> the program was executed but only  if the database file is not
'damage' (or
> corrupted). So I was wondering if there was a procedure or some way to
find
> out whether a database file(typed file) is corrupted. Thanks in
advance, :)

lisdjg;dfsoh;okjnkfbnkdfb;mnkblkm
idhpodfhpojdfhpodfsphodfpohpdofhp
lierjypoerypokjeryjeryperoypoeyoy

The above three records are three records in your database. Record 1 is
OK, as is record 3. Please tell me why record 2 is corrupt.

Are you just stupid or do you just pretend?

IF YOU WRITE A PROGRAM TO CREATE A DATABASE, YOU KNOW WHY RECORDS ARE OR
ARE NOT CORRUPT, AND YOU (Y O U) HAVE TO DO SOMETHING ABOUT IT!

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking a corrupted database typed file

Quote:

> Are you just stupid or do you just pretend?

> IF YOU WRITE A PROGRAM TO CREATE A DATABASE, YOU KNOW WHY RECORDS ARE OR
> ARE NOT CORRUPT, AND YOU (Y O U) HAVE TO DO SOMETHING ABOUT IT!

Instead of shouting, which is considered impolite as you certainly (don't)
know, you could have suggested the original poster create a checksum of the
database file. Each time the database is written to, the checksum must be
recomputed. Before making changes to the database, the checksum should be
verified. If individual records are stored in the database, a checksum field
can be added to the record type, e.g.:

type
  storage = record
              data : string;
              checksum : word
            end;
var
  f : file of storage;

For information on checksums, the original poster should search for CRC
using his favorite search enginge.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking a corrupted database typed file


Quote:

> > Are you just stupid or do you just pretend?

> > IF YOU WRITE A PROGRAM TO CREATE A DATABASE, YOU KNOW WHY RECORDS ARE OR
> > ARE NOT CORRUPT, AND YOU (Y O U) HAVE TO DO SOMETHING ABOUT IT!

> Instead of shouting, which is considered impolite as you certainly (don't)
> know, you could have suggested the original poster create a checksum of
the
> database file.
>...

If it is on a hard disc, is there not already a CRC check on the data? I
thought hard & floppy drives had some sort of checking built in, anyone know
for sure? Because if they do, the way to detect corruption would be to try
to read the thing with {$I-} and then check for IoResult to see if there was
an error 154.

Maybe the danger of corruption could be if the program crashes after writing
one or two records, but before it finishes writing all related records, so
that there are inconsistencies in the data. In that case, the answer would
depend on the design of the data and more information would be needed.

FP



Wed, 18 Jun 1902 08:00:00 GMT  
 checking a corrupted database typed file


In reply to this original posting:

I'm currently writing a simple inventory program(I admit, its for my
assignment)  and was thinking of creating a procedure that would create
a backup copy of the database file (which is a simple typed file) every
time the program was executed but only  if the database file is not
'damage' (or corrupted). So I was wondering if there was a procedure or
some way to find out whether a database file(typed file) is corrupted.

Quote:
> > Are you just stupid or do you just pretend?

> > IF YOU WRITE A PROGRAM TO CREATE A DATABASE, YOU KNOW WHY RECORDS
> > ARE OR ARE NOT CORRUPT, AND YOU (Y O U) HAVE TO DO SOMETHING ABOUT
> > IT!

> Instead of shouting, which is considered impolite as you certainly
> (don't) know, you could have suggested the original poster create a

I know very well that shouting is impolite, and that's why I reserve it
for special occasions.

Quote:
> checksum of the database file. Each time the database is written to,
> the checksum must be recomputed. Before making changes to the
> database, the checksum should be verified. If individual records are
> stored in the database, a checksum field
> can be added to the record type, e.g.:

> type
>   storage = record
>               data : string;
>               checksum : word
>             end;
> var
>   f : file of storage;

> For information on checksums, the original poster should search for
> CRC using his favorite search enginge.

HS, it's an assignment. Adding a CRC to each record may seem nice, but
is absolutely irrelevant in the real world, as it would only detect
changes to individual records. Corruption of records that are not
read (Oh, sorry, he's reading every record in his real life 40 Gb
database every time he runs the program) would go undetected.

If I were his tutor, I would subtract points for adding irrelevant
material. The assignment is to make a simple inventory program, not
a full blown database, I wouldn't have the time to check his bells
and whistles, I would suspect that they are there to hide other
problems!

Robert
--
Robert AH Prins

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 18 Jun 1902 08:00:00 GMT  
 checking a corrupted database typed file

Quote:


>> Are you just stupid or do you just pretend?

>> IF YOU WRITE A PROGRAM TO CREATE A DATABASE, YOU KNOW WHY RECORDS ARE OR
>> ARE NOT CORRUPT, AND YOU (Y O U) HAVE TO DO SOMETHING ABOUT IT!

>Instead of shouting, which is considered impolite as you certainly (don't)
>know, you could have suggested the original poster create a checksum of the
>database file. Each time the database is written to, the checksum must be
>recomputed. Before making changes to the database, the checksum should be
>verified. If individual records are stored in the database, a checksum
field
>can be added to the record type, e.g.:

 >(Snip)

Thanks for the info! :-)

Oh and by the way (for Robert AH Prins), the reason why I'm adding these
extra features into my program is because I can get extra points for  my
assignment as 20% of the total marks is for any extra features in your
program that can enhance the program and I already consult with my tutor and
he agrees that its a good idea as enhancement.

TDR



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. What corrupts a database file??

2. Database file types: Access, Paradox or dBase?

3. Reading database-type files

4. How Do I Check For Valid Type?

5. Overriding Type Checking for Pointers

6. APPEND to a file of record typed file

7. How to file/record lock a typed file.

8. Text file to Type File!

9. database corrupted on (unexpected) power down HELP!!!

10. Corrupted DataBase Vs Recover Time

11. corrupt database.

12. Corrupt database

 

 
Powered by phpBB® Forum Software