Search notes:

/var/lib/rpm

/var/lib/rpm stores the RPM database (in either SQLite or Berkley DB format)?
A corrupted database can be rebuilt with
rpm --rebuilddb

(SQLite) Schema

The rpm database schema has a «master» table:
CREATE TABLE IF NOT EXISTS 'Packages' (hnum INTEGER PRIMARY KEY AUTOINCREMENT, blob BLOB NOT NULL);
Then, there are quite a number of child tables with a foreign key referencing Packages:
All tables have the same definition:
CREATE TABLE IF NOT EXISTS <tabname> (key 'TEXT' NOT NULL, hnum INTEGER NOT NULL, idx INTEGER NOT NULL, FOREIGN KEY (hnum) REFERENCES 'Packages'(hnum));
The two table Installtid and Sigmd5 differ in that the datatype of key is not TEXT but BLOB.

Index