Friday, April 8, 2011

relational database and net structure

The company Microsoft could be referred as "microsoft", "ms" or "m$" etc. We may say these names are alias to one single identity. If you want to store the "alias" relationship, you might have to do it as the following pairs

microsoft      ms 

ms             microsoft

microsoft      m$

m$             microsoft

ms             m$

m$             ms

Or maybe there's a better approach?

From stackoverflow
  • You can accomplish this with a "TAG" schema.

    interest
    --------
    iPK
    value
    
    junction
    ---------
    iPK
    aPK
    
    alias
    -------
    aPK
    value
    
  • Sure. Don't store a table that shows a bunch of aliases. Instead have each company given one ID number, and use a secondary table to provide the aliases:

    Company table

    CompanyID  PreferredNameID
    12345      934
    

    Name table

    CompanyID  NameID  Alias 
    12345      934     Microsoft
    12345      384     M$
    12345      823     MS
    

    This gives you the ability to have as many aliases as needed, and when you make reports on the company you will reference the preferred name.

0 comments:

Post a Comment