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 trial

PHP

mo aly
mo aly
7,003 Points

stuck in stage 6 intro to databases challenge 3 task 3

my answer was ALTER TABLE t_movies ADD COLUMN fk_genre_id INTEGER NULL, CONSTRAINT FOREIGN KEY fk_genre_id REFERENCES t_genres(pk_id);

Can you link the challenge and/or question?

mo aly
mo aly
7,003 Points

https://teamtreehouse.com/library/programming/database-foundations/joining-relational-data-between-tables-in-sql/keys-and-autoincrementing-values-2

Alter the "t_movies" table to add a foreign key called "fk_genre_id" and constrain it to reference the "t_genres" "pk_id".

2 Answers

The problem is the syntax also you have to use "ADD CONSTRAINT" try to have a look at the syntax.

mo aly
mo aly
7,003 Points

https://teamtreehouse.com/library/programming/database-foundations/joining-relational-data-between-tables-in-sql/keys-and-autoincrementing-values-2

Alter the "t_movies" table to add a foreign key called "fk_genre_id" and constrain it to reference the "t_genres" "pk_id".