I have a ques similar to: How to create foreign key that is also a primary key in MySQL?
however my schema seems to match the answer but still returns the error "ERROR 1005 (HY000): Can't create table (errno:150)"
CREATE TABLE po_items (
job_id CHAR(3) NOT NULL,
po_id CHAR(3) NOT NULL,
item_id CHAR(3) NOT NULL,
quantity SMALLINT,
PRIMARY KEY (job_id, po_id, item_id),
FOREIGN KEY (job_id, po_id) REFERENCES pos(job_id, po_id)
) ENGINE = INNODB;
CREATE TABLE items (
item_id CHAR(3) NOT NULL,
descr CHAR(10),
on_hand SMALLINT,
price DECIMAL(5,2),
PRIMARY KEY (item_id),
FOREIGN KEY (item_id) REFERENCES po_items(item_id)
) ENGINE = INNODB;
Thanks in advance