SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Guru Husain's Avatar
    Join Date
    Sep 2001
    Posts
    620
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question What's wrong with using auto_increments?

    With reference to this thread I would like to know why I should not use auto_increments.

    I am writing my own code for forums and have used auto_increments for ThreadID, MemberID, and so on. Why should I not use auto_increments? What are the other alternatives for creating unique numbers to identify records in a database?

    NOTE: Since this topic is new to me, I request you to keep your explanations simple. Thank you.

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there's nothing wrong w/ using AUTO_INCREMENT when it's necessary. if you have a column that will suffice for the PRIMARY KEY, use it. but, AUTO_INCREMENT is fine if you need it. for your forum example, in the users table, you could use the username as the PRIMARY KEY, since it has to be unique, right? however, i, personally, wouldn't do that for a couple of reasons. first, because numbers take less space and can be compared faster by MySQL. and second, for a forum, wouldn't you be linking each post to the users table with some kind of ID? in that case, you definitely want to use numbers (e.g. AUTO_INCREMENT).
    Last edited by DR_LaRRY_PEpPeR; Jan 14, 2002 at 16:05.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


Bookmarks

Posting Permissions

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