added 'composite' SQL view

does a lot of the heavy work, hopefully removing the load from php