Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Integrity is broken

 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I test the implementation of access to the file and I found that I have violated the integrity of the data.

Before the record is created, it will first be verified Key. If record with same key already exists in the database, then throw DuplicateKeyException.

But the method can not throw updateRecord DuplicateKeyException. Although I can also change the key of record with updateRecord. Integrity is broken. What to do?
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I should ignore DuplicateKeyException? Except to the interface it is not mentioned anywhere else and at the interface is no description when throw DuplicateKeyException.

Customer holding this record - The id value (an 8 digit number) of the customer who has booked this. Note that for this application, you should assume that customers and CSRs know their customer ids. The system you are writing does not interact with these numbers, rather it simply records them. If this field is all blanks, the record is available for sale.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my assignment (the URLyBird one) I simply don't have a key, so I certainly can't update the key. And I don't think it is a good idea to update your primary key. So the createRecord throwing the DuplicateKeyException and the updateRecord not is just common sense.
My create-method does not throw a DuplicateKeyException, because like I said before there is simply no primary key: a hotel can have multiple available rooms with the same characteristics.
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

I think I just need to ignore DuplicateKeyException. I do not have a primary key.

The id value (an 8 digit number) of the customer who has booked this.


Theoretically, a customer can book a lot of rooms. For example, if the customer is a company. Other fields too, can not be the primary key.

my URLyBird version is 123
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Kachen wrote:I think I just need to ignore DuplicateKeyException. I do not have a primary key.

Don't forget to argument this decision in choices.txt
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's exactly the reason why I didn't implement this - the update method. I just commented this in choices.txt, and added that now the record number is effectively the key. This makes the data class much simpler and performant, too.
 
David Kachen
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic