PATH |
Describes how the primary key is generated for a new object in EOF. It also explains the various ways the user can generate a primary key.
Primary keys are used in a database to identify a row in a table. Each key is generated on the client side before its corresponding row is inserted into the database.
There are several ways to generate the primary key, some of which are outlined below.
The primary key can be generated by the user in the Enterprise Object (EO) when it is created. EOModeler allows the primary key to be made a class property and hence, an instance variable of the Enterprise Object. The user has the responsibility of creating a unique primary key each time a new EO is instantiated.
In Enterprise Objects Framework's default primary key mechanism, the EOAdaptorChannel generates the primary keys. It collaborates with the database server to maintain a linear sequence of nonrepeating primary keys per entity. The primary key attribute must not be a class property. If the type of the primary key attribute is a 12-byte NSData, EOF generates unique primary keys without going to the database.
Before using the adaptor's default primary key generation, the EODatabaseContext's delegate is given a chance to generate the primary key. This method is used only if it satisfies the following conditions
The user can create a stored procedure for the generation of the primary keys and add it to model. The stored procedure is set as the primary key stored procedure for the entity.
The EOModeler allows the user to set the "Propagate Primary Key" in the advanced relationship inspector. When the user creates an object within an entity, that entity's primary key is used as the primary key for the new object.
For example, a column in table A can be the primary key for table A, as well as the foreign key to a table B.
22 July, 1998. Seejo Pylappan. First Draft.
19 November, 1998. Clif Liu. Second Draft.