I have a database of users where I have a primary table with name, address etc. I then have separate tables for the users children, pets, training courses and education results etc.
This users details can all be displayed on the same page and the way I currently do it is by first querying the database for the users main details. Then I query the other tables individually and display this information with loops.
I really just need to know if this is the best way to do it or whether there is a way of doing it with a single query and if there is any advantage?
The basic structure of the tables is:
+----------------+ +-----------------------+
| Users | | Children |
+----------------+ +-----------------------+
|ID |Name |Age | |ID |UserRef |Name |Age |
+----------------+ +-----------------------+
|1 |Jim |53 | |1 |1 |Joe |11 |
|2 |Karl |37 | |2 |1 |Jane |9 |
+----------------+ |3 |2 |Amy |15 |
+-----------------------+
This is a basic version and only shows the user and children table. The other tables are similar to the children table in that they reference the user table and feature multiple records for a single user.
Thanks in advance.