Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

mysql中 建立一个用户表,一个订单表。将用户表中的uid,uname设为主键,订单表中的uid,uname怎么同时和主表关联

mysql外键


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

一般情况下只需要uid作为主标关联的主键,uname不建议使用,也不建议作为联合索引,uid是唯一的,uname就用不到,还会增加插入,更新,删除操作难度!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...