[odb-users] PKs and FKs at the same time

Boris Kolpackov boris at codesynthesis.com
Fri Mar 20 07:30:41 EDT 2015


Hi Nicholas,

Nicholas Cremonesi <nicholas.cremonesi at gmail.com> writes:

> I have to define a column (let's call it 'col_B') which is both Primary Key
> of 'Class_B' and Foreign Key referencing 'Class_A', so I tried to define it
> this way:
> 
> #pragma db id
> shared_ptr<Class_A> col_B_;
> 
> but compiling with ODB give me a lot of errors. Is this implementation
> unable to do?

No, ODB does not support using object pointers as object ids. However,
you can quite easily emulate this behavior as described in this earlier
post:

http://www.codesynthesis.com/pipermail/odb-users/2015-January/002335.html

Boris



More information about the odb-users mailing list