http://qs321.pair.com?node_id=187248

aufrank has asked for the wisdom of the Perl Monks concerning the following question:

hey all--

I'm working on some more DBI stuff and have kind of hit a wall. The stopping point is not perl, though, it's the way the databases I'm working with were set up. A brief explanation:

  • four fields: id, last_name, first_name, address
  • id is guaranteed to be unique, not guaranteed to be defined
  • last_name and first_name are guaranteed to be defined, but not to be unique
  • address is probably defined and is probably unique
  • the problem is that I have many different tables, and need to try to bring the information together, but cannot afford to match the wrong information with the wrong person. if I use the id field to identify and compare records across tables, I'll get correct matches but will not process all the records. if I use some combination of names and address, I risk incorrectly matching records where the names are the same and the addresses aren't defined.

    the first reply below is my implementation of a system that matches entries from different tables by id if possible, and if not, by names and address. (thought I should put it in a reply to keep it from cluttering the SOPW page).

    I guess I have three questions: 1) is there a better general strategy to deal with the problem? 2) is the code I have included an effective way of implementing the solution I've suggested, and 3) what suggestions should I make to the people that actually do the db design that might keep this sort of thing from happening with future tables that are created?

    if you feel that the real issue is simply a failure on my part to comprehend something basic and important, please include a link to someplace I can read up on it-- I'm fully aware of just how ignorant I may very well be, but not quite sure what I'm ignorant of! :D

    please do take a look at the code below,
    --au