mysql database navicat

How to link two tables in the same database. Three linkage achieve
a new table has three fields id (increment), code (primary key), name
Here Insert Picture Description
Here Insert Picture Description
save being given as: increment fields in a table primary key must be provided. That how to solve it? The unique id set to the only all.
Here Insert Picture Description
Increase in the index indexs, four used in the index are explained below
Here Insert Picture Description

PRIMARY:主键索引。索引列唯一且不能为空;一张表只能有一个主键索引(主键索引通常在建表的时候就指定)
normal:表示普通索引
unique:表示唯一的,可以为空,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为unique。
full text: 表示 全文搜索的索引。 FULLTEXT 用于搜索很长一篇文章的时候,效果最好。用在比较短的文本,如果就一两行字的,普通的 INDEX 也可以。

interested in the difference between hash and btree index can look at the following links:
https://blog.csdn.net/u014307117/article/details/47325091
the same way to build another table province.

  1. CASCADE: 从父表中删除或更新对应的行,同时自动的删除或更新自表中匹配的行。ON DELETE CANSCADE和ON UPDATE CANSCADE都被InnoDB所支持。
  2. SET NULL: 从父表中删除或更新对应的行,同时将子表中的外键列设为空。注意,这些在外键列没有被设为NOT NULL时才有效。ON DELETE SET NULL和ON UPDATE SET SET NULL都被InnoDB所支持。
  3. NO ACTION: InnoDB拒绝删除或者更新父表。
  4. RESTRICT: 拒绝删除或者更新父表。指定RESTRICT(或者NO ACTION)和忽略ON DELETE或者ON UPDATE选项的效果是一样的。

Guess you like

Origin blog.csdn.net/qq_39008205/article/details/92378815