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

B&S 2.1.2 Record number

 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
What is your interpretation of the record number ?
Considering the definition of the RecordNotFounException that I have received in my specifications : "Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.", the record number is the index of a record in the file, not taking care if the record is deleted or not.
So, it can happen that in database i have the first , let's say, 9 elements deleted, the 10'th element valid, in which case the read method will throw RecordNotFoundException for record numbers from 0 to 8 but read(9) will return the only record that is valid. Should not be more natural when the record number will be index the valid records in the database ? But in this case, throwing RecordNotFoundException from the read method will make no sense .... because internally I will read only valid records.
Please help ...
Thanks,
Liviu
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, what I wanted to ask is if the record number of a record is dependent from its position in the database file . This was my first thought when I started to work at the project, now I was reviewing my code and I started questioning some of my decisions. After digging a bit in the previous forum discussions I'm sure now that is correct to calculate the record number using the record offset in the file.
Thanks anyway
 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The recNo used in your implementation:

i.e.: find(int recNo)

Has nothing to do with the positioning of the data in the database file, more so the recNo is a unique identifier for the record or more simply the primary key. You have to decide what the primary key is (I would document this decision in your choices.txt).

And lastly, yes, you would have to calculate the offset of each record taking into consideration the initial offset and the length of each record which is specified in the instructions.html.
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Justin,
Has nothing to do with the positioning of the data in the database file, more so the recNo is a unique identifier for the record or more simply the primary key

Having as the record number the record position in the file it is also a good primary key. Don't you think so ?
 
Liviu Carausu
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Let's put it another way : In my solution the record numbers are not necessarily continuous if some database records are deleted. The record number is strictly dependent from the position in the file. At the client, to be shown in the table, the record numbers will be remapped to the table model indexes. But the table model is built based only at the results of the find() method which returns an array of record numbers.
I see here that it will be possible to keep a mapping recordNumbers - offset in file for the database records. The question is if is it worth maintaining this mapping... The clients works anyway with indexes, is it nowhere specified that they must be continuous.
Thanks,
Liviu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic