[odb-users] Bidirectional Relationship Primary Key

Chen Weiguang CWeiguan at dso.org.sg
Thu Feb 12 21:53:51 EST 2015


Hi Boris,

I have tables 'X' and 'Y with a bidirectional many-to-many relationship with each other, i.e. 'X' has vector of shared_ptr to 'Y' and 'Y' has vector of weak_ptr to 'X', similar to the example in ODB manual section 6.2.3 Many-to-Many Relationships. Currently I am able to generate the schema for X_Y relationship table (X_id, Y_id), but with no primary key when compiling with ODB compiler.

I would like the schema to have either a composite primary key, or unique index across the two fields when compiling with ODB compiler, so as to prevent multiple addition of same relationship. Is there a way to do this? For your information, I am compiling for SQL Server 2008.

Thank you for your time and also for your previous help.

Regards,
Weiguang


More information about the odb-users mailing list