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 trialSteve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsDataBase Foreign Keys
This is just a question thats on my mind relating to the Database Schema used in this video.. it shows the user_id has a relationship with both tables, the voting table and the books table.
I didn't think you could create 2 foreign keys from one ID? only reason i ask is because i am replicating this schema in a MYSQL database.
1 Answer
Steven Parker
231,269 PointsYou forgot to provide a link to the video, but just in general there's no limit.
Each foreign key is enforced independently by the database system. You can have as many foreign keys in a table as you want.
And a table can have only one primary key, but it can be referenced as a foreign key in any number of other tables.
Steve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsSteve Meadows
Full Stack JavaScript Techdegree Student 15,218 PointsThank you for your help, I was confused so this is helped greatly :)