Connect with us


which keys are used in mysql


which keys are used in mysql








which keys are used in mysql 

what is difference between all major key in msql
normally used keys in msql are four
index key
secondary key
primary key
unique key
forigen key
index key is used for fast seraching and
processing in table and database . index is used for a easy loop up in specified column and it makes search faster.
InnoDB uses a tree type strcutre for indexing whereas MYISAM uses linear way for indexing datait works
like as we find index in the end of book
where we can find different indexes and we can
find easily every topic of our choice and can go
where ever we wanna to go with related page mentioned on the book.
it is really helpful and beneficial for query processes.
there can be many indexes in a table as well as in a database.

primary key
it is unique key and can never be null.
it has one value always and can not be assigned or inserted anywhere else in database.
primary key is only one where there is no match against that .and second it will not be null.
primary key uses clustered indexing wherein it sorts in ascending order on the primary key.
this would automatically faster search results.

it is also used for processing purposes.
the difference between index key and primary key is that
it is only one key in a database. it has one value and if it has found anywhere the same value ;
it would prompt your primary key data structure error.
but index key , there can be many index keys in a table .
unique key means that the value in the same row cannot be same.
as per when we do not want that same email address can be made again by another
user we use unique key.

secondary key
it is alias type key we use it for another purpose of index or foreign key.

foreign key
we use foreign key when we want to relation one table strucure or entity of
table with another table ; FOREIGN KEY enforces Referential Integrity, that means that we cannot
create an entry in a column which has a foreign key to another table if the entered value does not exist in the
referenced table.In msql, a FOREIGN KEY does not improve search performance. It also requires that both tables
in the key definition use the InnoDB engine, and have the same data type, character set, and collation.foreign
key actually has its own value and it performs well every there would come constraint , the value updated in one table must be updated
respectively in another table.
what is unique index ; there can be many unique keys in same table but there can be only
one primary key a table.but the problem is that if we have two unique keys in same table
in msql , it would trigger an error .this would little bit slow down the performance of search etc.
title: what are keys and what are their roles
what is difference between index key , foreign key,primary key and unique key

Continue Reading
You may also like...

More in mysql


To Top