build entities and relationships in core data