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 trialAustin Cumberlander
13,997 PointsWhat'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) );
Jennifer Nordell
Treehouse TeacherIt would also be advisable to show the challenge you're working on It's hard to give an articulate answer with so little information to go on.
Austin Cumberlander
13,997 PointsSorry... I thought it would post the challenge I was currently working on.
Jennifer Nordell
Treehouse TeacherAustin Cumberlander Unfortunately, that doesn't happen in the database category for any of the challenges.
Roxanne Reyes
9,006 PointsI 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
Treehouse TeacherHi 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!
Austin Cumberlander
13,997 PointsThis worked! Thanks!
victor cooper
6,436 Pointsi dont think the problem is with the primary key the first_name and last_name need to have varchar(255). try that.
juanbaena
Courses Plus Student 721 Pointswell im stuck here to, can Jennifer Nordell just check it off so I can continue my path?
manjinder rahal
1,903 PointsCREATE TABLE MEMBERS (ID PRIMARY KEY, FIRST_NAME, LAST_NAME, FAVORITE_ROCK_ID REFERENCES ROCKS(ID) );
THIS WILL WORK
Roxanne Reyes
9,006 PointsThank you Manjinder. It worked!! ;)
Stephanie Czetli
13,180 PointsThis code returns this TH error: "Bummer: Make sure you're id only allows unique values. Hint: ID PRIMARY KEY"
victor cooper
6,436 Pointsvictor cooper
6,436 PointsCould you show what code you are trying to use?