Book a Demo

Author Topic: Many to Many relationships  (Read 5409 times)

LTG1

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Many to Many relationships
« on: June 04, 2008, 04:15:24 am »
Does anyone know what UML will generate a many-to-many relationship?

My goal is to use EA to model two classes, designate a relationship as m2m, and then be able to generate DDL where the intermediate table required at the DB level is automatically created.

I heard this was possible, but I've tried many approaches without being able to get this implicit behaviour.

Any help appreciated,
LTG

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Many to Many relationships
« Reply #1 on: June 04, 2008, 04:18:25 am »
I think you might be able to do this by modeling the classes with a many-to-many relationship, then transforming to a data model.

AFAIK the DDL generator won't create the join table on its own. You have to do this explicitly, either by hand or via a transformation from a class model.

[But I'm not absolutely sure. Anyone is very welcome to prove me wrong on this.]

David
No, you can't have it!

LTG1

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Many to Many relationships
« Reply #2 on: June 04, 2008, 04:29:56 am »
Yes definitely I expect to have to do a transformation - the key is what is the proper way to model m2m so that transforming to DDL then generating DDL will produce the join table?

I'm pretty sure there is a way because someone was saying that's one of the features they enjoy about EA.

Regards,
LTG
« Last Edit: June 04, 2008, 04:30:34 am by LTG1 »

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Many to Many relationships
« Reply #3 on: June 04, 2008, 07:17:02 am »
I think you just need to define a relationship - with roles; use the relationship properties dialog - between the two classes.

You might want to use an association class if there are additional properties of the relation (in the database) beyond the foreign keys (that make up the compound key used in the join).

Try it and see.

[Sorry to be so vague about this, but I've not done this directly through EA for quite a while, and I know there have been some changes.]
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Many to Many relationships
« Reply #4 on: June 04, 2008, 08:05:33 am »
Set the multiplicity of both ends of the association linking two classes.  (eg. 0..* or 1..*)

LTG1

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Many to Many relationships
« Reply #5 on: June 04, 2008, 09:01:24 am »
Thanks Simon thats exactly what I was looking for.

I did try lots of things, but EA has no shortage of options :).