[PHP] Re: Clarity needed

2009-02-04 Thread Shawn McKenzie
tedd wrote:
 Hi gang:
 
 I need some fog removed.
 
 I have a problem where I have an unlimited number of tutors teaching an
 unlimited number of courses. When I call upon a tutor, I want to see all
 the courses they teach.
 
 In my old days, I would just set up a linked list of courses and attach
 it to the tutor (another linked list). As a tutor adds courses, I would
 just add the course to the end of the linked list. If the tutor deletes
 a course, then I would remove it from the list by changing a single
 pointer. If I needed a list of all the courses the tutor taught, I would
 just run down the linked list pulling them out as needed.
 
 But now I have to think in terms of records in a database. I'll
 eventually figure it out, but what are your suggestions/solutions?
 
 I understand that I can have one record set up for each tutor, and
 another record set up for each course, and then tie the two together by
 another record like an assignment. That way I can have as many
 assignments as I want tying courses to tutors.
 
 It that the way you guys would do it?
 
 Thanks,
 
 tedd

As others have said, that's how I always do it.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Clarity needed

2009-02-04 Thread Nathan Rixham

tedd wrote:

Hi gang:

I need some fog removed.

I have a problem where I have an unlimited number of tutors teaching an 
unlimited number of courses. When I call upon a tutor, I want to see all 
the courses they teach.


In my old days, I would just set up a linked list of courses and attach 
it to the tutor (another linked list). As a tutor adds courses, I would 
just add the course to the end of the linked list. If the tutor deletes 
a course, then I would remove it from the list by changing a single 
pointer. If I needed a list of all the courses the tutor taught, I would 
just run down the linked list pulling them out as needed.


But now I have to think in terms of records in a database. I'll 
eventually figure it out, but what are your suggestions/solutions?


I understand that I can have one record set up for each tutor, and 
another record set up for each course, and then tie the two together by 
another record like an assignment. That way I can have as many 
assignments as I want tying courses to tutors.


It that the way you guys would do it?

Thanks,

tedd


not even read the other responses but yep, just normalise it like you 
said two tables + a link table
tutorId,courseId and a unique index over those two columns to make sure 
you don't get duplicates :)


regards!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php