Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2002

    Arrow Unanswered: Using a varchar as a Primary Key VS. using an Identity


    Currently, I am using a varchar "UserName" as a primary key instead of an Identity or GUID.

    System Info:
    When user's sign up they provide the "UserName" that is used as a PK.
    Creating a message board type web application.
    UserNames will never change.
    UserNames are used extensively as FK's in other Tables.
    We want to scale well.

    Does anyone know the implications?
    I understand Joins are faster on numerical values than strings but we will not be performing many joins.

    In my case is it better to use Identity as a PK or is it better to use a varchar for a "Users" table?

    Last edited by jen6677; 01-07-05 at 03:36.

  2. #2
    Join Date
    Aug 2003
    Delft, The Netherlands (EU)
    I'm used to work with identity columns for almost every tabel, since the key shouldn't have any semantics (which could force the key to be changed), it must be unique of cource, and such a key is compact.

    On special occasions, however, I do not follow this golden rule. As you describe, your key will not change, it is unique, and you don't expect any join troubles; so I don't see problems to design your database this way.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts