I've got a database where I have to avoid placing replicates. The needs are:
For that subset of rows with matching column 1, there cannot be any that have a similar column 2.
For that subset of rows with matching column 1, there cannot be any that have a similar column 3 and 4.
I am a new comer to SQL so it is possible to method of setting these associations after i produce the database (create table) or must i perform a choose and do these inspections by hand before placing in to the table?
Essentially, you'll need the column 1 and a pair of to become unique, as well as posts 1,3 and 4 to become unique. Then when you produce the table, you should use two UNIQUE constaints:
CREATE TABLE tbl ( col1 varchar(255), col2 varchar(255), col3 varchar(255), col4 varchar(255), CONSTRAINT uc_first UNIQUE(col1, col2), CONSTRAINT uc_second UNIQUE(col1, col3, col4) )
Just to obtain the ball moving ...
Would you return immediately after the place and remove copied rows in line with the contraints you pointed out?