Hey there everyone,
I am somewhat new to MySQL and have some past experience with various databases.
What I am trying to accomplish seems simple, but I know the method I am going about it is wrong. Some database engines allow what I do, the more accurate ones do not.
I am attempting to create a table as shown below:
[code=text]
CREATE TABLE `mydb`.`INV_Mas terItemList` (
`MasterItemList _ID` INTEGER UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT,
`ModelID` INTEGER UNSIGNED NOT NULL,
`CustomerID` INTEGER UNSIGNED NOT NULL,
`Serial` VARCHAR(45) NOT NULL,
PRIMARY KEY (`ModelID`, `CustomerID`, `Serial`)
)
ENGINE = InnoDB;
[/code]
However, when I do this I get the error that I expect to see (Cannot create an autonumber field that is not a primary key). I want to have a Unique ID that correlates to the line, but not allow duplicate values in the table between those 3 columns.
Is there another way to do this? Or do I just have to do this through programming to verify the integrity of these 3 columns to have the single Unique ID?
I am somewhat new to MySQL and have some past experience with various databases.
What I am trying to accomplish seems simple, but I know the method I am going about it is wrong. Some database engines allow what I do, the more accurate ones do not.
I am attempting to create a table as shown below:
[code=text]
CREATE TABLE `mydb`.`INV_Mas terItemList` (
`MasterItemList _ID` INTEGER UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT,
`ModelID` INTEGER UNSIGNED NOT NULL,
`CustomerID` INTEGER UNSIGNED NOT NULL,
`Serial` VARCHAR(45) NOT NULL,
PRIMARY KEY (`ModelID`, `CustomerID`, `Serial`)
)
ENGINE = InnoDB;
[/code]
However, when I do this I get the error that I expect to see (Cannot create an autonumber field that is not a primary key). I want to have a Unique ID that correlates to the line, but not allow duplicate values in the table between those 3 columns.
Is there another way to do this? Or do I just have to do this through programming to verify the integrity of these 3 columns to have the single Unique ID?
Comment