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 trialKirk Billings
3,420 PointsDifficulty with Code Challenge.
I am having severe difficulties with the Task Challenge 3 with Auto_Incrementing keys. I have struggled to get past this Challenge. Is there anyway to help me determine what is wrong with the following command?
ALTER TABLE t_movies ADD COLUMN fk_genre_id INTEGER FOREIGN KEY ADD CONSTRAINT (fk_genre_id) REFERENCE t_genres(pk_id);
Thanks in advance for your help.
2 Answers
Steven Parker
231,248 PointsHaving the link helped cleared it up.
- you do need a comma before "
ADD CONSTRAINT ...
" - the term "
FOREIGN KEY
" comes after "CONSTRAINT
" - the term "
REFERENCES
" must be spelled with an "S
"
So the revised query would be:
ALTER TABLE t_movies ADD COLUMN fk_genre_id INTEGER, ADD CONSTRAINT FOREIGN KEY (fk_genre_id) REFERENCES t_genres(pk_id);
Kirk Billings
3,420 PointsSteven,
Thanks for your help. Here is the link. I tried adding a comma without success.
Thanks again. Any insights are welcome. I am still struggling.
Regards,
Kirk
Kirk Billings
3,420 PointsSteve,
Thank you very much. That worked great.
Regards,
Kirk
Steven Parker
231,248 PointsSteven Parker
231,248 PointsCould you provide a link to the challenge page? Or at least mention which course this is for.