• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the key for the Database?

 
Richard HWang
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It throws a DuplicateKeyException in createRecord method of interface DBAccess, but there is no further information about the key of the database
in the instruction.
When should I throw the exception? If all fields of the new record is match some record in the database file or if a key field match? and what's the key field you select? many many thzZZZzzz
 
George Marinkovich
Ranch Hand
Posts: 619
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard,
Originally posted by Richard HWang:
It throws a DuplicateKeyException in createRecord method of interface DBAccess, but there is no further information about the key of the database
in the instruction.
When should I throw the exception? If all fields of the new record is match some record in the database file or if a key field match? and what's the key field you select? many many thzZZZzzz

Well, it depends on your particular assignment. For the URLyBird assignment I have heard it argued that there is no key for the database. I haven't read the assignment instructions for URLyBird so I can't independently confirm this, but the arguments have seemed reasonable that a key doesn't really exist in that case. My assignment was B&S Contractors and for that assignment I would argue that name+location comprises the key. So I prohibited the user from creating a record that duplicated an existing name+location combination.
 
Richard HWang
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment is URLBird 1.2.3. I think the Hotel Name & City as a key maybe OK, but not so sure.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Richard
Originally posted by Richard HWang:
My assignment is URLBird 1.2.3. I think the Hotel Name & City as a key maybe OK, but not so sure.

Mine is also URLyBird. But am not using any key for the db. I have gone through many designs here, but I do not remember anyone has used a key for this assignment till now. Maybe someone has used, I don't know. If so, they can give their opinion on this. Thanks.
Good Luck.
 
K. Tsang
Bartender
Pie
Posts: 3228
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The key depends on how you look at the database file.

The hotel name and city together can be a (composite) key. The row number can be a key. As long as it's unique, then it's ok.

When I did mine which was also URLyBird, I used the row number as the so-called key. And some where mentioned row reuse hence I didn't really throw the DuplicateKeyException at all.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic