Qt:从具有指向多个其他表的外键列的表中查看数据

问题描述 投票:0回答:1

我有一张桌子Thingsies,列iddata1otherTableIdotherTableRowId。我需要最后两列而不是外键列,因为根据Thingy我想要的信息类型有所不同。 otherTableId在表id中引用了OtherTablesid本身有名为tableNametableNames的列。这些OtherTable1是其他表的名称,如OtherTable2otherTableRowIdThingies中的id列引用OtherTable给出的otherTableId中的OtherTablesOtherTables本身有更多的数据。 Thingies和其中一个OtherTables的参赛作品之间有一对一的对应关系。所以Thingies中的行数是所有QTableView中的总行数。 (这是不好的设计吗?)

我想在id中显示Thingies,其中包含data1data2data2的列,其中otherTableId是从otherTableRowIdQSqlQueryModel以编程方式生成的。我该怎么办?

谢谢。

database qt relational-database qtableview model-view
1个回答
0
投票

我想我已经解决了这个问题。我正在使用OtherTable,其查询是一组select语句的联合,每个OtherTable一个。每个select语句必须以某种方式使用特殊表达式以某种方式合并(例如,连接)每个OtherTables的唯一数据,因此至少对于qazxswpoi表没有任何用处。

© www.soinside.com 2019 - 2024. All rights reserved.