Page 1 of 1

QxOrm might have relations?

PostPosted: Tue Apr 09, 2013 9:13 pm
by fuzz
Is it possible to layout a might-have relationship with QxOrm? I'm reading the tutorial and I don't think this case is covered.

Example? A person might have a rank:

Code: Select all
Table person
id | name | rank_id
1  | Me   | NULL
2  | You  | 100

Table rank
id  | name
100 | Hacker


So person "Me" got no rank and person "You" is hacker. Can I cover this case with QxOrm? Or it this the many-to-one case?

Re: QxOrm might have relations?

PostPosted: Wed Apr 10, 2013 7:22 am
by qxorm
Hi,

So person "Me" got no rank and person "You" is hacker.
Can I cover this case with QxOrm? Or it this the many-to-one case?

Yes this is a many-to-one relationship, and if you define a pointer to a hacker, just put a NULL pointer before inserting it in the database (or use boost::optional, but here a pointer seems a better idea).