MySQL Constraints
Constraints are the utilities that restrict entry of data into the table if the specified condition is not fulfilled.
They are primarily of the following type --
Primary key, foreign key, check, unique, not null
Primary Key : Primary key prevents duplicate entry.
It is called row based constraints(it means inside a table there is only one field can be declared primary )
No null Value can be entered .
Unique Key : It will not let enter a duplicate value in the field.
But a Null Value can be entered.
It is called column based constraint.
Foreign Key : A column is called foreign key when it refers to the primary key column of another table.
Not null : It will not allow entering null Value in the field.
But duplicate value can be entered.
MySQL Index
indexing is basically of four types :
=>
Primary
=>
Unique
=>
Index
=>
full-text
Primary Key
- Primary Key prevent the duplicate entry.
- Only one field can be defined Primary
- it is row based Constraint
Unique Key
- Unique Key also prevent the duplicate entry.
- More than one field can be defined unique
- it is column based Constraint
Index and full-texx
Index and full-text both are used for filtration. when you need to search , if you have to write the full name of field i.e.
indexing. on the other hand if the searching is based on the basis of characters it is
full-text.