遗留数据库中关联表的Django模型

时间:2018-07-12 03:42:48

标签: django django-models

由于Django不支持复合主键,因此为关联(或联结)表实现模型的最佳实践是什么?

我有一张将<plugin> <groupId>org.liquibase</groupId> <artifactId>liquibase-maven-plugin</artifactId> <version>3.4.1</version> <configuration> <propertyFile>${project.build.directory}/unpack/liquibase.properties</propertyFile> <outputChangeLogFile>${project.build.directory}/liquibase-outputChangeLog.xml</outputChangeLogFile> <changeLogFile>${project.build.directory}/liquibase-outputChangeLog.xml</changeLogFile> <diffTypes>tables, views, columns, indexes, foreignkeys, primarykeys, uniqueconstraints, data</diffTypes> </configuration> <dependencies> <dependency> <groupId>org.liquibase.ext</groupId> <artifactId>liquibase-hibernate4</artifactId> <version>3.5</version> </dependency> <!-- ojdbc6.jar example --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc6</artifactId> <version>11.2.0.1</version> </dependency> <!-- ojdbc7.jar example --> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc7</artifactId> <version>12.1.0.2</version> </dependency> </dependencies> <executions> <execution> <id>generate-change-log</id> <phase>generate-resources</phase> <goals> <goal>generateChangeLog</goal> </goals> </execution> <execution> <id>sync-sql-log</id> <phase>process-resources</phase> <goals> <goal>changelogSync</goal> </goals> </execution> <execution> <id>generate-sql-log</id> <phase>generate-resources</phase> <goals> <goal>updateSQL</goal> </goals> </execution> </executions> </plugin> 映射到user_id的表,该表对形成一个复合主键。 user_type_iduser字段最初都是user_type类,但是解释器给出了使用ForeignKey的提示。我没有收到以下代码的警告。这是实现表的正确方法吗?

OneToOneField

0 个答案:

没有答案