Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-01-2009
Member
 
Join Date: May 2008
Posts: 860
How to manage duplicates ?

I am in a key moment of development and I wanted to have a board on how you do to optimize my treatment to identify duplicates basis for an update since the key and value are unique.

The elements are:
- An associative array built from upstream values posted via a form (key/value)
- A database

Do I have to scan my associative array to identify the duplicate of the table, to select and directly compare the values and key base? Only the field values and then see if the id matches the key of the table? I do not know if I'm clear ...
Reply With Quote
  #2  
Old 21-01-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: How to manage duplicates ?

Just be clearer to your points!

Why are you using a table if you do not want to duplicate? A Map (HashMap) would be more appropriate. You want to identify the duplicate of the table or base?

- And if the value is unique, why do you use a key?
Reply With Quote
  #3  
Old 21-01-2009
Member
 
Join Date: May 2008
Posts: 860
Re: How to manage duplicates ?

I am quite newbie and so excuse my shortcomings. I just tried using HashMap to store the values from my form mailed to my servlet.

In fact in the end I wish I could say:
Ok, if there are duplicates. What would you do?
Cancel the operation or the value ...

I come now to show in my servlet:
id 50 -> 608768
id 69 -> polo
id 51 -> game

I wondered if I had already scanned my table but there would be a record with the 4th ID 80 -> polo then do another scan in the database. First compare the values and look if the idea is the same because I can very well shift values unchanged ... I do not know if it is more clear.

In the end it was spotted in duplicate in the basic and HashMap as it is possible that the user enters id 50 -> "abc" id 51 -> "abc" and in this case I have a duplicate. This is an updated field for each key (for single shot) posted via a hidden (the principle of PHP foreach with whom I do not worry)
Reply With Quote
  #4  
Old 21-01-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: How to manage duplicates ?

Blazej

Honestly it's not yet clear. From a general point of view what do you think of the following?

Case 1 (duplicates on the key base-form):
If the "id1" => "hello" is present in base and that in your entry form "id1" => "other" is entered.

Case 2 (doubling of value-based form):
If the "id1" => "hello" is present in base and that in your entry form "id2" => "hello" is entered.

Case 3 (duplicate the key and value-based form):
If the "id1" => "hello" is present in base and that in your entry form "id1" => "hello" is entered.

Case 4 (duplicate key form only):
If the entries "id1" => "hello" and "id1" => "other" is entered in your form.

Case 5 (duplicate value form only):
If the entries "id1" => "hello" and "id2" => "hello" is entered in your form.

Case 6 (duplicate key / value form only):
If the entries "id1" => "hello" and "id1" => "hello" is entered in your form.

For each case, is it possible (is it supposed to happen in normal operation)? and how do you want to manage the situation (what would you get the final result)?
Reply With Quote
  #5  
Old 21-01-2009
Member
 
Join Date: May 2008
Posts: 860
Re: How to manage duplicates ?

Thank you to you for your investment, you have almost everything.

So the purpose is to identify whether or not duplicate and say:
1 - "I force (only) the values posted (as)
2 - "I will not validate any value" (rollback)

This shows that the form is necessarily from the base and the idea is a hidden field (I post in the form to create the link and find my small update lines)

Case 1: Update the value for the specified id
Case 2: duplicate alert!
case 3: value does not change if it does not happen to be, update the same value in some way
case 4: impossible, the key is unique!
Case 5: possible in this case, duplicate alert!
Case 6: impossible, the key is unique!

It's a bit like this you had a back office to update the price list of items from your base. Each item has its own id. You make an updated overall price of all your items on the screen but you if you have benchmarks before 2 times the same price or, if your prices are all different take, check that they do not exist in base . I hope that is clearer.
Reply With Quote
  #6  
Old 21-01-2009
XSI XSI is offline
Member
 
Join Date: May 2008
Posts: 271
Re: How to manage duplicates ?

Quote:
Originally Posted by Blazej View Post
"I force (only) the values posted (as)
In this case, it means that you remove the couple id present value basis (or you ignore the previous detected in the form) and you insert the new couple key-value that's it?
Or is it that couple of id value in the database represent a significant volume (eg> 50000 entries)?
Reply With Quote
  #7  
Old 21-01-2009
Member
 
Join Date: May 2008
Posts: 3,971
Re: How to manage duplicates ?

You have two options:
- Either you do a sql select query for each input parameter sent in the form
- Or you do a single sql select query to the top of your salary to feed a Map and a temporary Set

The first is not penalized if you have very few entries seized in form, but it is "long" to make as many entries as requested if you have a lot.

The second penalty is if you have a high volume but is more effective if you have a manageable volume base and the processing time will not be proportional to the number of form fields.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to manage duplicates ?"
Thread Thread Starter Forum Replies Last Post
TreeMap and duplicates Logan 2 Software Development 5 10-02-2010 02:06 AM
Deleting Duplicates in OpenOffice Bansi_WADIA Operating Systems 3 24-10-2009 06:41 PM
Search for duplicates in EXCEL ADELIO Windows Software 3 19-10-2009 10:46 AM
How to find duplicates in Picasa Madison Technology & Internet 3 07-08-2009 10:34 PM
Delete duplicates on Outlook C.M.D Windows Software 5 02-09-2008 03:51 PM


All times are GMT +5.5. The time now is 12:46 AM.