我有一张桌子Thingsies
,列id
,data1
,otherTableId
,otherTableRowId
。我需要最后两列而不是外键列,因为根据Thingy
我想要的信息类型有所不同。
otherTableId
在表id
中引用了OtherTables
,id
本身有名为tableName
和tableNames
的列。这些OtherTable1
是其他表的名称,如OtherTable2
,otherTableRowId
。
Thingies
中的id
列引用OtherTable
给出的otherTableId
中的OtherTables
。 OtherTables
本身有更多的数据。 Thingies和其中一个OtherTables
的参赛作品之间有一对一的对应关系。所以Thingies中的行数是所有QTableView
中的总行数。 (这是不好的设计吗?)
我想在id
中显示Thingies,其中包含data1
,data2
和data2
的列,其中otherTableId
是从otherTableRowId
和QSqlQueryModel
以编程方式生成的。我该怎么办?
谢谢。
我想我已经解决了这个问题。我正在使用OtherTable
,其查询是一组select语句的联合,每个OtherTable
一个。每个select语句必须以某种方式使用特殊表达式以某种方式合并(例如,连接)每个OtherTables
的唯一数据,因此至少对于qazxswpoi表没有任何用处。