質問編集履歴
1
子テーブルに試したエラーも追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
```
|
13
|
+
```sql
|
14
14
|
|
15
15
|
ALTER TABLE all_now.bit_fingerprints ADD FOREIGN KEY (compound_id) REFERENCES all_now.compounds (compound_id);
|
16
16
|
|
@@ -30,11 +30,23 @@
|
|
30
30
|
|
31
31
|
###試したこと
|
32
32
|
|
33
|
-
[StackOverFlowの記事](https://stackoverflow.com/questions/9597081/postgresql-partitioning-and-fk)を参考にしたところ親テーブルを外部キーとしたらよさそうに思えたのですが、今回の件ではまた別なのでしょうか?
|
33
|
+
[StackOverFlowの記事](https://stackoverflow.com/questions/9597081/postgresql-partitioning-and-fk)を参考にしたところ親テーブルを外部キーとしたらよさそうに思えたのですが、今回の件ではまた別なのでしょうか?(出力結果は上の画像やコードになります)
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
-
子テーブルを外部キーとすることも試していますがその場合はcompounds_200000に含まれないcompound_idのレコードに対してエラーが出てしまいます。
|
37
|
+
子テーブルを外部キーとすることも試していますがその場合はcompounds_200000に含まれないcompound_idのレコードに対して以下のエラーが出てしまいます。
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```sql
|
42
|
+
|
43
|
+
ALTER TABLE all_now.bit_fingerprints ADD FOREIGN KEY (compound_id) REFERENCES all_now.compounds_200000 (compound_id);
|
44
|
+
|
45
|
+
ERROR: insert or update on table "bit_fingerprints" violates foreign key constraint "bit_fingerprints_compound_id_fkey"
|
46
|
+
|
47
|
+
DETAIL: Key (compound_id)=(200013) is not present in table "compounds_200000".
|
48
|
+
|
49
|
+
```
|
38
50
|
|
39
51
|
|
40
52
|
|