How to know when a value is unique in a row?
Sometimes we will be able to plan and create our databases, that will allow us to think about which values (besides an id) will most likely be unique to the item in each row, but most often we will be working with already existing databases and tables, yet there is no reason to fret, we will not be alone and there is most likely a visual schema somewhere where we can see what are the columns that the table has and what kind of values it contains for example:
- id int not null unique,
- name string,
- email string not null unique,
- age int
in this case, we have an id, but we can deduce that email will also be a unique value.
As we keep on practicing SQL being on its own or using SQLite this details will become clearer, and in general even in a work environment , we will be told how the table looks like so we can have an idea of what we are working with.