Restructured database relationships

Simplified the relationships between the MetaData table and other tables
by using a smaller intermediary table.
Queries should be much easier now.
Merge pull request #57 from dannybutler/master

Restructured database relationships