Table Building Query

  • Hi All,

    I have built a smalll contact database with some 15 tables or so.

    I have made some fields mandatory, and some unique. I have noticed that making a field mandatory and unique appears to crate an index. Is this correct?

    Do I not need to create indexes for mandatory unique and primary key fields, just the other fields that I want indexed, such as surname etc?

    Forgive the noobie question, but this is my first venture into building constraints and indexes into a database. I am doing thi sbecuase I am expecting some 800,000 records to be inserted.

    Paul

  • Paul_Harvey (12/2/2009)


    I have noticed that making a field mandatory and unique appears to crate an index. Is this correct?

    Making a field unique creates an index. The mandatory part has nothing to do with it. The way that SQL enforces uniqueness (either unique constraint or primary key) is to create an index on that column or set of columns.

    This series may be of use to you. http://www.sqlservercentral.com/articles/Indexing/68439/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thank you. I'll read the articles.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply