Summary of the invention
Technical matters to be solved by this invention is: provide a kind of and stride the method that class is inquired about with the bidirectional pointer technology fulfillment database between object, this method can realize effectively striding the class inquiry in database, further enriches the query processing ability of database.
The present invention solves its technical matters by following technical scheme:
The present invention is to provide a kind of class of striding with the bidirectional pointer method fulfillment database between object and inquire about, specifically is to adopt the method that may further comprise the steps:
(1) design of database cross-class inquiry mechanism:
In object-oriented database, object relationship database and object broker database, adopt the bidirectional pointer that comprises between object to connect, stride the class query specification and stride the class query processing, fulfillment database is striden the class inquiry, specifically:
Give an OID with each object in the database, OID is an object identifier, according to the relation that is had between OID that object had and different object, sets up the bidirectional pointer between different objects, to portray the contact between different objects.
In data base query language, for supporting to stride class query specification definition dependent parser.
During the database cross-class query processing, object from certain initial classes, according to the bidirectional pointer between object, find object relevant in the target class, and use and stride the goal expression that class is inquired about, adopt database expression formula Calculation Method to calculate to the object in the target class, return the result who strides the class inquiry at last;
(2) realization of database cross-class inquiry mechanism:
Its step comprises: according to the data organization form, adopt the design of above-mentioned database cross-class inquiry mechanism, realize striding the class inquiry in Database Systems.
The present invention has following main beneficial effect:
One. various semantic relations between expressive object easily and effectively.
In object-oriented database and object relationship database, the definition of abstract data type make exist between the type interrelated; In the object broker database, the definition of proxy class makes and exists the agent relation between the class.More than contact then shows as interrelated between the object at object hierarchy.Have the characteristics of unique object identifier at object in the database, the present invention proposes to adopt object identifier to set up bidirectional pointer between the object to connect being mutually related.Utilize the bidirectional pointer various complex relationships between expressive object easily and effectively.
They are two years old. can in database, realize effectively striding the class query manipulation.
Existing various semantic relations between bidirectional pointer connects between object the existence and type and type, between class and the class make to have had the basis of striding the class inquiry in database inside.The present invention makes data base query language have and describes the ability of striding the class inquiry by further expand semantic operation on existing database query language basis; By the extending database query processing module, adopt a kind of database cross-class inquiry mechanism that connects based on the bidirectional pointer between object, can in database, realize effectively striding the class query manipulation.
They are three years old. for the media application of striding of rising at present provides effective support.
Along with online digital media information is explosive increase, people are satisfied to carry out information retrieval by the simple connection between the text, and wishes by excavating and utilizing the various semantic associations between the media information to carry out the more extensive deeper medium cross-searching of striding.By setting up the two-way connection between the various medium, show various semantic relations, effectively store and manage, striding the class inquiry can be for realizing that efficiently striding Media Inquiries provides effective support.
Embodiment
The present invention is a kind of method of striding the class inquiry with the bidirectional pointer technology fulfillment database between object.Comprise the design of database cross-class inquiry mechanism and the step that fulfillment database is striden the class inquiry mechanism.Specifically:
One. the design of database cross-class inquiry mechanism
In object-oriented database and object relationship database, allow the user definition abstract data type.Exist binary relation between type and the type, binary relation can be divided into one-one relationship, many-one relationship, many-to-many relationship etc. again.What produce therefrom is between type instance, promptly also exists binary relation between object.In the object broker database, exist the agent relation between source class and the proxy class, a source class can define a plurality of proxy class simultaneously, and a proxy class also is not limited only to act on behalf of a source class.That be accompanied by agent relation between the class is agent relation between object.Object in class can be the source object of the agent object in a plurality of different proxy class, and the object in class also can be used as the agent object of the source object in a plurality of not homology classes and exists simultaneously.
Because in object-oriented database, object relationship database and object broker database, system is unique object identifier of each object distribution, and the relation between object can be come record by object identifier is interrelated.In case set up contact between the object, provided the foundation with regard to stride the class inquiry for database.Stride the class query specification by support in data base query language, and in the query processing process, utilize the contact support between object to stride the class query processing, thereby reach the purpose of database cross-class inquiry.
In object-oriented database, object relationship database and object broker database, adopt the bidirectional pointer that comprises between object to connect, stride the class query specification and stride the class query processing, fulfillment database is striden the class inquiry, specifically:
Give an OID with each object in the database, OID is an object identifier, according to the relation that is had between OID that object had and different object, sets up the bidirectional pointer between different objects, to portray the contact between different objects.
In data base query language, for supporting to stride class query specification definition dependent parser.Comprise in the data base query language and describe the grammer of striding the class inquiry, its be path expression or and the similar form of path expression, comprise initial classes, the target class of striding the class inquiry, stride the class.path that the class inquiry is experienced, and stride the expression formula on the class query aim class.
During the database cross-class query processing, object from certain initial classes, according to the bidirectional pointer between object, find object relevant in the target class, and use and stride the goal expression that class is inquired about, adopt database expression formula Calculation Method to calculate to the object in the target class, return the result who strides the class inquiry at last.Bidirectional pointer in the described database between object connects, and comprises the deletion of bidirectional pointer between the foundation of bidirectional pointer between object and object, and is specific as follows:
Set up that the method for bidirectional pointer is between object: for the object that belongs to different classes and have mutual relationship each other, when these objects are created in database, Database Systems are according to object identifier that object had, the bidirectional pointer of constructing between two objects connects, to write down two relations between object.
The method of bidirectional pointer is between the deletion object: when certain object was deleted, Database Systems deletion all bidirectional pointers relevant with this object automatically connected.
Two. the realization of database cross-class inquiry mechanism:
According to the data organization form, adopt the design of above-mentioned database cross-class inquiry mechanism, in Database Systems, realize striding the class inquiry.Stride the class query processing and adopt the method that may further comprise the steps:
1. according to striding the class query specification, determine by initial classes C
sArrive target class C
dThe class.path that is experienced, there is not the loop in this class.path;
2. for each the object O in the initial classes
s, set out by it, connect according to bidirectional pointer between the object of Database Systems maintenance, striding between all related classes of class query path, search the object that is mutually related, up to finding the related object that belongs to target class according to the depth-first traversal algorithm;
3. according to the expression formula of striding on the specified target class of class inquiry, adopt database expression formula Calculation Method, the object on the target class is calculated, stride class inquiry execution thereby finish.
Three. the application of the method for above-mentioned database cross-class inquiry
The method of above-mentioned database cross-class inquiry provided by the invention can be striden the application that class is inquired about by fulfillment database in OODBS, object-relational database system and object broker Database Systems.
Connect the semantic relation that writes down between the associated objects with bidirectional pointer; In object-oriented database, object relationship database and object broker data base query language, adopt path expression to describe and stride the class inquiry; OODBS, object-relational database system and object broker Database Systems are when striding the class query processing, path expression is calculated, thereby the class of striding that realizes object-oriented database, object relationship database and object broker database is inquired about.
1. OODBS, object-relational database system and object broker Database Systems safeguard that automatically the bidirectional pointer between the associated objects connects, and comprising:
(1) the automatic establishment of bidirectional pointer between the associated objects:
OODBS, object-relational database system and the bidirectional pointer that the object broker Database Systems are created between associated objects automatically are connected, and the steps include:
When the object in the class is created, find its all objects that are associated,
According to database is the OID that each object distributed, in Database Systems, note the bidirectional pointer between new establishment object and its associated object, newly create between object and its each associated objects bidirectional pointer by the OID of new establishment object, under it under OID of OID, the associated objects of class and the associated objects OID of class etc. form.May exist one to one between object or the relation of one-to-many, for man-to-man relation, can write down relation between object by a pair of bidirectional pointer, for one-to-many (1: relation m), then can write down the relation between object to (m to) bidirectional pointer by many;
(2) the automatic deletion of the connection of the bidirectional pointer between the associated objects:
When the object in the class is deleted, finds all bidirectional pointers relevant of data-base recording, and they are deleted from Database Systems with this object.
2. stride the description of class inquiry.Stride class when inquiry in description, need at least to comprise following some: stride the class inquiry the starting point class, stride the terminal point class of class inquiry, stride the path that the class inquiry will be experienced, stride the goal expression that class is inquired about.Stride between the class that class inquiry only requires that query path experiences and have contact, and the direction of inquiry can be two-way.The path expression that the class inquiry is striden in description is:
{<class>→}
+<target>.<expression>,
Above-mentioned path expression is based on any expression formula of target class attribute, wherein:<class〉be the title of each class in the path,<target〉be target class,<expression〉be goal expression.
3. the execution of striding the class inquiry is: from an object of initial classes, find the object of its correspondence in target class according to the path of striding class inquiry formulation, and return certain calculation expression of destination object.Its concrete steps are:
(1) according to striding the class querying command, determines by initial classes C
sArrive target class C
dThe class.path that is experienced; Carry out the correctness inspection to striding the path that class inquiry experienced, at first require this class.path not have the loop; Secondly must have certain semantic relation between former and later two classes in the class.path;
(2) for each the object O in the initial classes
s, set out by it that bidirectional pointer connects between the object of safeguarding according to Database Systems, striding between all related classes of class query path, search the object that is mutually related, up to finding the related object that belongs to target class.
Owing to stride in the class inquiry class.path associated with each other between former and later two classes, may exist one to one between object or the relation of one-to-many, according to the bidirectional pointer between object,, can directly find an object in the back class by an object in the previous class for man-to-man relation; For the relation of one-to-many, then find a plurality of objects in the relative back class by an object in the previous class.For latter event, will set out by an object of a back class that finds, along class.path up to finding the object that belongs in the target class; Date back to such afterwards, get the next object that does not calculate, continue the query processing process.
(3) according to the expression formula of striding on the specified target class of class inquiry, adopt database expression formula Calculation Method, the object on the target class is calculated, stride the class query processing thereby finish.
4. the standard of the verifying correctness of path expression is: must have the direct correlation relation in the path expression between former and later two classes, for example in the object broker database; Perhaps previous class is the proxy class of a back class, the source class that perhaps previous class is a back class.
Stride the class inquiry below in conjunction with realizing in the object broker database, the invention will be further described.
In the object broker database, can define class and proxy class.There is four types proxy class in the object broker database, comprises selection, merges, and connects and grouping, is used to support specialization, and is extensive, assembles and grouping.For each proxy class,, exist the source class of some according to the difference of its Agent Type; On this external proxy class, also can further define proxy class.Because the agent relation between class and the proxy class makes that the class in the object broker database has logically formed a reticulate texture.For example, in Fig. 1,, can expand student's class and make it have the document that is associated respectively, video and Books mutually by defining three selection type proxy class.
On object hierarchy, because the object in the proxy class is played the part of the different role of the source object in the class of source.Also exist the agent relation between agent object and the source object, according to the difference of Agent Type, an agent object can have one or more source objects; Equally, for same source object, also can have one or more agent objects.
In the object broker database, stride the class inquiry, that is: for the class that has the agent relation each other, can be from an object of one of them class, find its relevant object in target class according to certain path, and return certain calculation expression of destination object.For example, in Fig. 1, can by striding the class inquiry, can find video related and photograph album from student Zhang San's a document with him.
1. the bidirectional pointer between the object broker database object connects the concrete steps of safeguarding:
(1) the automatic establishment that bidirectional pointer connects between source object and the agent object
When creating a proxy class,, derive from agent object automatically in this proxy class by the object in the class of source according to its agent rule.In addition, upgrade when migration mechanism is feasible to be operated the source class, the new agent object that satisfies agent rule is derived from the proxy class.Therefore, when the object in the proxy class is derived from, the database root certificate is each object for allocation identifier OID of object institute, in Database Systems, note the bidirectional pointer between new generation agent object and its all source objects, the bidirectional pointer between the agent object of new derivative and its each source object by the OID of the agent object of new derivative, under it under OID of OID, the source object of class and the source object OID of class etc. form.
(2) the automatic deletion of bidirectional pointer between source object and the agent object
When the object in the class was deleted, Database Systems will find all bidirectional pointers relevant with this object, and they are deleted from Database Systems.
2. path expression is described and is striden the class inquiry
In the object broker data base query language, defined path expression and expressed and stride class inquiry.
The formalization of path expression is defined as:
{<class>→}
+<target>.<expression>
Wherein<and class〉be the title of each class in the path,<target〉be target class,<expression〉be goal expression, it can be based on any expression formula of target class attribute.For example, the last note path expression of striding the class inquiry can be expressed as:
Document → student → video.
*Document → student → photograph album.
*
3. path expression calculates
Object broker data base querying processing module is inquired about thereby realize striding class by path expression is calculated.When the calculating path expression formula, the database dependence is striden the given path expression of class querying command and is navigated, and follows the trail of inquiry according to the bidirectional pointer between object.Its concrete steps are:
(1) correctness of inspection path expression.Have such relation between correctness requirement all classes that the path experienced of path expression, promptly have direct agent relation between former and later two classes, perhaps previous class is the proxy class of a back class, the source class that perhaps previous class is a back class.In addition, the goal expression of path expression is based on a calculation expression of the attribute of path target class.
(2) each object in the scanning initial classes, navigation according to path expression, set out by it, bidirectional pointer connects between the object of safeguarding according to Database Systems, between all related classes of path expression, search the object that has the agent relation mutually according to the depth-first traversal algorithm, up to the related object that finds on the target class.
The expression of path expression is two-way, promptly can be from source class inquiry proxy class, and also can be by the proxy class query source class of setting out.For former and later two classes in the path expression class.path, if their agent relation is selection, merging or connecting-type agent relation, set out by an object in the previous class so, can only inquire an object of a back class of its correspondence, promptly the relation between object is man-to-man relation; If their agent relation is the packet-type agent relation, and previous class is the packet-type proxy class of a back class, set out by an object in the previous class so, will inquire a plurality of objects of a back class of its correspondence, promptly the relation between object is the relation of one-to-many.When running into latter event, after finding all objects of a back class, will select to set out by one of them object, proceed inquiry along class.path, up to finding the object that belongs in the target class; Date back to such afterwards again, get next object, continue the query processing process for calculating.
(3) for the object on the above-mentioned target class that finds, use the goal expression of path expression, according to database expression formula computing method, goal expression is calculated, and finally return result of calculation.