• Vedran Kesegic (1/26/2011)


    Like Andrew said, it's a classic many-to-many relation. In logical data model you have two entities: A and B. One A can have (contains, is associated with, etc) multiple B's, and B can have (contains, is associated with, etc) multiple A's. When converting logical data model to phisical data model, entity A becomes a table with PK, entity B becomes a table with PK, relation "many-to-many" between them also becomes a table with two foreign keys; one referencing table A and one referencing table B.

    This is a perfect example: many to many relation between Product and Order

    It really depends on what the Bs are. If all you know about each B is an identifier for the B and which As it is associated with, there's no need to model the Bs as entities in there own right, so you can do what Pablo suggested and just model the As plus a derived set of entities (AB associations). In that case you end up with two tables not three.

    Of course the same might be true of the As: in your database you know nothing about them except an identifier and which Bs they are associated with; in that case they two could be omitted from the model, and you would have only the AB relationship table.

    However, the general case for something like this is what Andrew said: you do indeed end up modelling two base entities plus a relationship between them, which leads to three tables.

    Tom