This is a migrated thread and some comments may be shown as answers.

m:n

3 Answers 62 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 06 Jul 2010, 07:23 AM
I have a "DClass" class representing a class taught at a school. I also have a "Student" class. A DClass can have many Students and a Student may attend many classes. To this end I added IList<> properties to each of the classes representing the list of the 'opposite' type. I also created a "Registration" class to join the 2. So far no problems. I need to record some data against each DClass/Student pairing, a fee paid, for example. So, I added my "FeePaid" property to my "Registration" class. Again, no problem.

My problems start when I actually try to get OA to accept my table as the link table. Nothing I try seems to allow me to convince OA to use my table. I briefly thought I should let OA create the table and then alter it but the link table doesn't get added to the object model.

I guess that this means that either OA is broken or I'm doing it wrong; My money's on the latter.

Is it possible to get OA to use a user-defined class to link 2 others as described above?

Or should I be doing it differently?

Thanks in anticipation,

-- 
Stuart

3 Answers, 1 is accepted

Sort by
0
Accepted
IT-Als
Top achievements
Rank 1
answered on 07 Jul 2010, 08:15 AM
Hi Stuart,

I am not sure if I fully understand your class model, but if you try to turn it 180 degrees around: What "connects" a Student and a Class - the Registration.

So you can lay out your classes like:

class Student
{
 // 1:m inverse field mapped to student field on class Registration
 - IList<Registration> registrations
}

class Registration
{
 - Student student
 - Class class
 - double fee
}


class Class
{
 // 1:m inverse field mapped to class field on class Registration
 - IList<Registration> registrations
}

So it is the Registration that connects a student to a list of classes and vice versa
Note, that you do not have a m:n relationship between the Student and Class class, instead you have a 1:m to the Registration class from the other two (in the IList<Registration> registrations field).
Doing so will make the Registration class the "join table class" and it will allow you to store additional information in this "join table class"..

Regards

Henrik


0
Stuart Hemming
Top achievements
Rank 2
answered on 07 Jul 2010, 10:31 AM
Henrik,

Thanks.

Thanks for helping me make a difficult decision. I've decided to give up programming and do something I'm clearly better qualified for, like selling ice-cream or helping kiddies across the road.

Yea gods but I'm dim. I was concentrating that had on trying to shoe-horn my additional properties in to the m:n link table that OA created and then... Never mind

If I'd done this with a pen and paper, or even by first creating the DB tables I'd've seen the answer straight-away, but I thought that I'd try and do everything using forward-mapping (to see if I could) and got lost in the trees.

Thanks again matey.

-- 
Stuart (now, where did I put that application form for Ben and Jerry's ...?)
0
IT-Als
Top achievements
Rank 1
answered on 07 Jul 2010, 10:59 AM
Hi Stuart,

I must admit I am setting here with a BIG smile on my lips as for your comments on Ben & Jerry's (nice tasting ice by the way) :-)

Glad I could help, maybe you can go to their website to get a form?  :-)

Regards

Henrik
Tags
Design Time (Visual Designer & Tools)
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
IT-Als
Top achievements
Rank 1
Stuart Hemming
Top achievements
Rank 2
Share this question
or