我有一组三个表(List<T> items;
IEnumerator IEnumerable.GetEnumerator()
{
return ((IList)this.items).GetEnumerator();
}
public IEnumerator<T> GetEnumerator()
{
lock (this.sync)
{
return this.items.GetEnumerator();
}
}
,runStats
和failedRuns
),如下所示(我正在使用Python中的sqalchemy模块创建数据库和表):< / p>
readsInfo
在上面的代码中,我在表#### Create the runstats table
c.execute('''CREATE TABLE IF NOT EXISTS runStats (
runStats_ID Int NOT NULL AUTO_INCREMENT,
samplesheet_name varchar(100),
run_ID varchar(100),
minimal_cluster_density varchar(100),
percentage_clusters_post_filter FLOAT,
percentage_reads_w_quality_greater_than_Q30 FLOAT,
percentage_aligned_phiX_reads FLOAT,
error_rate FLOAT,
UNIQUE (runStats_ID, samplesheet_name, run_ID, minimal_cluster_density, percentage_clusters_post_filter, percentage_reads_w_quality_greater_than_Q30, percentage_aligned_phiX_reads, error_rate),
PRIMARY KEY (runStats_ID)
)''')
#### add the column run_ID as unique index, so that it can be used as a foreign key in the table readsInfo
c.execute("""ALTER TABLE runStats ADD UNIQUE INDEX run_ID_UNIQUE (run_ID)""")
#### create the table failedRuns
c.execute("""CREATE TABLE IF NOT EXISTS failedRuns (
fail_ID Int NOT NULL AUTO_INCREMENT,
run_ID varchar(100),
reason_fail varchar(100),
PRIMARY KEY (fail_ID),
UNIQUE(fail_ID, run_ID, reason_fail)
)""")
#### add the unique index on the column run_ID, as this should also be referenced as a foreign key
c.execute("""ALTER TABLE failedRuns ADD UNIQUE INDEX run_ID_UNIQUE (run_ID)""")
#### Create the readsInfo table
c.execute("""CREATE TABLE IF NOT EXISTS readsInfo (
readsInfo_ID Int NOT NULL AUTO_INCREMENT,
run_ID varchar(100),
total_number_of_reads BIGINT,
total_number_of_reads_post_filter BIGINT,
percentage_reads_identified_post_filter FLOAT,
cv FLOAT,
min FLOAT,
max FLOAT,
UNIQUE(readsInfo_ID, total_number_of_reads, total_number_of_reads_post_filter, percentage_reads_identified_post_filter, cv, min, max, run_ID),
PRIMARY KEY (readsInfo_ID),
FOREIGN KEY (run_ID) REFERENCES runStats(run_ID)
)""")
的{{1}}字段上有一个FK,它引用表run_ID
中的字段readsInfo
。事实是,在此列中,我应该接受不仅存在于表run_ID
的{{1}}字段中而且还存在于表{{1}的runStats
字段中的值}(考虑到run_ID
的集合,它们将转到表runStats
或表run_ID
中的字段failedRuns
)。
长话短说,表run_IDs
中的字段run_ID
应该引用表runStats
中的字段failedRuns
或 {{1 }}。