Re: D2R's many-to-many definition

On 26 Apr 2011, at 14:57, Eric Prud'hommeaux wrote:
> Persuant to the many-to-many (Q's for Richard and others):
>  What is the exact definition of a many-to-many table?

A table T is a “link table” iff

* T has exactly two FKs defined
* T's primary key (if any) is not referenced by any FKs
* none of the T's two FKs reference T itself (seems redundant with the previous point, but that's what it says in the code)
* each column of T occurs in an FK

>  Does D2R include many-to-many behavior in it's default behavior?

Yes, in the mapping generator script. Any tables that detect as link tables will be mapped to a property connecting the two tables referenced by the two FKs, while non-link tables are mapped to classes.

>  Does the many-to-many representation preclude the representation
>  as a first class relation?

The mapping generator will not generate a mapping file that maps link tables to classes. However, users are free to modify the mapping file after it has been generated, and can change the mapping of the link table into anything they like, including a representation where you have a class for the link table, and a resource for each row.

Best,
Richard

Received on Tuesday, 26 April 2011 21:10:22 UTC