CMR - M:N relationship

Discussions

EJB programming & troubleshooting: CMR - M:N relationship

  1. CMR - M:N relationship (1 messages)

    Supposing I have to model a relationship between two entity beans, say, Student and Course (the mastering ejb2 example). A Student can enroll in multiple courses, and a Course has many students who enrol for it. At the database level, I have a third table which models the relationship between the two, an Enrollment table.

    The tables look like :
    Student
    -------
    StudentPK
    StudentName

    Course
    ------
    CoursePK
    CourseName

    Enrollment
    ----------
    EnrollmentPK
    StudentPK
    CoursePK

    What i'm not sure of is: How does one model this using bean relationships? Should there be a direct relationship between Student and Course ? Or should there be an Enrollment bean as well to model two 1:N relationships ?



     
  2. CMR - M:N relationship[ Go to top ]

    Hi,

    Read through the forum archives - this question has been asked & answered several times.

    Daniel.