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 MySQL 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.
indexing is basically of four types :
primary and unique both prevent the duplicate entry .
Primary : it can never be null. only one field may be primary. it is row based index
Unique: multiple fields may be unique, may be null. it is column based
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.