Hi Tim, I think I see now. Basically your external database structure is not what moodle is looking for ... and the second one you propose is.
The ID number of a course is only used when matching this course against external systems - it is never displayed within Moodle. If you have an official code name for this course then use it here ... otherwise you can leave it blank.
I don't think it is necessary to use the same course idnumber as in the external database is it?
Yes, this has to be the number of the course in the external database. In my example, when you're in moodle editing course 5, you would put 50 in here.
the external database should be of the form (you really only need 2 fields)
User , Course
then you have a separate entry for each course. This way it can scale to a large number of courses. e.g.
This approach, rather than adding an extra field for each new course, is a relational database approach to things. Very scalable.
So, you could use the structure you proposed (I dropped the 1 off Courseidnumber):
Record1: User1 Useridnumber Courseidnumber
this won't confuse moodle as in enrol_remoteuserfield you'll have "Useridnumber" and in enrol_remotecoursefield you'll have "Courseidnumber" and it won't look at the other fields.
Just FYI, the cleaner design from a relational database point of view ... is to just have the 2 fields and keep User or Course info out of this table. You then have 3 tables
1. user: holds all the user details ... name, address, DOB, useridnumber ...
2. usertocourse: that's the table we're talking about here (it's called a bridge table - and has two fields :useridnumber, courseidnumber)
3. course: holds course details: courseidnumber, description, level ....
The advantage of this approach is that you don't duplicate data (I'm guessing you have a lot of user and course info in there). Though, if you just want to have one table then forget the above. James