SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL statements differences

    hey

    what is the best statement? /faster/preferred?

    Code:
    key xyz(sid), constraint xyz foreign key(sid) references Singers(id) on delete cascade;
    Code:
    foreign key(sid) references Singers(id) on delete cascade;
    Code:
    index idx_dr(sid),foreign key(sid) references Singers(id) on delete cascade;
    what is the difference between "key" & "index"

    thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,246
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    KEY and INDEX are synonymous

    FOREIGN KEY, however, is completely different (and doesn't actually do anything in myisam tables)

    note that declaring a FOREIGN KEY will automatically create the underlying INDEX
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    KEY and INDEX are synonymous

    FOREIGN KEY, however, is completely different (and doesn't actually do anything in myisam tables)

    note that declaring a FOREIGN KEY will automatically create the underlying INDEX
    sorry not to mention that, but I am talking about InnoDB.
    so how is foreign key related in innodb?

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you bother to look in the manual?

  5. #5
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you have something to assist with ..so assist, if not i assume you could /exit

  6. #6
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you can't be bothered to look something up in the manual, don't post in a public forum.

  7. #7
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    really? ,,, I am not going to argue with you kid!
    1)
    but if you put your glasses on you could see that I already posted 3 sql's statements, that indicates that I BOTHERED to look at the manual.

    2)These forums are to help guys who are beginner like me! if guys like you monitor every post !! like a bodyguard and giving commands what to post and what not!! that would not be called forums!!
    Forums came to help people who are in need of help like me!

    3)I just do not get the idea of you guys who have free time just to "BLAME".
    I already stated if you have something to help , just help if not keep quit with all respect!

    c ya.

  8. #8
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,246
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by eawedat View Post
    so how is foreign key related in innodb?
    it is done with the REFERENCES syntax
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  9. #9
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah as it's written above..

    thank you very much


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
  •