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!
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
Daniel Malek20,140 Points
I try to understand FOREIGN KEY's. So I created database with 2 tables r_customers and r_cars. With Ttreehouse support I know how to use FOREIGN KEY when 1 customer owns 1 car how I can deal with situation when 1 customer owns 2 cars or 1 car has 2 owners?
Jeff Lemay14,268 Points
What you're talking about is a one-to-many relationship but what I think you really want is a many-to-many relationship (where an owner can have multiple cars and the cars can be belong to multiple owners). Check out this link for a pretty good explanation: http://code.tutsplus.com/articles/sql-for-beginners-part-3-database-relationships--net-8561 .