我有一个配置为使用SQLite的Django Web服务器。
在多对多关系中(带有额外字段),Django强制我使用关系模型来建立两个对象之间的关系。但是,我可以创建两个对象之间的关系,这些对象尚不存在于相关表中。
例如:
I have table1 and table2 which are related via table12.
In table1, there is just one object called A.
In table2, there is just one object called X.
I can create a record in table12 that depict a relationship between A & Y; even though Y doesn't exist in table2.
我的关系模型已经适当地标记了外键。
1
,稍微更好的写法是PRAGMA foreign_keys=ON
。 - Ron Kalian