Author |
Message |
basharious
|
Posted: Mon Mar 27, 2006 11:30 pm Post subject: Inventory Database Help |
|
|
Hey Guyzz
I'm working on inventory Database. I'm on Delete a record right now and I just can't get this to work..
So..Here's what I want to do
1.Change the Record's name into deleted
2.move every record to a new file besides the one(s) called deleted
3.remove the old file
4.rename the new file by the name of the old file
Wha't going on is it changes the name to deleted but it does move it to the new file...
Another thing...I think Edit is kinda buggy
Ah...you need the Last_id file (which I provided) but the program will create the database file as soon as you create a record.
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
databaseassignement.t |
Filesize: |
7.19 KB |
Downloaded: |
72 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
basharious
|
Posted: Mon Mar 27, 2006 11:32 pm Post subject: (No subject) |
|
|
whoops....I forgot to provide the last_id file
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
last_id.t |
Filesize: |
7 Bytes |
Downloaded: |
78 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue Mar 28, 2006 4:22 am Post subject: (No subject) |
|
|
what if your program/os/computer crashes during this "deletion" process? You're moving your entire database and deleting the original file.. if something was to happen at that moment, your all data is gone. Just gone.
I think a much simpler way would be to simply overwrite the record to be deleted with the last record in the file. Now the record in question is gone and you have two copies of another record - arbitrary location and the very end. It is trivial to remove the very last record, just move the EOF a step back. No need to move all of the data to another file then back.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
basharious
|
Posted: Tue Mar 28, 2006 8:42 am Post subject: (No subject) |
|
|
yeah...u're right...I never thought this could happen (eventhough it's very probable), but then how would I move the EOF a step back, doesn't it read until it hits the end of file, and I can't change that, Moreover, that would be wasting memory and space (if working with large database) because no one wouold be able to ACTUALLY delete the record.
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Tue Mar 28, 2006 2:55 pm Post subject: (No subject) |
|
|
aren't you using binary read/write with records? if so, you could seek to a location and write at that point in a file.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
|