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.

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