You are here: My boss beats me « MsSQL Server « IT news, forums, messages
My boss beats me

Posted by NickName on 05/22/06 23:28

I thought I'm pretty good with sql. Was presented with a little
challenge the other day, a colleague asked me to create a parent to
child relationship for a table without changing db schema. The table
looks like this
pkID parentID altPKfield
1 null abc
2 1 def

It's obvious parent to child relationship via pkID and parentID columns
would do a perfect job, however, he specifically asked not to use pkID
but altPKfield instead.

My first thought was to create a sort of 'ghost column' for 'alt parent
field', then, it goes like using a UDF to get pkID value, use temp
table or table variable, it worked but took quite a bit of time.

The next day, the colleague told me our boss has another solution, that
is, he joins this same table twice to geneate a fourth column of
another pkID, and it works perfect and it's very elegant compared to my
approach.

Question here is, would you know/use his approach without learning this
techque? Second question is, would there be any downside on using
this alternative approach of creating a parent to child relationship
for the same table not using PK column?


Thanks.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация