| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

03-23-09, 21:29
|
|
Registered User
|
|
Join Date: Feb 2009
Posts: 104
|
|
|
primary keys with variable length?
|
|
Is there any problem with using a varchar type for a primary key (in terms of efficiency, etc.)?
|
|

03-23-09, 22:17
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
no, not really

|
|

03-24-09, 00:04
|
|
Registered User
|
|
Join Date: Feb 2009
Posts: 104
|
|
|
thanks
|
|
Cool; primary keys can be descriptive.
|
|

03-24-09, 10:41
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
|
|
Yes, in which case they are frequently referred to as "natural keys". The corollary would be "surrogate keys", which by definition convey no information about the record they represent.
My God. I am embarrassed to admit it took me three attempts with the spell-checker to spell corollary correctly.
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

03-24-09, 11:16
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
It took me one attempt to look it up
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

03-24-09, 11:20
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
Quote:
|
Originally Posted by rbfree
Is there any problem with using a varchar type for a primary key (in terms of efficiency, etc.)?
|
Depending how you define efficiency, the specific nature (maximum length for example) of the primary key data, whether or not you use it in foreign keys and also what you propose instead of the natural key, there *might* be a "problem".
But Rudy is quite correct - there's nothing inheritantly wrong with varchar PKs.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

03-24-09, 11:50
|
|
Registered User
|
|
Join Date: Feb 2009
Posts: 104
|
|
|
thanks blindman
I appreciate this information. Re. the spelling... remember, the more we know, the more we can forget (apology of a geezer... though not to imply that anyone but me is a geezer...)
Quote:
|
Originally Posted by blindman
Yes, in which case they are frequently referred to as "natural keys". The corollary would be "surrogate keys", which by definition convey no information about the record they represent.
My God. I am embarrassed to admit it took me three attempts with the spell-checker to spell corollary correctly.
|
|
|

03-24-09, 11:58
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
varchar keys aren't necessarily natural keys
and the word you were looking for, blindman, is opposite, not corollary
(apology of a nitpicking geezer, or a picnicking teaser, or ... )
|
|

03-24-09, 12:11
|
|
Registered User
|
|
Join Date: Feb 2009
Posts: 104
|
|
|
thanks all and semantic quibble for r
These primary keys that I'm talking about will have short max lengths -- VARCHAR(6) ... or something under (10), whatever they might be.
Re. opposition and corollary, an opposition can be offered as a corollary.... a lovely case of non-conflicting apposition.
|
|

03-24-09, 14:14
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
|
|
Actually, I think the most appropriate term would be "complement".
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|