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 RecordNumbers and FlightNumbers! 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 "RecordNumbers and FlightNumbers!" Watch "RecordNumbers and FlightNumbers!" New topic
Author

RecordNumbers and FlightNumbers!

Lina Mahl
Greenhorn

Joined: Jul 02, 2002
Posts: 13
Am I the only one that is irritated that you are supposed to use recordnumber and not flightnumber as a unique identifier for the Flights?
I mean that flightnumber are unique. Recordnumber are just a number in a database.
I can live with it but I would have made the flightnumber the key value in my database.
regards
/Lina
friso dejonge
Ranch Hand

Joined: Jul 11, 2002
Posts: 162
And yes i don't like it either. According to me the flightnumber is the unique key as the add and find functionality search for the first row, which is the flightnumber.
You cannot add records with duplicate flightnumbers (at least not programmatically, through the add method).
Therefore i am using the flightnumber as unique key and put that in my assumptions, but i havent finished the certification.
However mark s.(bartender) points out the flightnumber may not be the unique key and he wrote another function to get the recordnumber, which is then used as unique key.
So, no conclusive answer.


swimming certificate (A & B), shoelaces diploma, and some useless java ones.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

I think that the db.db file is just a small db. And the flights all seem to fly on only one day. But in the real world flights have the same flight number each and every day.
Now of course, this also isn't a real world app. But by looking at the code that Sun supplied in the Data class, it's getRecord method is using the record number. But the find method uses flight number, and it only returns one record.
Here's a quote from the Javadoc, so this will tell us that we can look at both a the PK, so we can all be happy
/**
* This method searches the database for an entry which has a first
* field which exactly matches the string supplied.
If the required
* record cannot be found, this method returns null. For this
* assignment, the key field is the record number field.

*
* @param toMatch The key field value to match upon for
* a successful find.
* @return DataInfo The matching record.
* @exception DatabaseException Thrown when database file could not be accessed.
*/


The first bold line leads us to believe that Flight Number can be used as the Primary Key, but the second line explicitly says Record number is the key for theis assignment.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Eduard Jodas
Ranch Hand

Joined: May 14, 2002
Posts: 80
I mean that flightnumber are unique. Recordnumber are just a number in a database.

RecordNumber is also unique. And it is always there, while a flightnumber may change. RecordNumber is the key to access a Record, which is the flight data container, and the flight data is much more important that just its flightnumber.
If you lock by flight number, in the end, the database must also lock by record number. And what happens if you lock by flight number because you want to change the flight number?
Locking by record number is much easier, and it is what is required for the assignment.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RecordNumbers and FlightNumbers!