Welcome to the Treehouse Community
Looking to learn something new?
Why does my foreign key constrant not work?
I am getting an error message to add a foreign key constraint.
CREATE TABLE MEMBERS (ID PRIMARY KEY, FIRST_NAME, LAST_NAME, FAVORITE_ROCK_ID PRIMARY KEY REFERENCES ROCKS(ID));
You are attempting to create two primary keys in the same table. Eliminate PRIMARY KEY from your FAVORITE_ROCK_ID column so you just have:
CREATE TABLE MEMBERS(ID PRIMARY KEY, FIRST_NAME, LAST_NAME, FAVORITE_ROCK_ID REFERENCES ROCKS(ID));
Ignore.... i see my mistake.
it is suppose to be CREATE TABLE MEMBERS .......NOT ROCKS.
Your statement would create a table named ROCKS. It needs to create a table named MEMBERS.