问题描述
我正在使用 MYSQL WORKBENCH.在前向工程师之后,我在 phpadmin 中获得了所有表格.
I am working with MYSQL WORKBENCH. After forward engineer I got all my tables in phpadmin.
但是逆向工程师将 1:1 转换为 1:n .
But the reverse enginner transforms 1:1 to 1:n .
我该如何解决这个问题?
How can I fix this?
推荐答案
我相信这是 MySQL Workbench 中正向和反向工程过程的一个限制.关系的基数应确定用于生成的外键的索引类型.因此,基数为 1 需要唯一索引(或主键,根据定义是唯一的).非唯一索引允许 1..n 基数.但是,您不能使用外键对 0..1 基数进行建模,因为外键总是需要至少一个条目(毕竟这是它们的全部目的).
I believe it's a limitation of the forward and reverse engineering processes in MySQL Workbench. The cardinality of the relationship should determine the type of index used for the generated foreign key. Hence a unique index (or a primary key, which is per definition unique) are needed for a cardinality of 1. A non-unique index allows the 1..n cardinality. You cannot model the 0..1 cardinality with foreign keys, however, as foreign keys always require at least one entry (that's their entire purpose, after all).
如果你愿意,你可以创建一个错误报告(http://bugs.mysql.com)这有所改善.
If you like you can create a bug report (http://bugs.mysql.com) to have this improved.
这篇关于逆向工程师 MySQL Workbench 将 1:1 关系更改为 1:n 后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!