Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Records

 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the URLyBird

What are record numbers? They are just the records position in a file right.

so when a record gets marked as deletes (say record 5) do all the following recods move down one spot? (record 6 becomes 5). Then when a new record is added and gets written to the spot the last was deleted, is the new record number 5?

Is it ok to have a collections of type record? A record object just holds strings of all the fields. When the data file is opened I have it filling up the Collection with all the records. Then read just spits out the correct one. Update() updates the Collection and the file
 
Frans Janssen
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kris,

I have the Bodgitt and Scarper assignment and my instructions specify that each record has the following flag:
2 byte flag. 00 implies valid record, 0x8000 implies deleted record
.

I have interpreted just as you that the record number is just the position of the record in the file. I also count deleted records, so if a record is deleted, it keeps the same number.*

For example, the database could have the following contents:

0 - record A
1 - record B
2 - record C [deleted]
3 - record D

If a clients attempts to read or lock record 2, the server throws a RecordNotFoundException.

Frans.

* I think this has to be. Imagine in my example if one client attempts to access record #3, just after another client deletes record #1. Then record #3 would have been renumbered to #2 and the first client would get an exception. Not quite a practical approach!
 
Clivant Yeo
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used the starting position of the record at the file as the record number. Reading the record again is easier by just having to seek the start position using the record number. Hope it helps

With regards,
Clivant
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my assignment, there were no record numbers at all in the database file, so I ended up assigning them upon the startup of the application to whatever order they were read in.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic