SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Performance two keys a PK or ...

    Hi,
    What's the best way
    Code SQL:
    CREATE TABLE  `bookmark` (
      `user_id` INT(10) UNSIGNED NOT NULL,
      `video_id` INT(10) UNSIGNED NOT NULL,
      `date` datetime NOT NULL,
      PRIMARY KEY (`user_id`,`video_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
     
     
    CREATE TABLE  `bookmark` (
      `id` INT(10) UNSIGNED NOT NULL,
      `user_id` INT(10) UNSIGNED NOT NULL,
      `video_id` INT(10) UNSIGNED NOT NULL,
      `date` datetime NOT NULL,
      PRIMARY KEY (`user_id`,`video_id`)
      KEY `index1` (`user_id`),
      KEY `index2` (`video_id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

    and why

    Thanks in advance.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,018
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    the first one is better, because in the second one, the id column is useless
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •