References that indicate where global database objects reside6134558Abstract A method and apparatus for generating references to a set of objects which reside in a plurality databases is described. Each object is associated with a table from a plurality of tables that are contained in the plurality of databases. An object id is associated with each object; the object id uniquely identifies the object relative to the objects in the set of objects. A table id is associated with each table; the table id uniquely identifies the table relative to tables in the plurality of tables. A table containing an object is located based on the table id associated with the table, and the object is located in the table based on the object id associated with the object. A table mapping is generated. The table mapping maps a set of tables to databases associated with the set of tables. The set of tables are from the plurality of tables. References to objects from the set of object are generated. Each reference comprises data that identifies an object. The reference contains data representing the object id of the referenced object, the object referred to by the reference. The reference also contains data representing the table id of the table containing the referenced object. An object is located based on the table mapping and the reference referring to the object. The table containing the object is located based on the data in the reference, the data representing the table id associated with the table containing the object. Claims What is claimed is: Description FIELD OF THE INVENTION
______________________________________
Create Table FORMER.sub.-- EMPLOYEE
(NAME VARCHAR(30),
SSN VARCHAR(11),
STATE VARCHAR(2));
______________________________________
The above statement defines the relational table as having a column called NAME and specifies the column's data type as a VARCHAR having a maximum length of 30. VARCHAR is a primitive data type recognized by a DBMS, such as Oracle8.TM.. A VARCHAR is a string that is variable in length. Other examples of primitive data types include INTEGER and FLOAT. As used herein, length refers to the amount of the storage medium used to store a data structure in the particular medium in which the data structure is stored. For example, a sequence of bytes may be used to store a data structure of the type VARCHAR in the main memory 106 of computer system 100. Each byte in memory 106 contains one character of the string. If the data structure has a length of 30, 30 bytes would be used to store the data structure. In addition to NAME, the relational table FORMER.sub.-- EMPLOYEE is defined as having columns SSN and STATE. FIG. 3F shows the relational table FORMER.sub.-- EMPLOYEE populated with sample data. A DBMS, such as Oracle8.TM. creates a data definition for an object type, and stores the data definition in the metadata, in response to receiving a request to create an object type. For example, the object type OT.sub.-- STATE, shown in FIG. 3A, is defined in response to receiving the following SQL statement:
______________________________________
Create Type OT.sub.-- STATE as Object
(NAME VARCHAR(30),
ABBR VARCHAR(2));
______________________________________
When the preceding SQL statement is received, a DBMS creates and stores a data definition for an object type named OT.sub.-- STATE in the metadata. OT.sub.-- STATE is comprised of several attributes, which are NAME, defined to be a VARCHAR(30) (i.e. string up to 30 characters in length), and ABBR, defined to be a character VARCHAR(2) (i.e. string up to 2 characters in length). ABBR is intended to represent the abbreviations of states (e.g. CA, PA). As mentioned previously, an object table contains objects belonging to the same object type, i.e. the table type. An object table is created by specifying, in the request to create an object table, the object type to which the table's objects belong. For example, the object table STATE, shown in FIG. 3B, is created by database server 202 in response to receiving the following SQL statement: Create Table STATE of OT.sub.-- STATE; Each row in the object table STATE contains the attributes of an object belonging to the object type OT.sub.-- STATE. Each column of the object table STATE represents an attribute of the objects belonging to the object type OT.sub.-- STATE. For example, referring to FIG. 3E, the row 350, represents an object belonging to the object type OT.sub.-- STATE and having a NAME attribute value of "Alabama", and a STATE attribute value of "AL". When creating an object table, the database server 202 generates a table identification number (TID) and a local table descriptor for the object table. According to one embodiment of the invention, the TID generated for a table is a value that uniquely identifies a table relative to tables in the same or other databases. A local table descriptor is data that uniquely identifies a table relative to tables contained in the same database as the table. The local table descriptor associated with an object table, for example, is unique relative to any other table contained in the same database as the object table, including relational tables or other object tables. Both the local table descriptor and the TID are stored as part of the data definition of the table in the metadata. GENERATION OF UNIQUE IDENTIFICATION NUMBERS According to an embodiment of the invention, the TIDs assigned to tables by database server 202 are unique among any object table accessible by database server 202, including object tables in database 254 that are foreign to database server 202. Various mechanisms may be used to ensure that the TIDs assigned by database server 202 are unique. For example, TIDs can be made unique among a set of DBMSs by causing each database server in the set of DBMSs to use the same id assignment function when generating TIDs for object tables. An id assignment function may be implemented by a sequence of instructions running on a computer system, which, when executed, generates an id that is unique among any other ids generated by the same function running on any computer system. Such an id assignment function is available, for example, in a software product called SQL*NET.TM., generally available from Oracle Corporation. Any applications, including database management systems, that use such a function to generate ids within any computer system are assured that the generated ids are unique relative to previously generated ids and relative to the ids generated for any other application using the same function. Various mechanisms for generating an id that is unique relative to any other id generated by the same mechanism running on any computer system are well to known those skilled in the art. Therefore, it is understood that the present invention is not limited to any particular mechanism for generating unique ids that are unique relative to any id generated by the same mechanism. OBJECT IDS Referring again to FIG. 3B, each object in object table STATE is associated with an object id ("OID"). An object ID is assigned by the DBMS when an object in an object table is created. An object may be created, for example, by an SQL insert command. The object id is unique among any object created by any application that uses the same id assignment mechanism in generating object ids for objects, including DBMSs that use the same id assignment mechanism. In one embodiment of the invention, the same id assignment mechanism is used to generate TIDs and OIDs. Note that the sample TID and OID values shown in FIGS. 3B, 3D, 3H, and 4B are only 6 characters in length. The TIDs and OIDs shown in FIGS. 3B, 3D, 3H, and 4B are intended to be illustrative, and not intended to represent actual TIDs and OIDs. Typically, ids assigned to object tables and objects are much greater in length, or contain more significant digits than the illustrative TIDs and OIDs shown in FIGS. 3B, 3D, and 4B. For example, OIDs and TIDs generated by the Oracle8.TM. DBMS can represent numbers up to 2.sub.128 -1. TABLE MAPPINGS A table mapping is a set of data structures that contain data indicating the database containing a particular table. FIG. 5 shows a table mapping of one embodiment of the invention, which comprises global table map 504 and local table map 554. Referring to FIG. 5, the entries in local table map 554 each contain a TID and a local table descriptor. A local table descriptor is data that uniquely identifies a table relative to other local tables. Each entry thus serves as a mapping between a TID and the object table identified by the local table descriptor. A local table map is maintained in a manner that keeps the table consistent with the database containing the local table map. The table map thus only contains entries that correspond to object tables in the database containing the local table map. For example, when an object table is created, an entry for that object table is created in the local table map. The entry just created contains the TID and the local table descriptor associated with the object table. When the object table is moved from a first database to a second database, an entry corresponding to the object table is removed from the local table map of the first database, and an entry corresponding to the object table is added to the local table map of the second database. FIG. 5 also shows a global table map 504, which is contained in database 204. Global table map 504 contains entries for foreign tables. Each entry in global table map 504 contains a TID and a database descriptor. A database descriptor is data that uniquely identifies a database among multiple databases. Each entry thus serves as a mapping between the foreign table associated with the TID and the database identified by the database descriptor. Because the TID is unique between local tables and foreign tables, the database to which any mapped object table belongs can be determined based on the TID associated with the object table. Any object table associated with any entry in the global table map is referred to as a mapped table relative to the global table map. Entries are added to the global table map 504 when a foreign reference is generated, as shall be described in further detail. Entries may also be added by the execution of a table mapping utility that creates entries for foreign object tables. The table mapping utility scans one database for object tables contained in that database and makes entries for those object tables in another database. In an embodiment of the invention, global table map 504 and local table map 554 may be either an object table or a relational table. Therefore, client 208 can issue SQL statements inserting or updating entries in global table map 504 of either database 204 or database 254. GENERATING REFERENCES References are generated in response to requests received by a database server 202 or database server 252 for references to objects. For example, a request may be made by a client 208 by issuing an SQL query statement that designates that the data to be returned include references to the objects returned by the database server 202 to client 208 in response to the query. The data returned in response to a query is herein referred to as the query results. The objects contained in the query results are referred to as the returned objects. In response to receiving the above query, database server 202 finds the objects specified in the query and returns the query results, including the references to returned objects. For example, consider the following SQL statement issued by client 208 to database server 202: Select REF(s) From STATE s; In response to receiving the SQL statement, the database server 202 returns to client 208 a reference to every object contained in object table STATE (FIG. 3B) that matches the query represented by the above statement. In the example, all the objects in the object table STATE would be returned to client 208. When the client receives the references, the client 208 may store the references. One of the above references received by client 208 may later be used to by client 208 to populate an attribute of an object, referred to as a reference attribute. For example, client 208 may transmit an SQL insert statement to database server 202 to create an object. The insert statement would specify that one of the attributes to be populated is a reference attribute, and the data with which to populate the attribute is one of the references previously received by client 208. A reference attribute is an attribute that is a reference to an object of a particular type. A reference attribute may be defined by an object type. For example, consider the following SQL statement:
______________________________________
Create Type OT.sub.-- PERSON as Object
(NAME VARCHAR(30),
SSN VARCHAR(9),
STATE REF OT.sub.-- STATE);
______________________________________
In response to receiving the above statement, a DBMS, such as Oracle8.TM., defines the object type OT.sub.-- PERSON object type (FIG. 3C) as having a STATE attribute that is a reference to an object belonging to the object type OT.sub.-- STATE. Referring to FIG. 3D, the object table EMPLOYEE is an example of an object table containing objects having a reference attribute. The table type of EMPLOYEE is PERSON. Note that the STATE attribute of the objects contained in the object table EMPLOYEE may be referred to as EMPLOYEE.STATE. Other attributes associated with a particular object table or object type may be referred to according to the following form: <object table or object type>.<attribute> The EMPLOYEE.STATE reference attribute of the objects contained in EMPLOYEE is a reference to any object belonging to the object type OT.sub.-- STATE. The reference attribute may refer to an object in the object table STATE, or it may refer to another object table containing objects belonging to the object type OT.sub.-- STATE. For example, another object table, called COUNTRY.sub.-- X.sub.-- STATES, may also contain objects belonging to the object type OT.sub.-- STATE. Assume COUNTRY.sub.-- X.sub.-- STATES represents the states in the country X. The EMPLOYEE.STATE attribute of an object in the object table EMPLOYEE may refer to an object in object table STATE, or refer to an object in object table COUNTRY.sub.-- X.sub.-- STATE. As shall be described in further detail, a reference contains information indicating the object table to which the referred object belongs. REFERENCES FIG. 6 shows the data structure of a reference 610 according to an embodiment of the invention. Reference 610 includes an Rlength field, a row id flag field, a key-based OID flag field, an Olength field, an OID field, a TID field and a row-id field. Each of these fields shall be described in greater detail below. In the illustrated embodiment of the invention, the length of a reference is variable, i.e. the length of one reference may differ from the length of another reference. Consequently, reference 610 contains the Rlength field. The value stored in the Rlength field specifies the length of reference 610. The Rlength field is fixed length and is stored at the beginning of reference 610 in order to indicate the number of bytes in reference 610. The row-id flag field of reference 610 indicates whether the reference contains a row-id field. The contents and use of the row-id field are described in greater detail below. The key-based flag indicates whether the reference is a key-based reference. Row-ids and key-based references shall be described in further detail. In one embodiment of the invention, the row-id flag and the key-based flag are each represented by a bit in a status byte. For example, the bit representing the row-id flag in the status byte being set to 1 represents that the reference contains a row-id. The row-id field of reference 610 contains data that represents a row-id. A row-id represents the location of a specific entry in a table. Row-ids are well known to those skilled in the art and are not further described. The row-id field in a reference represents the row-id of a row (in an object table) that, at one point in time, contained the object referred to by the reference. A row-id associated with an object may change after a reference in the database is created as result of running utilities that re-organize rows in tables more efficiently. Other utilities may be run that find references in the database with row-id fields that do not refer to a row containing the referred to object, and then correct such row-id fields. The OID field is the OID of the object referred to by a reference. The Olength field stores a value of the OID field. In various embodiments of the invention, the length of the OID may or may not be variable. An OID is variable, when, for example, the OID is key based. Key based OIDs are explained in greater detail below. When the length of an OID is not variable, the Olength field may be omitted from the data structure of a reference. The TID field contains the TID of the table that contains the object referred to by a reference. GENERATING REFERENCES Database server 202 creates a reference when, for example, a query specifies that a reference be returned for the objects matching the query. An example of such a query was described above. For each of the objects matching the query, the DBMS creates in the memory, or other storage medium, values for the fields in reference 610. For example, assume that client 208 transmits to database server 202 an SQL statement representing a query of the EMPLOYEE table (FIG. 3D): Select REF(e), NAME, STATE From EMPLOYEE e Where SSN=`999-99-9999`; In response, the database server 202 determines that the object with OID 000000 in the EMPLOYEE object table matches the query. This object is referred to as the selected object. The database server 202 then generates the reference to the selected object. Generating the reference includes determining the value of the TID field. This value can be found in the data definition of EMPLOYEE table. Then the OID for the selected object is read from the OID column of the row containing the selected object. The row-id of the row in which the object is located is stored in the row-id field. The row-id flag is set to indicate that the reference contains a row-id. Then the length of the reference is calculated and stored in the Rlength field. Finally, the reference is returned as part of the data returned by the database server 202 representing the results of the above query. LOCATING OBJECTS BASED ON REFERENCES A reference is used to locate an object. The need to locate objects based on references arises in many contexts. For example, consider the following PL/SQL.TM. code fragment:
______________________________________
Declare empref Ref EMPLOYEE;
Declare empname VARCHAR2(30);
.
Select REF(e) From EMPLOYEE e Where SSN = '999-99-9999' Into
empref;
empname :=empref.name;
______________________________________
The first line represents a declaration of a variable containing a reference. Assume that in the third line of code, empref represents a reference to the object. The third line causes the server to return the reference to the object in EMPLOYEE whose SSN attribute value equals `999-99-999`. The reference returned contains the OID of the object, which is `000000`. In response to executing the instructions represented by the third line, client 208 transmits a request for the object. The request includes a reference. In response to receiving the request, the database server 202 locates the object, and then transmits to the client the object data requested by the client, including data for the NAME attribute for the object data. FIG. 7 represents the steps for locating an object based on a reference according to an embodiment of the invention. The steps are illustrated in reference to the above example, the EMPLOYEE object table shown in FIG. 3D, and exemplary reference 630 (FIG. 3). At step 710, the database server receives a request to locate an object based on the reference. The request includes the reference. In this example, client 208 invokes the function of the API for database server 202 for requesting objects based on references. Database server 202 receives the request along with the reference. The reference received along with the request is referred to as the request reference. The object requested by the client is herein called the requested object, the object referred to by the request reference. At step 720, the object table containing the requested object is located based on the TID field of the requested reference. The object table containing the requested object is referred to as the requested table. First, local table map 554 is scanned to find an entry containing a TID matching the TID field of the requested reference. If an entry is found, then the requested object is in a local table, and database server 202 locates the requested table based on the local table descriptor and the metadata. Control then passes to step 730. If on the other hand no entry is found in local table map 554, then the requested object table is a foreign object table. The global table map 504 is examined for the entry matching the TID. Based on the DBMS descriptor contained in the entry with the matching TID, the DBMS is able to determine which database contains the requested table and the requested object. Database server 202 sends a message to the foreign DBMS managing the foreign database on which the foreign table resides. The request includes the information contained in the requested reference. In response, the foreign DBMS performs the steps for locating the requested table based on the local table descriptor and metadata described immediately above. Control then passes to step 730. In this example, the TID field in the reference is 999, the TID of the object table EMPLOYEE. Assume that when database server 202 examines the mapping table, it finds that the database descriptor in the matching entry indicates the object table is located in database 204, the local database. Then database server 202 scans its local table map for the entry with a TID matching the TID field of the request reference. Database server 202 finds the entry with TID 999. Based on the local table descriptor contained in the entry, database server 202 locates the requested table. Control therefore passes to step 730. At step 730, a determination is made of whether the row-id flag is set to indicate whether a row-id is contained in the request reference. If the row-id flag is set to indicate that the reference contains a row-id, control passes to step 740. Otherwise, control passes to step 760. In this example, the row-id flag indicates a row-id is present. Therefore, control passes to step 740. At step 740, the entry in the requested table corresponding to the row-id is located. The row represented by the row-id is accessed and the OID contained in the row is examined. At step 750, a determination is made of whether the OID being examined matches the value in the OID field of the request reference. When the OID being examined and value in the OID field match, then the object represented by the row is the requested object. If the OID being examined matches the value in the OID field, control passes to step 770. Otherwise, control passes to step 760. In this example, the database server 202 accesses the object table EMPLOYEE (FIG. 3D), and examines the OID contained in row 308. Because the OID being examined has a value of 000000, which matches the OID field of the request reference, control passes to step 770. At step 770, the data representing the object is returned to the client. If a foreign database contains the object, data representing the object is returned to the database server of the local database, which in turn transmits the data to the client. Step 760 is performed when the requested reference does not include a row-id, or the row specified by the row-id does not represent the requested object. In step 760, the requested table is traversed for the row containing an OID matching the OID field of request reference, using methods well known to those skilled in the art. OBJECT VIEWS A view is the presentation as a table of data from one or more tables in a database. An object view is presentation of data as a set of objects in an object table. A DBMS generates an object view based on an object view definition stored in the metadata. An object view definition is created in response to receiving a request from a database client to create an object view definition. The request specifies the tables and the columns in the tables that are used to represent the attributes of the objects presented by the object view. The request also specifies the one or more columns that will be used to generate OIDs for the objects presented by the object view. In response to receiving the request to create an object view, the DBMS stores an object view definition in the metadata. A TID is assigned to the object view. KEY-BASED REFERENCES The request to create an object view definition may also specify the one or more attributes of the object view that are used to generate OIDs for the objects presented by the object view. An OID generated in this fashion is referred to as a key-based OID. The attributes that are specified as the attributes to use to generate the OID are referred to as the OID attributes. References based on key-based OIDs are referred to as key-based references. Key-based references are used to refer to objects presented by an object view that is based on a relational table. A key-based reference may be generated by a database server in response to receiving a query of an object view. Because the actual data stored in any column corresponding to an OID attribute for a set of rows may vary in length, key-based OIDs vary in length. Consequently, the OID field in a key-based reference is variable. For example, consider the object view definition FEMPLOYEE (FIG. 4B), created by DBMS 22 when it receives the following SQL statement:
______________________________________
Create View FEMPLOYEE of OT.sub.-- FEMPLOYEE
With OID(SSN)
SELECT f.NAME,
f.SSN,
FROM FORMER.sub.-- EMPLOYEE f;
______________________________________
Object view FEMPLOYEE is created based on the OT.sub.-- FEMPLOYEE object type shown in FIG. 4A. The above statement specifies the attribute SSN of OT.sub.-- FEMPLOYEE as the OID attribute for the object view FEMPLOYEE. The objects presented by an FEMPLOYEE object view have attributes as defined by OT.sub.-- FEMPLOYEE, which are NAME and SSN. The columns FORMER.sub.-- EMPLOYEE.NAME and FORMER.sub.-- EMPLOYEE.SSN correspond to the NAME and SSN attributes of OT.sub.-- FEMPLOYEE respectively. When a reference is key-based, the key-based flag is set to indicates so. The reference also includes an Olength field, which precedes the OID in the reference. The Olength field indicates the length of the key-based OID. In addition to systems using key-based OIDs, the Olength field may be used to indicate the length of the OID field in any system where the OID field length in a reference is variable. LOCATING OBJECTS BASED ON KEY-BASED REFERENCES In an embodiment of the invention where the references may be key-based, database server 202 follows the above steps, modified as follows. At step 720, database server 202 determines whether the requested reference is key-based by examining the key-based flag. If the request reference is not key-based, then performance of the steps proceeds as previously described. If the key-based reference is based on an object view, then database server 202 determines the database containing the object view in substantially the same manner as database server 202 determines the database of the requested tables. The database server 202 appends a where condition based on the OID field in the request reference. Specifically, the view is modified as if the object view definition included a "Where" condition that the OID columns of the object view match the OID field of the request reference. The view is evaluated resulting in the requested object. For example, consider a query of the view FEMPLOYEE (FIG. 4B), represented by the following PL/SQL.TM. code:
______________________________________
Declare empref Ref OT.sub.-- FEMPLOYEE;
.
.
Select NAME From FEMPLOYEE f Where REF(f) = empref;
______________________________________
The first line represents a declaration of a reference variable. Assume that when computer instructions represented by the second line of code are being executed by client 208, empref represents a reference with an OID field having a value of `999-99-9999`, with a TID field having a value of 800, the TID associated with the view FEMPLOYEE. Further assume, that the client executing the above PL/SQL.TM. transmits a request for a query of the object specified by the reference represented by empref. In response to receiving the request, the DBMS would generate a query of the object view similar to the one represented by the following PL/SQL.TM. code: Select NAME From FEMPLOYEE Where SSN=`999-99-9999`; SSN is the OID attribute. The `Where` condition specifies that the SSN attribute match the OID field in the request reference. REFERENCES TO FOREIGN OBJECTS A reference to a foreign object is a reference to an object contained in another DMBS (i.e. foreign database). When a reference to a foreign object is generated, an entry is added to the global table map of the local DBMS. This entry contains the TID of the foreign object table and the database descriptor of foreign database containing the foreign object. For example, assume that client 208 issues the following SQL query statement to database server 202 for data in object table EMPLOYEE.sub.-- ARCHIVE (FIG. 3H), which is in database server 252: Select REF(EMPLOYEE.sub.-- ARCHIVE),NAME, SSN From EMPLOYEE.sub.-- ARCHIVE@DBMS254; Assume "@DBMS254" designates that the table is located in database managed by database server 252, database 254, which is a foreign database to database server 202. Further assume that the objects in EMPLOYEE.sub.-- ARCHIVE (FIG. 3H) belong to the OT.sub.-- ARCHIVED.sub.-- EMPLOYEE object type (FIG. 3G), and that object table EMPLOYEE.sub.-- ARCHIVE is located in database 254. Note that the above statement specifies that the query results include references to the returned objects, the returned objects being foreign objects in EMPLOYEE.sub.-- ARCHIVE. In response to database server 202 receiving the request from client 208, database server 202 requests the data specified by the above SQL query statement from database server 252, including the references (returned references). The request may be in the form of an SQL statement or an API function call. Because the returned references are references to foreign objects, database server 202 updates global table map 504. An entry is inserted into global table map 504 with a TID corresponding to the TID of EMPLOYEE.sub.-- ARCHIVE and a database descriptor corresponding to database server 252. Maintaining global table map 504 in this manner ensures that if a returned reference is used to access an object, that the TID specified by the TID field in the returned reference is mapped in global table map 504. ALTERNATE TABLE MAPPINGS While one approach for providing a table mapping has been described, there are alternatives. Therefore, it is understood that the present invention is not limited to any particular approach for providing a table mapping. For example, in one embodiment of the present invention, the table mapping comprises a local-name table and a local-descriptor-to-database-descriptor table. The local-name table contains entries for both foreign object tables and local object tables. Each entry contains a TID and a local table descriptor, which represents the local name of the object table corresponding to the entry. Each entry thus serves as a mapping between the TID and the object table that corresponds to the entry's local table descriptor. A local-descriptor-to-database descriptor table contains entries, for both foreign object tables and local object tables, that map a local table descriptor to a database descriptor. Each entry thus serves as a mapping between the table associated with a local table descriptor and the database associated with the database descriptor. In step 720, the requested object table is located by first scanning the local-name table to find the local table descriptor associated with TID contained in the requested reference. Then the local-descriptor-to-database-descriptor table is scanned, using the local table descriptor, to determine the database mapped to the requested object table. Once the database is found, the object table can be located. In another embodiment of the present invention, there is no counterpart to the local table map 554. Instead, the global table map 504 comprises a table having columns for a TID, a local table descriptor, and a database descriptor. Each row is associated with a local or foreign object table. If the row is associated with a local table, then the local table descriptor column contains a value representing a local table descriptor and the database descriptor column has no value (i.e. a value representing no database). If, on the other hand, the row is associated with a foreign table, then the local table descriptor column contains no value (i.e. a value representing no local table) and the database descriptor column has value representing the database descriptor of the database containing the object table. In step 720, the requested object table is found by first scanning the global table map 504 for the row containing the TID associated with the requested object table. Next, the database containing the object table is determined. First, the local table descriptor column is read. If the local table descriptor has a value, then the requested object table is a local table. If, on the other hand, the local table descriptor has no value, then the database descriptor column is read. The database that contains the object table is the database associated with the database descriptor. Once the database is determined, the object table is located in a manner similar to that previously described. BATCHING BASED ON OBJECT REFERENCES A single request that specifies the performance of an action upon group of objects, rather than a single object, is referred to as a batch request. For example, consider the request represented by the following previously described PL/SQL statement: Select REF(e) From EMPLOYEE e Where SSN=`999-99-9999`; The where condition specifies the SSN attribute of an object. Assume that the SSN attribute is the key for EMPLOYEE, and thus only one object can possibly match the where condition. This request thus represents a request for a single object, and is therefore not a batch request. Consider the following previously described PL/SQL statement: Select REF(s) From STATE s; As explained earlier, this request is a request for references of all the objects in STATE. Because this request specifies a group of objects, the request is a batch request. Batch requests take many forms. In one embodiment of the invention, a batch request can be made to pin a group of objects. For example, a batch pin function, a function for pinning a group of objects, may provide for the purposes of specifying the objects to pin, a parameter for an array or list of object references. A pin is a request to load one or more objects into memory so that the objects may be accessed and manipulated. The array or list of object references may contain TIDs of more than one object table or view. Typically, when a batch request is based on an SQL statement specifying a query, the operation specified by the SQL statement may only operate on objects from one source (i.e. the extent of the table or view specified the SQL statement). One the other hand, when a making a batch request based on a list of object references, objects from more than one source (e.g. table or view) may be operated upon. For example, assume that it is desired to update data representing the attributes of objects x residing in object table x, and objects y residing in object table y. To request the updates based on SQL statements, two requests are required. To issue a request using an update function that operates upon an array of references to objects x and objects y, requires one request in the form of one function invocation for the entire arrary of references. Requesting objects from multiple tables or views by issuing one request is especially an advantage in a network environment, where requests are transmitted and objects are returned across a network. Consolidating requests for objects from multiple tables or views reduces network traffic and increases performance. The methods described herein offer many advantages over previous methods for locating objects based on references to objects. One advantage is the ability to determine the location of the object table containing a sought object without having to scan multiple object tables or the indexes of multiple object tables. Instead, the global table map is scanned to determine which table contains the sought object, and then local table map 554 is scanned to determine which database contains the object. Typically, the global table map and local table map are much smaller than many of the object tables containing the sought objects, and can therefore be stored in entirety in main memory 106 of a computer system 100 while a DBMS, such as database server 202, is running. Storage in a dynamic storage mechanism, such as main memory 106, provides far quicker access than storage in other mediums, such as computer disk drive. Another advantage is the ability to locate the row corresponding to the sought object in the object table using the row-id. Because the reference makes the row-id available, an object can be located in an object table without the need to traverse the object table's entries or to create an index based on the object id. Furthermore, the row-id is used only as a "hint". When the row identified by the row-id is examined, the object id contained in the row is verified to ensure it matches the object id of the sought object. When there isn't a match, the sought object is located using conventional methods, such as traversing the object table containing the sought object. Because the row-id is relied upon as only a "hint", and not an absolute indicator of an object's location in the object table containing the object, the attributes of an object may be transferred to a different row without causing the errors that arise due to mistakenly locating an object. Another advantage is that a reference may continue to be used to locate the objects even when the object tables containing the objects are transferred from one database to another database. Because a TID is unique among the databases using the same object id mechanism, the TID value in a reference continues to uniquely identify an object table as it is moved from a database that uses an object id mechanism to another database using the same mechanism. As a consequence, the mappings in the global table map, which are based on the correlation between the TIDs and database descriptor contained in each entry, can be relied upon to establish the location of an object table, even after the object table has been moved from one database to another. In the foregoing specification, the invention has been described with reference to specific 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. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.
|
Same subclass Same class Consider this |
||||||||||
