一直没有很好的理解外键. 下面的参考链接写的很好. 简单来说, 子表引用主表的主键, 这样, 子表只能插入主表已经存在的主键值. 可以在数据的一致性做的比较好.
https://www.cnblogs.com/chenhaoyu/p/5890195.html