Patent ID: 7536407

Claim:
A machine to manage entity-relationship data for data objects persisted in a relational database and to reduce a number of database operations needed to maintain persistent referential integrity between a plurality of data objects, comprising: a computer having a processor and a memory, the computer connected by a network to a relational database; a container managed relationship engine, a container program, and a client object program in the memory; wherein, when the client object program requests the container program to create a parent component object and to create a child component object that depends on the parent component object, the client object program specifies a RESTRICTED rule, a CASCADE rule, or a NULL rule for the relationship between the parent component object and the child component object; wherein, responsive to the container program creating the parent component object and the child component object, the container program creates a reference that links the child component object to the parent component object, indicates that the child component object is dependent upon the parent component object, and persists the parent component object and the child component object to the database; wherein, when the client object program requests the container program to remove the parent component object, the container managed relationship engine applies a referential integrity rule specified by the client object program for the parent component object; wherein, when the RESTRICTED rule is specified, the container managed relationship engine throws an exception to the client object program, the exception indicating that the client object program has attempted to remove the parent component object without first removing the child component object, whereby the container managed relationship engine eliminates a need to access the relational database where such access would result in an error; wherein, when the CASCADE rule is specified, the container managed relationship engine removes the parent component and the child component from the memory and then removes the parent component object from the database wherein a database management system in the database then applies a cascade-on-delete rule to remove the child component object from the database; wherein, when the NULL rule is specified, the container managed relationship engine sets the reference in the child component object to a null value, removes the parent component object from the memory and from the database, and the database management system in the database applies a set-null rule to set the foreign key of the child component object in the database to a NULL value; and wherein the number of database operations needed to maintain persistent referential integrity between a plurality of data objects is reduced.