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!
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

James Kennedy
20,755 PointsDatabase Foundations: Keys and Auto-Incrementing Values challenge
Q: Alter the "t_movies" table to add a foreign key called "fk_genre_id" and constrain it to reference the "t_genres" "pk_id".
So my answer so far is: alter table t_movies add coumn fk_genre_id integer add contraint foreign key (pk_id) reference t_genres(pk_id)
and the error its giving me is: Bummer! You're missing the 'fk_genre_id' column. I cant seem to understand where Im going wrong?
5 Answers

John W
21,558 PointsTry dropping the column keyword (it is optional) and/or the constraint keyword (optional when followed by "foreign key"). Also make sure you've spelled everything correctly. One character wrong would break everything.

John W
21,558 PointsYou need a comma to separate each add statement
"add constraint" not "add contraint"
you want to set the foreign key as fk_genre_id, not pk_id
"references" not "reference"
Think that covers it.

James Kennedy
20,755 PointsEDIT: "Add column" with an l obviously, still gives same error

James Kennedy
20,755 PointsSo Ive got: alter table t_movies add column fk_genre_id integer, add constraint foreign key (fk_genre_id) references t_genres(pk_id) But im still getting the missing the fk_genre_id error. am I missing anything else?

James Kennedy
20,755 Pointsdropped the column and constraint keyword and it was correct. Thanks for your help