Enterprise Objects supports tables that have compound primary keys. In EOModeler, you identify the attributes that are a part of the compound primary key by making those attributes primary keys (so the key icon is present in an attribute’s row). All of Enterprise Objects internal mechanisms that rely on primary keys (such as global ID creation) work just as well with compound primary keys as with simple primary keys. However, you cannot use a compound primary key and Enterprise Object’s automatic primary-key generation. You have to provide a primary key another way.
The easiest way to generate primary keys for compound primary keys is with the delegate method databaseContextNewPrimaryKey. The implementation of this method in “Generating Custom Primary Keys” supports a compound primary key. It retrieves all of an entity’s primary keys and generates a unique value for each one.
Note that methods in Enterprise Objects that return primary key values usually return an NSDictionary object. This is to support the case in which a primary key is compound. Each key of the dictionary is the name of an attribute that is part of the compound key.
Last updated: 2007-07-11