我有這個數據庫結構作爲主鍵的字符串?
CREATE TABLE `productinfo` (
`ProductID` int(11) NOT NULL AUTO_INCREMENT,
`ProductName` varchar(255) NOT NULL,
`ProductImage` varchar(255) NOT NULL,
`CategoryID` int(11) NOT NULL,
`SubCategoryID` int(11) NOT NULL,
`ProductBrief` varchar(255) NOT NULL,
`Features` text NOT NULL,
`Specifications` text NOT NULL,
`Reviews` text NOT NULL,
`Price` varchar(255) NOT NULL,
`Status` tinyint(4) NOT NULL,
PRIMARY KEY (`ProductID`)
) ENGINE=MyISAM AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;
我現在我需要把產品ID,類別ID,並SubCategoryID到像PS-5678一個字符串的部件號。 ProductID是主鍵,所以如何更改數據庫的結構。類別ID,並SubCategoryID在其他表的主鍵,以便如何處理this..is它那麼容易,因爲轉彎
`ProductID` int(11) NOT NULL AUTO_INCREMENT
成string..and擺脫
PRIMARY KEY (`ProductID`)
的意見,建議任何人
特別是如果您需要處理ORM,只需保留現有的PK並在「漂亮的字符串產品ID」上使用唯一的覆蓋索引就更容易了(實際上這聽起來有點類似於SubCat的非規範化,等等......) – 2010-11-03 23:15:09