Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Inventory Database Help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
basharious




PostPosted: 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.



databaseassignement.t
 Description:

Download
 Filename:  databaseassignement.t
 Filesize:  7.19 KB
 Downloaded:  72 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
basharious




PostPosted: Mon Mar 27, 2006 11:32 pm   Post subject: (No subject)

whoops....I forgot to provide the last_id file


last_id.t
 Description:

Download
 Filename:  last_id.t
 Filesize:  7 Bytes
 Downloaded:  78 Time(s)

Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
basharious




PostPosted: 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.
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: