orange_floyd — 2012-05-19T20:38:39-04:00 — #1
I am looking for some help in the clarification of the UNIQUE key. For example, say I created a table and appended UNIQUE (email, activation, code) to the end of the CREATE statement. When inserting data, does the unique fields create a combined unique key or are they separate? In other words does an insert look for a row with all three unique fields to be the same or will it be unsuccessful if just one of the fields is a duplicate?
r937 — 2012-05-19T23:24:08-04:00 — #2
the combination of column values has to be unique
orange_floyd — 2012-05-19T23:29:56-04:00 — #3
So to accomplish individual UNIQUE, it means that I have to do SELECT queries prior to make sure the values are not there?
r937 — 2012-05-19T23:54:19-04:00 — #4
you never have to do SELECTs to ensure uniqueness
what is it you want to do?
what was the purpose of declaring a 3-column composite UNIQUE key?
orange_floyd — 2012-05-20T00:39:39-04:00 — #5
I was trying to understand how they work in concept. If I had a field for email and then a field for a salt key, I would want to make sure the email is UNIQUE and that the salt can only be in the database once as well. I guess if I created the salt with the email among other things, I shouldn't have to worry about that I suppose and can just have email as UNIQUE.
If the email is a UNIQUE field, does that mean with my coding language I shouldn't perform a select query, just try to insert the email and then check if the insert query succeeded to know if the email exists already or not?
r937 — 2012-05-20T05:59:27-04:00 — #6
mittineague — 2014-09-23T03:33:48-04:00 — #7
This topic is now archived. It is frozen and cannot be changed in any way.