SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru DeNasio's Avatar
    Join Date
    May 2001
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about the primary key

    Hello,

    Take a look at the two tables at

    http://www.webmasterbase.com/article.php/228/503

    I want to create something like this. But I have a question. If I delete the Author Kevin Yank, won't Joan Smith get id=1 and therefore screw up the relation between the two tables?

    I read somewhere on this board that if you delete a row in a table, the primary key kolomn will be rearranged.

  2. #2
    SitePoint Wizard johnn's Avatar
    Join Date
    Mar 2001
    Location
    Southern California, USA
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    It won't happen. Test it yourself.

    John

  3. #3
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Question about the primary key

    Originally posted by DeNasio
    I read somewhere on this board that if you delete a row in a table, the primary key kolomn will be rearranged.
    I believe what you're thinking of is MySQL will rearrange the rows to fill the space left by deleting a row - but the primary key is not affected.

    (I know I didn't explain that well and it's probably wrong, but there's something to that effect that it does.)
    Kevin


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
  •