File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes UrlyBird: Primary Key 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 "UrlyBird: Primary Key question" Watch "UrlyBird: Primary Key question" New topic

UrlyBird: Primary Key question

Sihle Manqele

Joined: Sep 28, 2006
Posts: 5
As a South African who grew up in the townships, I've been finding it extremely hard to learn Java on my own, with no peers around to bounce ideas with. Thanks to the forums like this, my job is getting easier every day, so big THANK YOUs to the guys behind these forums!

I'm implementing UrlyBird Ver 1.1.2. The one glaring thing is the lack of the primary key in the schema. It appears the schema should have had the "Number of Available Rooms" field. It's as if the assumption is "on any given day and price, any hotel can only have one room of its kind". Is that a safe assumption?


SCJP 1.4
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
Welcome to the JavaRanch comunity!

Sihle, comrade; we all make that question when we have to implement the data interface provided by Sun Microsystems.

I have read throughout this forum different approaches about how to implement primary keys.

My approach is not to implement it. Although the interface declares a DuplicateKeyException, my implementation ( as required by the documentation) does not throw any exception on creating a new record.

From the Java language point of view is valid that an implementation of class do not necessarily throw the exceptions declared in the method signature of the interface.

Now, if I had to implement a primary key, I would do it with primary key based in all the fields, which is the only logical decision I could take regarding this matter.

But, the decision would complicate also the updateRecord method, since now, an update could violate the primary key.

Surprisingly, the updateRecord method does not declare this exception.

I hope you local community of Java Developers continue to increase and I wish you a lot of success with your SCJD!
[ October 03, 2006: Message edited by: Edwin Dalorzo ]
I agree. Here's the link:
subject: UrlyBird: Primary Key question
It's not a secret anymore!