1

I am working with MYSQL WORKBENCH. After forward engineer I got all my tables in phpadmin.

enter image description here

But the reverse enginner transforms 1:1 to 1:n .

enter image description here

How can I fix this?

shapiro yaacov
  • 2,308
  • 2
  • 26
  • 39
stephane
  • 11
  • 2

2 Answers2

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).

If you like you can create a bug report (http://bugs.mysql.com) to have this improved.

Mike Lischke
  • 48,925
  • 16
  • 119
  • 181
0

Yes,I faced this problem when using django to model 1:1 relationship like this:

class Server(models.Model):
    ...
    asset = models.OneToOneField('Asset', on_delete=models.CASCADE, null=True, blank=True)

after python makemigrations & python migrate, I run mysql workbench(6.3 on ubuntu16.04) reverse engineer,than something show as follow: 1_to_1_bug.png

Evoup Yin
  • 1
  • 1
  • 1
  • 2