build the relationship of the whole database