Home > Database > Mysql Tutorial > mysql 主键 在别的表里面当外键 不允许重复

mysql 主键 在别的表里面当外键 不允许重复

WBOY
Release: 2016-06-06 09:32:58
Original
1856 people have browsed it

mysql外键主键

在mysql数据库里面,有三张表,如下:
student(no,name,class)no是主键,
activity(name,time,place)name是主键,
select(id,no,name)no,name是外键且分别对应表student和activity
问题:表select输入数据(1,"000‘’,“排球”);(2,"001‘’,“看书”);没问题
再输入数据(3,"000‘’,“看书”)就有问题了。请问为什么啊??
主键在自己的表里面才需要独一无二啊,为什么作为外键在别的表里面不能重复呢??

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template