The field of invention relates generally to relational database management; and, more specifically, to a backward reference in a persistent data target object within a unidirectional relational database relationship.
Relational databases are used to define relationships between items of persistent data. For example,
The relational database entries of
Notions of “navigability” come into play in the design of a relational database. Navigability defines the ordered flow in which elements of data within a relational database can be accessed. For example, according to the simplistic relational database entries observed in
Unidirectional relationships 101, 102 enforce the above policy in which information can be obtained in a first direction of object access flow but not in a second. In a typical application, the Customer A object would include information that defines the unidirectional relationship 101 to Order 1 but the Order 1 object would not include any such information (i.e., only the Customer A object has information that corresponds to relationship 101); and, the Customer B object would include information that defines the unidirectional relationship 101 to Order 2 but the Order 2 object would not include any such information (i.e., only the Customer B object has information that corresponds to relationship 102).
In terms used by those in the software arts, it can be said that customer objects have “visibility” to the order objects; but, the order objects not have “visibility” to the customer objects. Restricting visibility in this manner enforces the unidirectional relationship that is to be implemented into the database. Implementing unidirectional relationships within an object oriented persistent data relational database as described just above can be part of the defined software environment.
For example, the current Java Enterprise Java Bean (EJB) 2.0 specification currently implements a unidirectional relationship by instantiating “accessor” methods in an object having visibility to another object in a unidirectional relationship—but not instantiating such accessor methods in the other object that does not have visibility to the object. A first type of accessor method, referred to as a “set” method, is used to create or change a relationship. A second type of accessor method, referred to as a “get” method, give access to another object from the object that executes the accessor method. The EJB 2.0 specification provides as part of its container managed persistence (CMP) for both types of accessor methods and specifies that objects representing items of persistent data are implemented as “entity beans”. CMP is a service by which the persistence management of beans within an EJB container are managed by the contained itself.
Implementing a unidirectional relationship where a first object has “visibility” to a second object but the second object does not have “visibility” to the first object can be inefficient, however, when changes are to be made to existing relationships between existing objects. For example, consider if the working environment of the relational database of
If Customer A is a high priority customer and Customer B is a low priority customer; and if, Order 2 has every item in Order 1 and includes an item in shortage; then, if Customer A suddenly updates his items for purchase to include the item in shortage, Customer A may be satisfied by “taking” Order 2 from Customer B and dropping Order 1.
Implementing the change, however, can be inefficient because of the lack of visibility that Order 2 had to Customer B in the original set of relationships in
Because of the lack of visibility that Order 2 has with respect to Customer B, the second step 2) above can only be accomplished by searching through all customer objects (which again can be many more than those observed in
A method for making a change in an object oriented relational database in which objects that represent items of persistent data are related to other objects that represent items of persistent data. The method comprises referring to a backward reference contained in a first object that does not have visibility to a second object that the first object is in a unidirectional relationship with. The first object represents a first item of persistent data. The second object represents another item of persistent data. The backward reference identifies the second object. The method also comprises removing the unidirectional relationship, adding a new unidirectional relationship from a third object to the first object, and modifying the backward reference to identify the third object rather than the second object. A cascade delete method that uses a backward reference is also described.
The present invention is illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements and in which:
a and 1b shows a change made to relational database of persistent data;
a shows the relationship of
b shows an object that lacks visibility to its companion object including a backward reference to its companion object;
a through 3d show a method for implementing the change of
a through 4c show another database change made with the use of a backward reference;
a and 6b show methodologies made with the use of a backward reference;
A solution to the problem of finding a relationship companion to an object that does not have visibility to its relationship companion is to include a “backward reference” into the object that lacks visibility to its relationship companion.
A backward reference is a reference to a relationship companion within an object; where, the object does not have visibility to the relationship in light of the navigability rules that apply. Referring to
Note that the implementation of the backward references 203, 204 into the order objects does not interfere with the “designed-for” navigability principles of the database. That is, for example, the Customer A and Customer B objects would include accessor methods but the Order 1 and Order 2 objects would not. As such, during a normal flow of use of the database (i.e., when a change to the database is not being made), purchased items listed in “Order 1” can be retrieved with the identity of “Customer A” (and purchased items listed in of “Order 2” can be retrieved with the identity of “Customer B”)—but—the identity of “Customer A” can not be retrieved from the records “Order 1” (and the identity of “Customer B” can not be retrieved from the records of “Order 2”).
b shows an exemplary depiction of how a backward reference could be implemented into the Order 2 object of
As observed in
According to the database change procedure of
Removing the backward reference 203 from Order 1 to Customer A first, as observed in
Here, assume that it is not yet known exactly which other order Customer A will “take” in order to satisfy Customer A. That is, for example, perhaps multiple orders (not shown) came up as “hits” when the pool of order objects were searched to identify those objects that included all items needed by Customer A. As such, the unidirectional relationship 201 from Customer A is not yet changed because it is not yet known to which object the new unidirectional relationship from Customer A will point.
The referring to the backward reference of Order 2 as observed in
b shows the result of Customer B being of lower priority than Customer A because the unidirectional relationship 202 from Customer B to Order 2 has been removed to make room for Customer A to “take” Order 2.
Implementing the backward reference from Order 2 to Customer A (in
a through 4c shows a database change involving an Order 1 object 401 and objects 403, 404, 405 representing ordered items A, B and C respectively; and, an Order 2 object 406 and objects 408, 409, 410 representing ordered items D, E and F respectively. The specific change is that ordered item C is to be removed from Order 1 and added to Order 2. Note that each of the order relationships include corresponding unidirectional relationships 411, 413, 415, 417, 419, 421, 423, 425 and corresponding backward references 412, 414, 416, 418, 420, 422, 424, 426. Each of the order relationships are implemented as “one to many” (“1:M”) relationships through the use of a collection object (collection object 402 for Order 1 and collection object 407 for Order 2) that identifies the objects for each of the “many” (M) items of their respective order (i.e., items A, B, C for Order 1 and items D, E, F for Order 2).
Referring to
Upon reaching a conclusion that the removal of item C from the Order 1 arrangement was appropriate (e.g., because Order 1 or Order 1's customer was lower in priority than Order 2 or Order 2's customer),
A cascade delete is a process by which the elimination of an object from a database causes a “ripple effect” whereby other objects that are related to the eliminated object must also disappear (i.e., an inter related network or objects “does not make sense” if a particular object disappears). In the exemplary situation of
a and 6b show methodologies that have been discussed above.
According to the methodology of
According to the methodology of
Processes taught by the discussion above may be performed with program code such as machine-executable instructions which cause a machine (such as a “virtual machine”, general-purpose processor or special-purpose processor) to perform certain functions. Alternatively, these functions may be performed by specific hardware components that contain hardwired logic for performing the functions, or by any combination of programmed computer components and custom hardware components.
An article of manufacture may be used to store program code. An article of manufacture that stores program code may be embodied as, but is not limited to, one or more memories (e.g., one or more flash memories, random access memories (static, dynamic or other)), optical disks, CD-ROMs, DYD ROMs, EPROMs, LEPROMs, magnetic or optical cards or other type of machine-readable media suitable for storing electronic instructions.
It is believed that processes taught by the discussion above can be practiced within various software environments such as, for example, object-oriented and non-object-oriented programming environments, Java based environments (such as a Java 2 Enterprise Edition (J2EE) environment or environments defined by other releases of the Java standard), or other environments (e.g., a .NET environment, a Windows/NT environment each provided by Microsoft Corporation).
In the foregoing specification, the invention has been described with reference to specific exemplary embodiments thereof. It will, however, be evident that various modifications and changes may be made thereto without departing from the broader spirit and scope of the invention as set forth in the appended claims. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.
This patent application is a divisional of Ser. No. 10/836,681 filed on Apr. 30, 2004, entitled, “BACKWARD REFERENCE IN A PERSISTENT DATA TARGET OBJECT WITHIN A UNIDIRECTIONAL RELATIONAL DATABASE RELATIONSHIP”.
Number | Name | Date | Kind |
---|---|---|---|
7143108 | George | Nov 2006 | B1 |
20040111701 | Beust | Jun 2004 | A1 |
Number | Date | Country | |
---|---|---|---|
20060123023 A1 | Jun 2006 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 10836681 | Apr 2004 | US |
Child | 11270961 | US |