Reputation: 461
What can i add to these three tables to allow a "family" to have many students and a family to have many parents?
i am struggling to get my head around what i could add which would allow me to do this.
Thanks
Upvotes: 1
Views: 1256
Reputation: 129
You need to add a foreign key in student and parent that maps back to family_id, Remove parent_id and student_id in the Family table. If you need to find all member of family 22
select * from family f
join parent p on f.family_id=p.family_id
join student s on s.family_id=f.family_id
where f.family_id=22
Upvotes: 2