I have two tables. One is called BooksRead, one is called Authors. Authors has a Primary Key of BOTH author_last_name and author_first_name.
I'm using Netbeans IDE.
I want to alter table BooksRead, which also has columns author_last_name and author_first_name, to reference Authors as Foreign Keys.
ALTER TABLE BooksRead
ADD FOREIGN KEY(AUTHOR_LAST_NAME, AUTHOR_FIRST_NAME)
REFERENCES AUTHORS(AUTHOR_LAST_NAME, AUTHOR_FIRST_NAME);
I've tried to do this many different ways--including adding/naming a CONSTRAINT--but always get the same error:
[Exception, Error code 30,000, SQLState X0Y45] Foreign key constraint 'SQL170903182055780' cannot be added to or enabled on table BOOKSREAD because one or more foreign keys do not have matching referenced keys.