What's the difference between using INDEX vs KEY in MySQL?

后端 未结 5 1428
迷失自我
迷失自我 2020-11-28 01:54

I know how to use INDEX as in the following code. And I know how to use foreign key and primary key.

CREATE TABLE tasks ( 
  task_id INT UN         


        
5条回答
  •  庸人自扰
    2020-11-28 02:15

    Keys are special fields that play very specific roles within a table, and the type of key determines its purpose within the table.

    An index is a structure that RDBMS(database management system) provides to improve data processing. An index has nothing to do with a logical database structure.

    SO...

    Keys are logical structures you use to identify records within a table and indexes are physical structures you use to optimize data processing.

    Source: Database Design for Mere Mortals

    Author: Michael Hernandez

提交回复
热议问题