Preventing duplicate data in MySQL

Viewed 30

Say I have a table with columns mobile phone models and their ram/rom. The table can have two rows with same models but with different ram/rom, different models with same ram/rom but not same models with same ram/rom. Do you know about any special primary key or something to do this?

Thanks for any help.

1 Answers

You could add a unique index covering both the phone model and memory storage columns, e.g.

ALTER TABLE yourTable ADD UNIQUE u_idx (model, memory);
Related