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

Databases

Challenge Task 3 of 3 - FOREIGN KEY Now recreate the MEMBERS table with the new FAVORITE_ROCK_ID

I can't figure this one out. I have tried everything I can think of:

  • Starting with PRAGMA FOREIGN_KEYS = ON; (at the Top like the video)
  • DROP TABLE MEMBERS;

I used Workspaces throughout the videos so I referenced every possible example from the videos and I can't make this one pass.

Best vote gets points =)

Cheers!

2 Answers

Stuart Wright
Stuart Wright
41,120 Points

I couldn't work out what challenge this related to, so started Googling to try to find it, but instead of finding the challenge, I seem to have stumbled across a correct answer, so I'll just post the link here rather than try to reinvent the wheel :)

https://teamtreehouse.com/community/challenge-3-of-3-foreign-key-constraint

This works:

CREATE TABLE MEMBERS (
  ID PRIMARY KEY, 
  FIRST_NAME, 
  LAST_NAME, 
  FAVORITE_ROCK_ID REFERENCES ROCKS(ID));