[eluser]garymardell[/eluser]
I'm not going to write any code currently but give you a idea of how i would do it.
Have a table called student, a table called address and a table called student_address. This is because one student may require many addresses and one address may belong to many students. The student_address table allows this.
The idea is to include where the primary key and foreign keys will be.
Student table
id | primary key
name|
...
Address table
id | primary key
name|
...
student_address table
student_id | composite key
address_id | composite key
Together act as a primary key.
Now to get all the students, you will want to select everything from the students table and from the address table.
Then join the student_address table where student.id = student_address.student_id
And then now join address table where student_address.address_id = address.id
This will return the addresses related to each student, this setup would potentially allow more than 2 addresses for a student (some complicated arrangement maybe.) or just a single address.