Q:

MySQL 5.0.11 Error Code #1215: cannot add foreign key constraint

From what I understand after reading the related SO answers and official docs, I may have a column type mismatch situation or absency of defining a required INDEX situation. However I couldn't solve my case.
Table below is being created successfully
CREATE TABLE `parts` (
`partnum_rev` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part number with revision number',
`status` char(4) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part is live or dead',
`partdef` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part definition',
`makebuy` varchar(4) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part is maked or buyed',
PRIMARY KEY (`partnum_rev`), 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='table that part specific data is hold'

Table below gives MySQL - Error Code 1215, cannot add foreign key constraint.
partnum_rev is primary key for parts table so I couldn't understand my reason. 
can you help me please?
Best regards 
CREATE TABLE `bom` (
`lcn` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'logistics control number',
`status` char(4) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part is live or dead',
`partnum_rev` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'part number with revision number',
`effective_date` date NOT NULL COMMENT 'drawing effective date',
`abolish_date` date DEFAULT NULL COMMENT 'drawing abolish date',
`parent_partnum_rev` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'parent part number with revision number',
`bomlevel` tinyint(3) unsigned NOT NULL COMMENT 'bom level',
`quantity` decimal NOT NULL COMMENT 'quantity',
`quantity_unit` char(2) COLLATE utf8_unicode_ci NOT NULL COMMENT 'quantity unit',
`usage_ratio` decimal DEFAULT NULL COMMENT 'usage ratio',
`mttr` decimal DEFAULT NULL COMMENT 'mean time to repair',
`purchasecost` decimal unsigned DEFAULT NULL COMMENT 'purchasing cost',
`moneyunit` varchar(3) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'purchasing cost monetary unit',
PRIMARY KEY (`lcn`), 
FOREIGN KEY (`partnum_rev`) REFERENCES part(`partnum_rev`) ON UPDATE CASCADE 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='table for bill of material'

A:

The foreign key clause is wrong - your table is called parts (plural!), not part. Just use the correct table name:
FOREIGN KEY (`partnum_rev`) REFERENCES parts(`partnum_rev`) ON UPDATE CASCADE 

