Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Charles 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.