Originally posted by Mark Spritzler:
If you go to create a record and the key is already in the database, then this is a duplicate key. In real databases you have primary key which must be unique. So if you try to create a new record where the primary key already exists the database will throw back an error.
This is what Sun is looking for here.
If you have a primary key that is a number and the current values in the database are
1
3
4
5
and you try to insert a new record with a primary key of 2, then it will let you, if you try to insert a new record with a primary key of 4, then it will throw an error.
Hope that helps.
Mark
Peter
SCJP, SCJD, SCWCD, SCBCD
Peter
I do not believe there is a unique key in the provided database. There could logically be multiple records with the exact same data (a hotel could have multiple rooms with the same specifications avaiable at the same time for the same price). If there was a room number field, then a unique combination could be established.
I am planning on not throwing the DuplicateKeyException and explaining it in my designchoices.txt.
My app adds the new row if there are no existing matching rows or there are matching rows that are vaild. If there is a matching row that is deleted, that row is validated and a new row is not added.