Portage is missing some important information about packages. The purpose of this database is to easily answer questions: - What ebuilds provide file foobar (or /path/to/foobar)? - What files ebuild foobar provides? The database should contain the following information: ename name of each ebuild eversion version of each ebuild eused USE-flags that were in effect while package was installed and used by the package (IUSE) fpath path to each file fname name of each file Structure of the database could be: PK = primary key (unique, indexed, notnull) FK = foreing key R = reference, can return multiple rows notnull = value can not be missing TABLE ename column type --------------------- id int, PK name string, unique, indexed, notnull TABLE eversion column type --------------------- id int, PK version string, unique, indexed, notnull TABLE useflags column type --------------------- id int, PK flag string, unique, indexed, notnull TABLE flaglist column type --------------------- id int, PK setid int, indexed, notnull flagid R(useflags.id), notnull TABLE fpath column type --------------------- id int, PK path string, unique, indexed, notnull TABLE fname column type --------------------- id int, PK name string, unique, indexed, notnull TABLE filelist column type --------------------- id int, PK setid int, indexed, notnull pathid FK(fpath.id), notnull nameid FK(fname.id), indexed, notnull TABLE main column type --------------------- id int, PK name FK(ename.id), notnull version FK(eversion.id), notnull flags R(flaglist.setid) files R(filelist.setid), indexed Referencing goes like this: main -+-> ename +-> eversion +-> flaglist -+-> useflags | | ... | `-> filelist -+-> fpath, fname | ... A row in table 'main' is a version of an ebuild installed with given USE-flags. Only those USE-flags that the ebuild really uses should be listed. According to 'filelist.setid' list of 'fpath, fname' pairs can be retrieved. This structure solves the task given. Database design by Pekka "PQ" Paalanen