IMHO the second option sounds more viable but you may still want to know individually what each column position has for a value.
Here is a sample table
CREATE TABLE searchtable
(
attr01 TINYINT DEFAULT 0,
attr02 TINYINT DEFAULT 0,
attr03 TINYINT DEFAULT 0,
attr04 TINYINT DEFAULT 0,
attr05 TINYINT DEFAULT 0,
attr06 TINYINT DEFAULT 0,
attr07 TINYINT DEFAULT 0,
attr08 TINYINT DEFAULT 0,
attr09 TINYINT DEFAULT 0,
attr10 TINYINT DEFAULT 0,
attr11 TINYINT DEFAULT 0,
attr12 TINYINT DEFAULT 0,
attr13 TINYINT DEFAULT 0,
attr14 TINYINT DEFAULT 0,
attr15 TINYINT DEFAULT 0,
attr16 TINYINT DEFAULT 0,
attr17 TINYINT DEFAULT 0,
searchkey CHAR(17) NOT NULL,
PRIMARY KEY (searchkey)
) ENGINE=MyISAM;
You will be inserting the 17 integers like this:
INSERT INTO searchtable
(attr01,attr02,attr03,attr04,attr05,
attr06,attr07,attr08,attr09,attr10,
attr11,attr12,attr13,attr14,attr15,
attr16,attr17) VALUES
(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1);
You will need a trigger to create the searchkey for these 17 columns
DELIMITER $$
CREATE TRIGGER searchtable_ai AFTER INSERT ON searchtable FOR EACH ROW
BEGIN
SET NEW.searchkey =
CONCAT(
attr01,attr02,attr03,attr04,attr05,
attr06,attr07,attr08,attr09,attr10,
attr11,attr12,attr13,attr14,attr15,
attr16,attr17);
END; $$
DELIMITER ;
In order to see if a set of 17 columns exist you will have to concatenate them and then query the table like this:
SELECT COUNT(1) FOUNDKEY FROM searchtable WHERE searchkey = '1234123412341';
That way, you get either 0 or 1 as the answer as to whether the 17-value combination you are seeking exists. The reason all 17 columns are manifested is to allow for the individual querying of those specific columns, should you need it. If you do not need it then change the table to this:
CREATE TABLE searchtable
(
searchkey CHAR(17) NOT NULL,
PRIMARY KEY (searchkey)
) ENGINE=MyISAM;
and change the insert to this
INSERT INTO searchtable VALUES (CONCAT(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1));
and ditch the trigger.
I also recommend using MyISAM over InnoDB in this case in order to alleviate additional table overhead.
Give it a Try !!!