File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S Record Number Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "B&S Record Number Question" Watch "B&S Record Number Question" New topic
Author

B&S Record Number Question

Katie McGettrick
Greenhorn

Joined: Mar 03, 2006
Posts: 10
Hi all, I realise this is probably a really silly question, and its my first time to post so I hope I don't annoy anyone

I've just started on my SCJD project and I'm in the design phase of the data access part. I've been looking at the instructions, at the part where it tells you about the fields that are in the database and I notice that there are no record numbers, i.e. no unique identifiers for the records in the database. Now, maybe I've just been using relational databases too long but I can't see how this is going to work.

I could of course read all the records and create record numbers for them on the fly but then how do you find them once they've been written to the database? Am I missing something?
Johnny Hastings
Greenhorn

Joined: Mar 09, 2006
Posts: 5
I hadled this issue by caching the data in the application. All interactions that the users have with the data is actually with the application cache of the data, not the file itself. When I read in the records, into a Vector, the order in which they get added becomes their key. Occasionally I write them back out to the file (when needed do to changes by the users), and it doesn't matter what order they end up in as/when they go out.

This is my first post here too, but I hope that helps you some.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Each record is defined by its offset from the beginning of the database file, with record 0 (or 1, depending on how you count) starting at 1 byte past the last byte of the file header.
If the record is 200 bytes long (for example), and the header 400 bytes (for example), that would mean that you can calculate the location of a record in the database as

if you use zero-based recordIds.

Or more correctly, as there's the flag indicating whether a record has been deleted (which I don't count as part of the record):


Therefore the recordId can be determined as


If you ever needed to calculate it based on the position of a record in the database.


42
Katie McGettrick
Greenhorn

Joined: Mar 03, 2006
Posts: 10
Thank you!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: B&S Record Number Question