[Qt-interest] QSqlRelationalTableModel "left join"

Linos info at linos.es
Tue Feb 3 20:11:39 CET 2009


Robert Hairgrove escribió:
> Linos wrote:
>> Hello all,
>>     do i have any way to create a relation without make it mandatory? i 
>> have any fields on database that can be null but if they are not null 
>> they have to be a valid value from other table. Thanks.
>>
>> Regards,
>> Miguel Angel.
> 
> What you need is a default value for the related (foreign) table which 
> corresponds to an existing row in the other (master) table. For example, 
> if I have a table "Occupation" which has different kinds of jobs (e.g. 
> baker, truck driver, banker, ...) and it had a primary key column of 
> integer type, there could be one row with PK = 0 and text "(unknown)". 
> In the related table, the correlated column's default value would be 0 
> and never NULL.
> 
> If the PK for the master table is automatically generated, e.g. 
> autoincrement starting with 1, you can still insert the row with 0 
> manually (i.e., SQL "INSERT INTO...").

I thought using this as a solution but was interested in knowing if there was 
another way, i prefer my users not have to see unmeaning values, thanks anyway 
Robert.



More information about the Qt-interest-old mailing list