When to use auto_increment? I wonder when to use auto_increment. It is said that it can be used for a unique identifier. But why the unique identifier is needed?

Suppose the data of a student has entered in a student table. If I  enter that student data again, it will be ok since it create another id automatically. But I have storing the same data unnecessarily.

What is the meaning of using that?

If I can identify a primary key, I do not need to use that?
For example, For a Hotel table, I can use the combination of Hotel name and address as a primary key. Then, we can avoid storing the same data several times.

Is it better to use to generate a key with auto_increment?
The advantage of using an auto increment field is that new records are automatically given an unique primary key.


  Suppose the data of a student has entered in a student table. If I enter that student data again, it will be ok since it create another id automatically. But I have storing the same data unnecessarily.


It's your duty to take care that the same data is not entered again i.e. verify that the student exists and, if yes, edit his record instead of creating a new one.


  If I can identify a primary key, I do not need to use that? 


Yes, if you can identify a natural primary key (e.g. the student ID in an University, the ISBN for a book, the S/N for a piece of hardware) it is much better to use that one.


  For example, For a Hotel table, I can use the combination of Hotel name and address as a primary key.


It is a bad idea to use primary keys which contain meaningful data. What happens if the hotel changes its name? In this example, it is better to use a surrogate primary key.