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

Steve Meadows
seal-mask
.a{fill-rule:evenodd;}techdegree
Steve Meadows
Full Stack JavaScript Techdegree Student 15,218 Points

DataBase 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
Steven Parker
231,248 Points

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