Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 21st, 2008, 02:33 PM
lokisapocalypse lokisapocalypse is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 474 lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level)lokisapocalypse User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 20 h 54 m 39 sec
Reputation Power: 92
Linking fields

Hello all,

I am updating a database table through an XML file. This XML file is populated via 3rd party app that I do not have access to. Part of the table includes a persons name. In some cases, the same name is entered multiple times but with different spellings such as:

John Doe
J. Doe
John D.
J. A. Doe
JA Doe

etc...

Because I have no control over how the names are initially entered into the database, I cannot prevent this from happening.

Additionally, I cannot manually change these entries because in some reports that are generated, the name needs to be exactly as it was in the XML file.

However, the need has arisen to click on a name and return all references to that name. Using the case above, if I were to click on John Doe, then I would like to get results for each of the cases listed above.

Therefore, I am working on creating an application to allow users to create links from one name to another. This must be done manually because I have cases where I have J. Doe and B. Doe that are two different names.

My first thought was to create a new database table to handle these links. Each unique name has a corresponding id so I can simply save the name id's in a table with the following structure:
int name_a
int name_b

For consistency, I can store the smaller id in name_a. As you can see however, linking n items will yield (n * (n - 1)) / 2 entries into the table. Even though this is polynomial, I have to think there is a better way to do this.

Is there a better approach to solving this problem that I have not seen yet?

Reply With Quote
  #2  
Old April 21st, 2008, 07:24 PM
Lux Perpetua Lux Perpetua is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: San Francisco Bay
Posts: 1,459 Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level)Lux Perpetua User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 16 h 47 m 3 sec
Reputation Power: 336
Right, you definitely don't want to store every pair of linked names. What you want is to associate to each name an identifier such that linked names receive the same identifier. For each identifier, you then have a set of names associated to it, and to retrieve all the entries for an input name, you look up its identifier in your auxiliary database, and for each name associated to that identifier, return the corresponding entries.
Comments on this post
lokisapocalypse agrees: Brilliant suggestion. Worked beautifully. Kicking myself for not being able to think of it myself.
Thanks!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Linking fields


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT