Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTadjiev Codes
9,626 PointsWhat's wrong with my version?
Now recreate the MEMBERS table with the new FAVORITE_ROCK_ID column, and make sure it has a foreign key constraint to the ID column of the ROCKS table. The columns should now be: ID, FIRST_NAME, LAST_NAME, and FAVORITE_ROCK_ID.
CREATE TABLE members
(
id int NOT NULL PRIMARY KEY,
first_name varchar NOT NULL,
last Name varchar NOT NULL,
FAVORITE_ROCK_ID int,
foreign key(FAVORITE_ROCK_ID) REFERENCES ROCKS(ID) );
Error is making sure to add foreign key Constraint
4 Answers
Steven Parker
231,275 PointsIt looks like you named a column "last Name" (with a space) instead of "last_name" (with an underscore).
Tadjiev Codes
9,626 PointsCREATE TABLE MEMBERS
(
ID int NOT NULL PRIMARY KEY,
FIRST_NAME varchar NOT NULL,
LAST_NAME varchar NOT NULL,
FAVORITE_ROCK_ID int,
CONSTRAINT MEMBERS_ROCKS_FK FOREIGN KEY (FAVORITE_ROCK_ID)
REFERENCES ROCKS(ID)
);
I dunno why but it still doesn't work? I tried to change it including the last name but the error says: Bummer: Don't forget to add the foreign key constraint to the FAVORITE_ROCK_ID column.
Tadjiev Codes
9,626 PointsStill couldn't solve the challenge LOl weird challenge
Steven Parker
231,275 PointsThere may be some problem with the challenge itself. Submit a bug report to the Support folks.
Tadjiev Codes
9,626 PointsAlright thanks for the suggestion Mr.Steven)))
Tadjiev Codes
9,626 PointsTadjiev Codes
9,626 PointsThanks for the response Mr.Steven but still sth is wrong there
Steven Parker
231,275 PointsSteven Parker
231,275 PointsTry using the single-line form of defining field as a foreign key as shown in the video:
FAVORITE_ROCK_ID int REFERENCES ROCKS(ID)