我使用sqlite3并且我有以下表格,我想知道是否有可能实现下面描述的结果作为想要的行为。我不确定这会有多大用处,但似乎将来可能会有用。
我有以下表格:
topics:
topic_id int primary key,
topic_name str,
topic_author str,
posts:
tid int,
pid integer primary key autoincrement,
post_author str,
post str,
FOREIGN KEY(tid) REFERENCES topics(topic_id)
当我插入表格帖子时:
15, null, "Author1", "Post1"
15, null, "Author1", "Post2"
16, null, "Author1", "Post1"
16, null, "Author1", "Post1"
我明白了:
15, 1, "Author1", "Post1"
15, 2, "Author1", "Post2"
16, 3, "Author1", "Post1"
16, 4, "Author1", "Post1"
而不是我想要的:
15, 1, "Author1", "Post1"
15, 2, "Author1", "Post2"
16, 1, "Author1", "Post1"
16, 2, "Author1", "Post1"
这可能吗?