Even though Mac OS X filesystem is not a relational database, it does support a query language that allows you to search for built in or user defined attributes and their values.
This search functionality is available system wide (Spotlight search box), from any file open dialog or from the command line. For example things like this are possible:
Find me all pictures I tool this year and where I used flash, and aperture f4:
kind:image fnumber:4 date:"this year" flash:1
You type this in either spotlight or search box on open file dialog. You can do the same from the command line
mdfind -interpret "kind:image fnumber:4 date:"this year" flash:1"
The nice thing about the mdfind command is that you can restrict the search to a directory of your choice only.
Some people pay good money for photo organizers on Mac OS X, not knowing they already have this functionality built in. And finding what attributes are available is not that hard either:
mdimport -X
prints the entire metadata schema.