note
The_Dj
I second SQlite. I use it a lot, and if your dataset is big(ish), you don't want to be parsing flat files for every lookup.<br/>
<br/>
How you store this depends on just how many <code>[ key1=value1, key2=value2]</code> there are.<br/>
If there is a fixed list of '<code>key1</code>','<code>key2</code>' and it's not too many: bite the bullet and add the columns.<br/>
<br/>
Otherwise, you get to use a link (This is Database 101. search for 'database normalization')<br/>
<br/>
each record should be <br/>
<code>[id], field1, field2</code><br/>
<br/>
then in a separate table<br/>
<code>[link_id], key1, value1
[link_id], key2, value2
</code><br/>
You can also have a 3rd table with<br/>
<code>[link_id], source_file_name</code><br/>
or whatever other metadata you need to keep. <br/>
<br/>
SQLite very kindly has a magic <code>ROWID</code> column. It wont' return it on <code>SELECT *</code>, but will on <code>SELECT ROWID,*</code>.<br/>
Of course you get to do two queries for each lookup: <code>SELECT ROWID,* FROM main_data</code> and then <code>SELECT * FROM extra_data WHERE link_id = ?</code><br/>
<br/>
HTH.<br/>
<br/>
TO clarify: if your 'real' data is <br/>
<code>name=bob, age=75, [ hair=balding, glasses=bifocal]
name=john, age=20, [ sport=chess ]</code><br/>
<br/>
Then you get:<br/>
Primary table:<br/>
<code>1, bob, 45
2, john, 20</code><br/>
<br/>
lookup table:<br/>
<code>1,hair,balding
1,glasses,bifocal
2,sport,chess</code><br/>
11108346
11108351