Ok I am still unable to create a foreign key restraint in my database. I know I posted this in another post, but after 3 or 4 days with no responses, I wanted to reword and properly explain my problem. I executed two show create table commands for my two tables. Here are the results.
Table Create Table rlbbulbs
CREATE TABLE `rlbbulbs` (
`bulbID` int(11) NOT NULL AUTO_INCREMENT,
`item` char(255) DEFAULT NULL,
`brandID` int(11) NOT NULL,
`bulbDesc` longtext,
`cost` text,
`price` text,
`qtyPerPrice` char(100) DEFAULT NULL,
`wattage` char(255) DEFAULT NULL,
`voltage` char(255) DEFAULT NULL,
`base` char(255) DEFAULT NULL,
`glass` char(255) DEFAULT NULL,
`filament` char(255) DEFAULT NULL,
`avgLife` char(255) DEFAULT NULL,
`beamAngle` char(255) DEFAULT NULL,
`catagory` char(255) DEFAULT NULL,
`oldPage` char(255) DEFAULT NULL,
`keyWords` longtext,
`image1` char(255) DEFAULT NULL,
PRIMARY KEY (`bulbID`),
UNIQUE KEY `bulbID_3` (`bulbID`),
UNIQUE KEY `bulbID_4` (`bulbID`),
KEY `bulbID` (`bulbID`),
KEY `item` (`item`),
KEY `bulbID_2` (`bulbID`),
KEY `item_2` (`item`),
KEY `item_3` (`item`)
) ENGINE=InnoDB AUTO_INCREMENT=1595 DEFAULT CHARSET=latin1
Create Table rlbbrand
TABLE `rlbbrand` (
`brandID` int(11) NOT NULL AUTO_INCREMENT,
`brandName` varchar(255) DEFAULT NULL,
PRIMARY KEY (`brandID`),
UNIQUE KEY `brandID` (`brandID`),
UNIQUE KEY `brandID_2` (`brandID`),
KEY `brandName` (`brandName`)
) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=latin1
I know I have duplicate entries for keys and unique keys. I want to create a foreign key for brandID which is what relates the rlbbrand table to the rlbbulbs table. Many bulbs can have the same brand. It was suggested to me that I should make sure all the fields and data types were the same for both tables, which I have. It was even suggested that I set brandID to "Unique" within the rlbbulbs table, which I think is wrong, but tried it anyway and got an error saying "1062 Duplicate entry '1' for key brandID". Please I need to resolve this. I have been trying to correct this issue for a week now, but cant seem to figure it out and noone has seemed to be able to help me in forums. Thanks for any help and suggestions.
Tony