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 trial

Databases Creating and Modifying Database Tables Creating and Modifying Database Tables Making Changes to a Database

Tadjiev Codes
Tadjiev Codes
9,626 Points

What'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
Steven Parker
231,272 Points

It looks like you named a column "last Name" (with a space) instead of "last_name" (with an underscore).

Tadjiev Codes
Tadjiev Codes
9,626 Points

Thanks for the response Mr.Steven but still sth is wrong there

Steven Parker
Steven Parker
231,272 Points

Try using the single-line form of defining field as a foreign key as shown in the video:

FAVORITE_ROCK_ID int REFERENCES ROCKS(ID) 
Tadjiev Codes
Tadjiev Codes
9,626 Points
CREATE 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
Tadjiev Codes
9,626 Points

Still couldn't solve the challenge LOl weird challenge

Steven Parker
Steven Parker
231,272 Points

There may be some problem with the challenge itself. Submit a bug report to the Support folks.

Tadjiev Codes
Tadjiev Codes
9,626 Points

Alright thanks for the suggestion Mr.Steven)))