May 2014
Intermediate to advanced
624 pages
19h 43m
English
The next step is to factor (database-savvy developers would say normalize) ownTeam out of Game and into a new entity, Team. Click on Passer Rating.xcdatamodel, and (using the skills you picked up in Chapter 9, “An iOS Application: Model”) create the Team entity, with one attribute, teamName. teamName should be a string, indexed, not optional, and with an obviously bogus default name like UNASSIGNED_NAME. Add a relationship, games, tracing to many of the Game entity; deletion should cascade.
Game can lose the ourTeam attribute, and gain team, a to-one relationship to Team, nullifying on delete. Be sure to set up this relationship as the inverse of Team’s games. When you’re done, the diagram view of the data model should look like ...