Hi
I am looking to establish what the best/alternative routes would be to achieve the following, or if in fact what i am doing is what other developers also do:
I have a table of unique records which can be linked to multiple records from a second table (so a one to many relationship in effect).
For explanation sake, table 1 is called 'Schools' and table 2 is called 'pupils'.
At the moment, I store the Unique ID's (primary keys) of the 'pupil' records in a varchar field within the 'school' record with spaces separating them as such..
1 2 4 10 12 14
.. to indentify which pupils are assigned to which school.
And when I come to display the records on screen, I run a query to get the 'schools' record data and explode the varchar field into an array:
$pupil_ids = explode(" ", $varcharfield);
and then run a second query to get everything from the 'pupils' table and if the unique id's of the 'pupils' is in the array $pupil_ids, I display the record on the web page.
So, is this a familiar routine that other use, or is there alternative routes to achieve my end result?
bare in mind, from an admin point of view, this needs to be updateable and at the moment i use check boxes to check which 'pupil's are assigned to which 'school' and run an update query to update the Varchar field.
Many thanks for reading.
Doug