Build database relationships