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

Austin Cumberlander
Austin Cumberlander
13,997 Points

What's wrong with my code here?

I've marked the id as a primary key, yet I'm given the error that the id isn't unique. I'm not sure what I've done wrong here.

Challenge Task 3 of 3 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 PRIMARY KEY, FIRST_NAME, LAST_NAME, FAVORITE_ROCK_ID REFERENCES ROCKS(ID) );

victor cooper
victor cooper
6,436 Points

Could you show what code you are trying to use?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

It would also be advisable to show the challenge you're working on :smiley: It's hard to give an articulate answer with so little information to go on.

Austin Cumberlander
Austin Cumberlander
13,997 Points

Sorry... I thought it would post the challenge I was currently working on.

I think you need a data type like int for ID

Example: CREATE TABLE MEMBERS(ID INT NOT NULL PRIMARY KEY, ...

Give that a try

4 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Honestly? I have no idea what's wrong with this code. I can't see it and I've restarted the challenge and done it start to finish three times now. In the very last Step, I use the code you posted above. It has passed for me every time.

My best suggestion is to restart the challenge from Step 1 and then copy/paste your code from above into Step 3.

Hope this helps! :sparkles:

victor cooper
victor cooper
6,436 Points

i dont think the problem is with the primary key the first_name and last_name need to have varchar(255). try that.

well im stuck here to, can Jennifer Nordell just check it off so I can continue my path?

manjinder rahal
manjinder rahal
1,903 Points

CREATE TABLE MEMBERS (ID PRIMARY KEY, FIRST_NAME, LAST_NAME, FAVORITE_ROCK_ID REFERENCES ROCKS(ID) );

THIS WILL WORK

Thank you Manjinder. It worked!! ;)

This code returns this TH error: "Bummer: Make sure you're id only allows unique values. Hint: ID PRIMARY KEY"