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 trialCharles Gray
19,470 PointsDatabase help
Alter the "t_movies" table to add a foreign key called "fk_genre_id" and constrain it to reference the "t_genres" "pk_id".
ALTER TABLE t_movies ADD COLUMN fk_genres_id INTEGER NULL, CONSTRAINT FOREIGN KEY(fk_genre_id) REFERENCE t_genres(ph_id)
I think I've tried everything, even wrote instructions down and followed it, nothing seems to work
8 Answers
Charles Gray
19,470 PointsOK i figured it out REFERENCE, needed to be REFERENCES with an 's'
sushil sharma
Courses Plus Student 260 Pointsuse REFERENCES, instead of REFERENCE
Charles Gray
19,470 PointsALTER TABLE t_movies ADD COLUMN fk_genres_id INTEGER NULL, CONSTRAINT FOREIGN KEY(fk_genre_id) REFERENCE t_genres(ph_id)
Michael Nguyen
6,138 Pointstry
ALTER TABLE t_movies ADD COLUMN fk_genre_id INTEGER NULL, CONSTRAINT
FOREIGN KEY(fk_genre_id) REFERENCE t_genres(pk_id)
typo issue
Charles Gray
19,470 PointsThat didn't work at all.
Vernon Watson
8,854 PointsALTER TABLE t_movies ADD COLUMN fk_genres_id INTEGER, ADD CONSTRAINT FOREIGN KEY(fk_genre_id) REFERENCES t_genres(ph_id);
YAYYY!
Vic Phillips
1,067 PointsI am getting an error, "You're missing the 'fk_genre_id' column".
This is my code below:
ALTER TABLE t_movies ADD COLUMN fk_genre_id INTEGER, ADD CONSTRAINT FOREIGN KEY(fk_genre_id) REFERENCE t_genres(ph_id);
Any suggestions?
Kevin Fitzhenry
30,096 PointsI keep getting this error as well. Is there a bug in the challenge? Did it eventually pass for you?
Vic Phillips
1,067 PointsNevermind.
James Barnett
39,199 PointsJames Barnett
39,199 PointsTo help us better help you we need to see the code you are using. For some tips on how to do that, check out the tips for asking questions video located in the right hand sidebar.