• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Records

 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic