Discussions

EJB design: Question on M:N ejbs relation. Are they really needed?

  1. Hi,
    a beginner question!
    In relation databases i cannot make direct M:N association, so i need to use associative tables, wich divides this relation in two 1:N relations.
    My point is...
    If i'm in a arquicteture that has the persistence layer build with one-to-one EJBs on the database, do i ever need to use M:N EJBs associations in my app?
    Is the point clear...? I mean to say that if we already have the associative DB tables, why not mapp an associative EJBs, as this way, we would not need M:N EJBs relations.

    Thanks,
    ltcmelo
  2. Theoretically, you can model your M:N relations as a pair of 1:M relations with an Entity bean representing your join table.

    In practice, the join table often has no meaningful information by itself, and the server can optimize the M:N relation in ways that it would not be able to do with the pair of 1:M relations.