MySQL InnoDB 双倍 ID
http://img839.imageshack.us/img839/8241/stackoverflow.png
我创建了一个新的数据库。有 2 个表 class
和 teacher
。 class
表中有一个与 teacher
的 teacher_id
相关的字段 class_leader
。 [1]
在 PHPMyAdmin 中,关系如下所示: [2]
表 teacher
包含一些记录。 [3]
当我在表 class
中添加新记录时: [4]
为什么 class_leader
中的 ID 会加倍? [5]
这意味着什么?我应该怎么办?
感谢您的帮助。
http://img839.imageshack.us/img839/8241/stackoverflow.png
I created a new databese. There are 2 tables class
and teacher
. There is a field class_leader
in the table class
related with teacher_id
from teacher
. [1]
In PHPMyAdmin relationship looks like: [2]
Table teacher
contains some records. [3]
When I add new records at table class
: [4]
Why IDs in class_leader
are doubled? [5]
What does it means? What should i do?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为班级和老师之间是多对一的关系。 class_leader 列中有重复的 id 是正常的。
抱歉,我没有看到截图。如果您没有唯一的 class_leader 字段,那么有重复的 id 是正常的。让它成为具有唯一值的列,就可以了。
Because the relationship between class and teacher is many-to-one. It's normal to have duplicate ids in the class_leader column.
Sorry, I did not see the screenshot. If you don't have the class_leader field as unique, it's normal to have duplicate ids. Make it a column with unique values and you'll be fine.