Results 1 to 7 of 7

Thread: How to manage duplicates ?

  1. #1
    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 ...

  2. #2
    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?

  3. #3
    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)

  4. #4
    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)?

  5. #5
    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.

  6. #6
    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)?

  7. #7
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,940,339.57329 seconds with 17 queries