CREATE TABLE IF NOT EXISTS `scores` (
`userID` int(11) NOT NULL,
`sessionID` int(11) NOT NULL,
`points` double NOT NULL DEFAULT '0',
PRIMARY KEY (`userID`,`sessionID`),
KEY `par_ind1` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
What does the line:
KEY `par_ind1` (`userID`)
do? (userID is a primary key in another table?)
KEYis a synonym forINDEX. This creates an index namedpar_ind1ont the columnuserIDin addition to the composite key it already shares withsessionID.See the MySQL
CREATE TABLEdocumentation for the full details, but the relevant part here is:Since no
index_typewas specified, the default is used. See theCREATE INDEXreference for the default index types, which vary by table storage engine. For an InnoDB table such as this, that’s aBTREEindex.