MrNewbie
02-21-2001, 08:36 PM
In my database program I'm planning to do things like this:
When the user enters a record that is written into a structure to be used in a linked list, and then its sent through a sorting algorithm to order the list elements.
When it is in order the ordered elements are written to the file sort of like this:
A 123 ER
B 312 DF
C 122 GF
If a new element is added later the file is read and the records in it are written into a linked list structure again, then the new record entry is sent through the sorting algorithm again to reorder the list with the new record.
When that is done, the disk file is totally cleared and the structures are written back to the disk file. And the process is repeated every time a new record is entered.
The same thing goes for deleting a record. The linked list is modified to not include the element and the file is cleared then the list is written back to the file.
For searching, the file is read again into linked list elements then compared with the search condition although this time the file is not cleared or written to at all.
So, is this a good way to do things?
I have the code to do pretty much everything, including rereading the tab-seperated file records back (Thanks to TheLinuxDuck). But to clear a file is the best way to delete and recreate it?
I'd like to hear any comments/suggestions.
Thanks
MrNewbie
[ 21 February 2001: Message edited by: MrNewbie ]
When the user enters a record that is written into a structure to be used in a linked list, and then its sent through a sorting algorithm to order the list elements.
When it is in order the ordered elements are written to the file sort of like this:
A 123 ER
B 312 DF
C 122 GF
If a new element is added later the file is read and the records in it are written into a linked list structure again, then the new record entry is sent through the sorting algorithm again to reorder the list with the new record.
When that is done, the disk file is totally cleared and the structures are written back to the disk file. And the process is repeated every time a new record is entered.
The same thing goes for deleting a record. The linked list is modified to not include the element and the file is cleared then the list is written back to the file.
For searching, the file is read again into linked list elements then compared with the search condition although this time the file is not cleared or written to at all.
So, is this a good way to do things?
I have the code to do pretty much everything, including rereading the tab-seperated file records back (Thanks to TheLinuxDuck). But to clear a file is the best way to delete and recreate it?
I'd like to hear any comments/suggestions.
Thanks
MrNewbie
[ 21 February 2001: Message edited by: MrNewbie ]