Is there a PHP Class That I Can Use to Make Sure My Users Can't Enter the Same Data Twice (Preventing Duplicate Data)?

StackOverflow https://stackoverflow.com/questions/9945559

Question

Problem Overview:

  • My application has an enrollment form.
  • Users have a habit of entering the same person into the system twice.
  • I need to find a way to rapidly and accurately check the data they've entered against the other clients in the database to see if that client is already in the database.

Criteria Currently Being Used:

  • Duplicate SSN
  • Duplicate Last Name and Date of Birth
  • Duplicate First Name, Date Of Birth and Partial SSN Match (another client has an SSN where 5 of the 9 digits are the same and in the same position.
  • Duplicate First Name and Partial SSN Match (another client has an SSN where 5 of the 9 digits are the same and in the same position.
  • Duplicate Last Name and Partial SSN Match (another client has an SSN where 5 of the 9 digits are the same and in the same position.

In addition to these checks, there's been discussion of using soundex to detect matches based on similiar first name / last name.

Is there a PHP class already designed to handle something like this? Can something like this be done at a (Mysql) Database level?

Clarifications:

  • The problem exists not because of a lack of data integrity at the database level but because of typos caused during the entry process. The applicaiton is a data-entry application. Users are taking physical paper copies of forms and entering the data into the application.
Was it helpful?

Solution

If I understand your problem correctly the point is that the duplicates you want to filter out are not necessarely equal as strings. I encountered situations like this a couple of times in the past and I could never find a perfect criteria for finding logical duplicates. In my opinion the best way to deal with such cases is to provide a very smart autocomplete-like functionallity to the user, so when he tries to enter the data he sees all the similar entries and he hopefully won't create a new entry for something he see in the list. Such a soulution can be a good "buddy" of your not-yet-perfect criteria.

OTHER TIPS

Not a php solution, but

You can cast that fields in your database as unique.

ALTER TABLE  `users` ADD UNIQUE (
    `username`
)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top