• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

id of a record

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my database interface i have the following method-declaration:

//Creates a new record in the database (possibly reusing a deleted
//entry). Inserts the given data, and returns the record number of the
//new record.
public int create(String[] data) throws DuplicateKeyException;

and my databasedefinition has no "primary key". the only thing what i have is a unique name. and which one should be the record number? should i generate a map with the id's and the unique name? or maybe a map with the id of the record and with the start-position in the db-file?

regards,
[ April 09, 2007: Message edited by: Daniel Vogt ]
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

May I ask you to read the



naming guideline again and update you display name accordingly?

Furthermore, if you have a kind of primary key, that is great. I do not have it. So mapping that key to the file position sounds a pretty good idea/solution.

Why do I not have a primary key?!
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Daniel,

The DuplicateKeyException can be throw if you can define a unicity criteria, and this depend on your database structure. Even if this sound strange there are some situation where you can not define a reliable unicity criteria and in this case you can not throw the DuplicateKeyException, but you need to document your decision.


regards M.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic