Structured query optimization system and method for relational corpus database
By constructing a layer graph and optimizing the query path, the problems of zero inflation and heavy-tailed features in cross-layer queries of relational corpus databases were solved, achieving efficient and stable cross-layer query optimization and improving query efficiency and system performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- YUNNAN NORMAL UNIV
- Filing Date
- 2026-05-18
- Publication Date
- 2026-06-16
AI Technical Summary
Cross-layer structured queries in relational corpora face the characteristics of zero inflation and heavy tails, which traditional query optimizers cannot identify, leading to incorrect cardinality estimation, abnormal inflation of intermediate results, consumption of computing resources and storage overhead, and reduced query efficiency.
Construct a layer graph, calculate anchor point scores based on local selection rate and average outward expansion, obtain anchor point candidate set, expand prefix connection results, calculate projected successor, obtain zero expansion rate and positive value set, construct layer depth cardinality function, identify critical layer depth through second-order difference, perform prefix contraction and suffix expansion, and optimize query path.
By accurately identifying zero-inflation and heavy-tailed features, the query path is optimized, computational resources and storage overhead are reduced, cross-layer query efficiency is improved, system stability is ensured, and the need for efficient retrieval of multi-type related corpora in language research is met.
Smart Images

Figure CN122220375A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data query optimization technology, and more specifically, to a structured query optimization system and method for relational corpus databases. Background Technology
[0002] Relational corpus databases are widely used in language research. They store corpus data through a multi-level storage structure. For example, the Karen language digitized corpus includes multiple relational layers such as vocabulary, sentence, text, dialogue, and proverb layers. Each layer is linked through fields such as primary keys and collection numbers, supporting cross-layer structured queries of corpora in multiple formats, including text, audio, and video. These databases need to meet users' multi-dimensional query needs, such as associating vocabulary with corresponding grammatical examples and retrieving multiple types of corpora from specific collection batches. Cross-layer queries have become a core application scenario.
[0003] However, the multi-level nature of relational corpora and the unique characteristics of corpus data present significant technical challenges for cross-level structured queries. Corpus data exhibits uncertainties in morpheme segmentation, cross-level alignment mismatches, and multiple annotations within the same unit. This results in vastly different cross-level fan-out behaviors for records at different anchor points. Some anchor points lack corresponding deep-level records, exhibiting zero inflation, while a few anchor points suffer from heavy-tailed characteristics due to multiple annotations and the disassembly of composite labels. Traditional query optimizers rely solely on global average fan-out or single-level selectivity to estimate cardinality, failing to recognize this fan-out distortion characterized by both zero inflation and heavy tails. This leads to incorrect cardinality estimation and consequently, unreasonable join order planning.
[0004] Incorrect cardinality estimation can directly lead to an abnormally large number of intermediate results during query execution, consuming significant computational and storage resources and reducing query efficiency. For example, in the Karen language corpus, when retrieving vocabulary and corresponding grammatical examples from a specific batch of data, traditional optimizers may misjudge the fan-out size and prematurely connect to high-risk paths, resulting in a number of intermediate results far exceeding the actual requirement. This not only prolongs query response time but may also degrade system performance, failing to meet the practical needs of efficient retrieval of multi-type related corpora in language research. Summary of the Invention
[0005] This invention provides a structured query optimization system and method for relational corpus databases, solving the technical problems mentioned in the background.
[0006] This invention provides a structured query optimization system for relational corpus databases, comprising:
[0007] The first module constructs a layer diagram, calculates anchor point scores based on local selectivity and average outward expansion, takes the relationship layer corresponding to the minimum anchor point score as the anchor point layer and defines the layer depth.
[0008] The second module obtains the candidate set of anchor points, expands the prefix connection results, and calculates the projected successor number at each depth.
[0009] The third module obtains the zero expansion rate and the set of positive values based on the projected successor, and constructs the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values.
[0010] The fourth module obtains the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. The maximum logarithmic base curvature is extracted as the critical layer depth. The suffix risk size is constructed by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth.
[0011] The fifth module retains the primary key of the anchor layer and the primary key of the current layer before the critical layer depth, performs prefix shrinkage, generates prefix compression results, and extracts the anchor survival set;
[0012] The sixth module intersects the anchor survival sets of each path to obtain a global set of survivable anchor points. The prefix compression result is then filtered into the global set of survivable anchor points using a left half connection to complete the anchor point intersection.
[0013] The seventh module sorts the suffix risk sizes from smallest to largest and performs suffix expansion sequentially across the critical layer depth to obtain the final state result;
[0014] The eighth module connects the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval payload field, the payload is retrieved and the final query result is output.
[0015] This invention provides a structured query optimization method for relational corpus databases, comprising the following steps:
[0016] Step S1: Construct a layer diagram. Calculate the anchor point score based on the local selection rate and the average outward expansion. Take the relationship layer corresponding to the minimum anchor point score as the anchor point layer and define the layer depth.
[0017] Step S2: Obtain the anchor point candidate set, expand the prefix connection results, and calculate the projected successor number at each depth.
[0018] Step S3: Obtain the zero inflation rate and the set of positive values based on the projected successor, and construct the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values.
[0019] Step S4: Obtain the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. Extract the point with the maximum logarithmic base curvature as the critical layer depth. Construct the suffix risk size by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth.
[0020] Step S5: Before the critical layer depth, retain the anchor layer primary key and the current layer primary key, perform prefix shrinkage, generate prefix compression results, and extract the anchor point live set;
[0021] Step S6: Find the intersection of the anchor point survival sets of each path to obtain the global survivable anchor point set. Use the left half connection to filter the prefix compression result into the global survivable anchor point set to complete the anchor point intersection.
[0022] Step S7: Sort the suffix risk sizes from smallest to largest, and perform suffix expansion sequentially across the critical layer depth to obtain the final state result;
[0023] Step S8: Connect the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval load field, complete the load retrieval and output the final query result.
[0024] The beneficial effects of this invention are as follows: By constructing a layer graph and selecting suitable anchor layers, combined with projection-followed quantification of cross-layer fan-out features, this invention captures the zero inflation and heavy-tailed characteristics of corpus data. The constructed layer depth cardinality function can better fit the cardinality changes in actual query scenarios. Critical layer depth identification and prefix contraction effectively simplify invalid anchor data, and suffix risk size sorting optimizes the path execution order. It avoids the abnormal inflation of intermediate results caused by cardinality estimation bias in traditional query optimization, reduces computational resources and storage overhead, and makes cross-layer query execution more orderly. It adapts to the multi-level structure of relational corpus databases and the special characteristics of corpus data, can stably support cross-layer related queries of multiple types of corpora, improve query response efficiency, ensure system stability, and meet the actual needs of efficient retrieval of related corpora in language research. Attached Figure Description
[0025] Figure 1 This is a flowchart of the structured query optimization method for relational corpus databases according to the present invention. Detailed Implementation
[0026] The subject matter described herein will now be discussed with reference to exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and implement the subject matter described herein, and changes may be made to the function and arrangement of the elements discussed without departing from the scope of this specification. Various processes or components may be omitted, substituted, or added as needed in the examples. Furthermore, features described in some examples may be combined in other examples.
[0027] It should be noted that, unless otherwise defined, the technical or scientific terms used in one or more embodiments of the present invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in one or more embodiments of the present invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" indicate that the element or object preceding the term encompasses the elements or objects listed following the term and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0028] like Figure 1 As shown, a structured query optimization system for relational corpus databases includes:
[0029] The first module constructs a layer diagram, calculates anchor point scores based on local selectivity and average outward expansion, takes the relationship layer corresponding to the minimum anchor point score as the anchor point layer and defines the layer depth.
[0030] The second module obtains the candidate set of anchor points, expands the prefix connection results, and calculates the projected successor number at each depth.
[0031] The third module obtains the zero expansion rate and the set of positive values based on the projected successor, and constructs the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values.
[0032] The fourth module obtains the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. The maximum logarithmic base curvature is extracted as the critical layer depth. The suffix risk size is constructed by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth.
[0033] The fifth module retains the primary key of the anchor layer and the primary key of the current layer before the critical layer depth, performs prefix shrinkage, generates prefix compression results, and extracts the anchor survival set;
[0034] The sixth module intersects the anchor survival sets of each path to obtain a global set of survivable anchor points. The prefix compression result is then filtered into the global set of survivable anchor points using a left half connection to complete the anchor point intersection.
[0035] The seventh module sorts the suffix risk sizes from smallest to largest and performs suffix expansion sequentially across the critical layer depth to obtain the final state result;
[0036] The eighth module connects the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval payload field, the payload is retrieved and the final query result is output.
[0037] In one embodiment of the present invention, a layer diagram is constructed, and anchor point scores are calculated based on local selectivity and average outward expansion. The relationship layer corresponding to the minimum anchor point score is taken as the anchor point layer, and the layer depth is defined, including:
[0038] Construction layer diagram , where the vertex set Each vertex in One-to-one correspondence to one relationship layer and relation layer Local predicates on Binding, edge collection Each edge in One-to-one correspondence layer With relation layer Connection conditions between ;
[0039] Calculate the local selectivity The calculation formula is: ;
[0040] in For the first A relational layer, Relationship layer The total number of records, To be applied to the relation layer Local predicates, For relational layer Apply local predicates The obtained screening results The number of records in the filter results. For local selectivity;
[0041] Calculate the average outward expansion The calculation formula is: ;
[0042] in From the vertex The starting edge set, For the set of edges The number of elements, For layer diagram From the apex Pointing to the vertex The edge, For the edge The corresponding connection conditions, In connection conditions Lower Relationship Layer With relation layer The connection result, The number of records in the join result. The average outward expansion;
[0043] Calculate anchor point score And select the anchor point layer Anchor point rating The calculation formula is:
[0044] ;
[0045] in For local selectivity, For average outward expansion, Scoring of anchor points; anchor point layer The selected formula is: ;
[0046] in To make anchor point scoring The rule for determining the index of the minimum value. For anchor point layer;
[0047] Define layer depth The calculation formula is: ;
[0048] in For anchor point layer, For layer diagram Any vertex in the middle, In the layer diagram From the vertex To the top The shortest path length is the number of edges contained in the path. For layer depth.
[0049] It should be noted that a relation layer is a dataset storing different levels of language materials in a relational corpus database, reflecting the hierarchical storage structure of the corpus data. This can be obtained by retrieving the database table structure and data classification labels. Local predicates are filtering conditions applied to a single relation layer, reflecting the data filtering needs for a specific relation layer. The preferred values are constraints based on corpus attributes, including batch restrictions, speaker restrictions, and corpus type restrictions, adapting to the structured query scenarios of relational corpus databases and matching the inherent attributes of the corpus data. Join conditions are matching rules that associate different relation layers, reflecting the association logic between relation layers. This can be obtained by parsing the foreign key relationships and inter-layer alignment relationships in the relational corpus database. The number of filtered result records is the number of records remaining after applying local predicates to the relation layer. The total number of records in a relation layer is the initial total number of records contained in a single relation layer, which can be obtained by counting the number of rows in the corresponding relation layer's table in the relational corpus database. The local selection rate is the ratio of the number of filtered result records to the total number of records in the relation layer, reflecting the proportion of records retained in a single relation layer under the action of local predicates. The edge set is the set of all edges originating from a single vertex in the layer graph. The number of connection result records is the number of records obtained after associating a single relation layer with connected relation layers according to the connection conditions, reflecting the scale of the association matching results between the two relation layers. The outward connection ratio is the ratio of the number of connection result records to the total number of records in the relation layer, reflecting the degree of association expansion between a single relation layer and a connected relation layer. The average outward expansion is the average of all outward connection ratios of a single relation layer, reflecting the overall expansion degree of a single relation layer in associating with other relation layers. The anchor score is the product of the local selectivity and the average outward expansion, reflecting the comprehensive suitability of a single relation layer as an anchor layer. The anchor layer is the relation layer with the lowest anchor score, reflecting the starting baseline level for the entire structured query optimization. The shortest path length is the number of edges contained in the path between any vertex in the layer graph and the corresponding vertex in the anchor layer, reflecting the hierarchical distance between different relation layers and the anchor layer in the layer graph. The layer depth is the shortest path length corresponding to any vertex in the layer graph, reflecting the hierarchical depth of any relation layer relative to the anchor layer.
[0050] It should be noted that the specific conversion rules and implementation methods for converting structured queries into layered graphs are as follows: First, parse all relation layers in the structured query and create a layered graph vertex for each relation layer; then, bind the local predicates applied to the corresponding relation layer in the query to each vertex; next, parse the connection conditions that associate different relation layers in the query and create a layered graph edge for each set of connection conditions, with the two ends of the edge being vertices of the corresponding relation layers; finally, integrate all vertices and edges to form a complete layered graph. For example, if a structured query requires limiting the batch of word layer data collection and the speaker layer at the morpheme layer, and associating the word layer and morpheme layer by primary key, then when converting the layered graph, create two vertices for the word layer and morpheme layer, bind the corresponding local predicates to them respectively, and then create an edge connecting the two vertices, with the edge corresponding to the connection condition associated by the primary key. The specific filtering operation rules for using local predicates to filter relation layers are as follows: convert the limiting conditions of the local predicates into query statements for relational databases, execute the query statements on the database tables corresponding to the relation layers; traverse each record in the database tables, determine whether the record meets the limiting conditions of the local predicates, retain records that meet the conditions, and discard records that do not meet the conditions; the final retained records are the filtering results. The specific join operation for calculating the number of records in the connection results between relation layers is an inner join operation. Using the join condition as the matching rule, the database tables corresponding to the two relation layers are associated. Each record in the first relation layer is traversed, and records matching the join condition are searched in the second relation layer. A new connection record is generated for each matching record. The total number of newly generated connection records is the number of connection results. The specific algorithm for determining the shortest path length between any vertex in the layer graph and the anchor layer is a breadth-first search algorithm. Starting from the vertex corresponding to the anchor layer, other vertices in the layer graph are traversed layer by layer. The number of edges in the path from the anchor layer vertex to each traversed vertex is recorded. The number of edges when a vertex is first traversed is the shortest path length between that vertex and the anchor layer vertex. For example, if the anchor layer vertex is V0, the breadth-first search first traverses V1 and V2, which are directly connected to V0, with 1 edge; then it traverses V3, which is connected to V1, and V4, which is connected to V2, with 2 edges; therefore, the shortest path length for V3 is 2.
[0051] It should be noted that the selection criteria for anchor layers are not based solely on local selectivity or average outward expansion. Instead, the two parameters are multiplied to obtain an anchor score, and the suitability of the anchor layer is determined by the magnitude of the anchor score. The smaller the anchor score, the better the filtering effect of the relationship layer and the lower its outward expansion, making it more suitable as an anchor layer. The layer depth of each vertex in the layer graph is uniquely determined by the shortest path length between that vertex and the corresponding vertex of the anchor layer. The value of the shortest path length is the value of the layer depth. The shortest path length of the vertex corresponding to the anchor layer is 0, and its layer depth is 0. The shortest path length of the vertex directly connected to the anchor layer is 1, and its layer depth is 1. This invention addresses the hierarchical characteristics of cross-layer queries in relational corpora. It transforms structured queries into a visualized hierarchical structure by constructing a layer graph. Then, it quantifies the local selectivity rate to reflect the filtering capability of a single relation layer and the average outward expansion rate to reflect the outward expansion risk of a single relation layer. These two are coupled into an anchor point score to select the optimal anchor layer. Simultaneously, it defines layer depth to clarify the hierarchical distance between each relation layer and the anchor layer. This makes the hierarchical relationship logic of structured queries clearer, providing a stable starting point for subsequent query optimization. By comprehensively considering filtering capability and expansion risk, the anchor layer selection avoids benchmark bias caused by selecting a single parameter. The explicit definition of layer depth provides a unified measurement standard for subsequent quantitative analysis related to layer depth, ensuring a consistent basis for determining the hierarchical dimensions of the entire query optimization process. The quantitative calculation of each parameter is based on the inherent attributes of the database and query conditions, adapting to the structured query scenarios of relational corpora, making the selection of anchor layers and the definition of layer depth more aligned with actual query needs.
[0052] In one embodiment of the present invention, obtaining a candidate set of anchor points and calculating the projected successor number at each depth by expanding the prefix connection results includes:
[0053] Get anchor point candidate set The calculation formula is:
[0054] ;
[0055] in For anchor point layer The corresponding relationship layer, To be applied to the relation layer Local predicates, To filter the results, For anchor point layer Correspondence layer Primary key field, To perform projection operations that only retain the primary key field, For the anchor point candidate set;
[0056] Expanding prefix join results For layer diagrams Mid-target vertex Construct the shortest path vertex sequence with shortest path length :
[0057] ;
[0058] in This refers to the starting vertex corresponding to the anchor point layer. The shortest path length; for any depth satisfy Construct the prefix connection result The calculation formula is:
[0059] ;
[0060] in Shortest path vertex sequence The Middle The relation layer corresponding to each vertex As a local predicate, As a connection condition, For join operations, This is the result of prefix concatenation;
[0061] Calculate the projection successor at each depth. The calculation formula is:
[0062] ;
[0063] in Anchor candidate set One of the anchor points records the primary key value. For anchor point layer The primary key field corresponding to the relationship layer, To filter records where the primary key field equals the anchor key value The collection of records, Depth of the shortest path vertex sequence Corresponding vertex The primary key field corresponding to the relationship layer, For projection operations, For counting operations, This is the successor of the projection.
[0064] It should be noted that the anchor candidate set is the set of records after the anchor layer filtering results have been projected and the primary key field has been retained. The primary key field of the anchor layer corresponding to the relation layer is the field that uniquely identifies each record in the anchor layer corresponding to the relation layer, reflecting the unique identification attribute of the anchor layer record. It can be obtained by retrieving the primary key definition information and field identifier of the anchor layer corresponding table in the relational corpus database. The target vertex is the final vertex that the structured query in the layer graph needs to access. The shortest path vertex sequence is a sequence of all vertices on the shortest path from the corresponding vertex of the anchor layer to the target vertex, formed in hierarchical order, reflecting the optimal hierarchical access path for cross-layer queries. Depth is the hierarchical position in the shortest path vertex sequence counted from the anchor layer, reflecting the current hierarchical progress in the cross-layer query process. The prefix join result is the set of records obtained by joining the filtering results of each layer according to the join condition along the shortest path vertex sequence to the specified depth, reflecting the intermediate result of cross-layer association at the specified depth. The primary key value of the anchor record is the specific value of the primary key field of each anchor record in the anchor candidate set, reflecting the unique identification information of a single anchor record. An anchor record is a single record in the anchor candidate set, reflecting a single effective anchor unit participating in subsequent query optimization. The primary key field of the relation layer at the corresponding depth is a unique identifier field of the relation layer at the specified depth in the shortest path vertex sequence, reflecting the unique identification attribute of records in the relation layer at the specified depth. It can be obtained by retrieving the primary key definition information and field identifier of the relation layer table at the corresponding depth in the relational corpus database. The record set is all records in the prefix join result that match the primary key value of the anchor record, reflecting the cross-layer association result of a single anchor record at the specified depth. The projection successor is the number of records in the record set after projection, retaining the primary key field at the specified depth, reflecting the cross-layer fan-out number of a single anchor record at the specified depth.
[0065] It should be noted that the specific implementation of performing projection operations on the filtered results, retaining only the primary key field, adopts the projection operation syntax of relational databases. The primary key field of the relational layer corresponding to the anchor layer is specified as the unique projection column. A column extraction operation is performed on the filtered result dataset, removing all non-primary key columns to generate a one-dimensional dataset containing only the primary key field. This dataset is the anchor candidate set. The specific method for constructing the shortest path vertex sequence from the anchor layer to the target vertex is based on the vertex-edge relationships in the layer graph. A breadth-first search algorithm is used to determine the shortest path from the anchor layer vertices to the target vertex. All vertices on the path are extracted and sorted according to the access order from the anchor layer vertices to the target vertex. The sorted vertex list is the shortest path vertex sequence. Furthermore, a deduplication operation is performed on the dataset containing only the primary key field at the specified depth after the projection operation, removing duplicate primary key values. Then, a row count operation is performed on the deduplicated dataset, and the counted row number is the projection successor.
[0066] It should be noted that the projection operation only extracts the primary key field from the anchor layer filtering results, removing all other attribute fields and retaining only the field that uniquely identifies the anchor record, without retaining any redundant corpus attribute information. The mapping logic for constructing the shortest path vertex sequence from the anchor layer to the target vertex in the layer graph is as follows: starting from the corresponding vertex of the anchor layer in the layer graph and ending at the target vertex, the shortest path between them is first determined, and then the vertices on the path are arranged in hierarchical order from the start to the end, forming an ordered vertex sequence. The order of vertices in the sequence is consistent with the hierarchical order of cross-layer queries. The hierarchical operation logic for performing connection operations along the shortest path vertex sequence to generate prefix connection results is as follows: starting from depth 1, each layer performs a connection operation based on the connection results of the previous depth and the filtering results of the corresponding layer at the current depth, according to the connection conditions. The operation is performed only on vertices within the shortest path vertex sequence, without involving other vertices outside the sequence. The connection results of each layer serve as the basis for the operation of the next layer. This invention determines the effective anchor records for subsequent optimization based on the anchor layer. By constructing a shortest path vertex sequence, it clarifies the optimal hierarchical path for cross-layer queries. Prefix join results are generated layer by layer along this sequence according to the layer depth. Then, the association results are precisely filtered for each individual anchor record, and the projected successor at each layer depth is quantified, providing basic data for subsequent quantitative analysis of layer depth. This makes the effective record range of the anchor layer clearer, retains only the primary key field to reduce data redundancy, avoids invalid cross-layer paths with the shortest path vertex sequence, makes the join operation more in line with query requirements, and the prefix join results are generated according to the layer depth, which can reflect the cross-layer association status of different levels. The projected successor accurately quantifies the cross-layer fan-out characteristics of a single anchor record, providing calculable basic parameters for subsequent analysis of zero inflation and heavy-tailed features.
[0067] In one embodiment of the present invention, a zero inflation rate and a set of positive values are obtained based on the projected successor, and a deep cardinality function is constructed by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values, including:
[0068] Calculate the zero expansion rate The calculation formula is:
[0069] ;
[0070] in For the anchor point candidate set, Anchor candidate set The number of elements, To retrieve the primary key value for the anchor record in the anchor candidate set, For the projected successor, This is an indicator function that takes one if the projected successor is zero and otherwise takes zero. Zero expansion rate;
[0071] Construct a set of positive values ,satisfy:
[0072] ;
[0073] in For the anchor point candidate set, For the projected successor, It is the set of positive values;
[0074] Calculate the logarithmic mean of positive values The calculation formula is:
[0075] ;
[0076] in The set of positive values The number of elements in the set of positive values. This is the result of taking the natural logarithm of the projected successor. The logarithmic mean of positive values;
[0077] Calculate the positive logarithmic variance The calculation formula is:
[0078] ;
[0079] in Let be the natural logarithm of the projected successor. The logarithmic mean of positive values The number of elements in the set of positive values. The variance is a positive logarithm.
[0080] Constructing deep cardinality function The calculation formula is:
[0081] ;
[0082] in The number of elements in the anchor candidate set. With zero expansion rate, The proportion of surviving anchor points. The logarithmic mean of positive values The variance is a positive logarithm. For exponential operations, This is the layer depth cardinality function.
[0083] It should be noted that the zero inflation rate is the ratio of the number of anchor records with a projected successor of zero to the number of elements in the anchor candidate set, reflecting the distribution characteristics of the zero-value projected successors in the anchor candidate set at a specified depth. The indicator function is a function used to determine whether the projected successor is zero. The number of anchor records with a projected successor of zero is the total number of anchor records with a projected successor of zero in the anchor candidate set, reflecting the scale of anchor records without cross-layer fanout at a specified depth. The number of elements in the anchor candidate set is the total number of anchor records contained in the anchor candidate set. The positive value set is the set of primary key values of anchor records with a projected successor greater than zero in the anchor candidate set, reflecting the range of anchor records with cross-layer fanout at a specified depth. The positive value logarithmic mean is the ratio of the sum of the natural logarithms of the projected successors in the positive value set to the number of elements in the positive value set, reflecting the average distribution level of the positive value projected successors on a logarithmic scale. The sum of the natural logarithms of the projected successors is the sum of the natural logarithms of the projected successors of all anchor records in the positive value set, reflecting the cumulative scale of the positive value projected successors after logarithmic transformation. The number of elements in the positive value set is the total number of primary key values for the anchor records included in the positive value set, reflecting the scale of anchor records with cross-layer fanout at a specified depth. The positive value logarithmic variance is the ratio of the sum of squared differences between the natural logarithms of the projected successors and the mean of the positive value logarithms in the positive value set to the number of elements in the positive value set, reflecting the discrete distribution characteristics of the positive value projected successors on a logarithmic scale. The depth cardinality function is the product of the number of elements in the anchor candidate set, the proportion of surviving anchors, and the positive value projection scale, reflecting the quantitative characteristics of the scale of cross-layer query results at a specified depth. The proportion of surviving anchors is a value minus the zero inflation rate, reflecting the proportion of anchor records with cross-layer fanout at a specified depth in the anchor candidate set. The positive projection scale is the result of the sum of the positive logarithmic mean and half the positive logarithmic variance, after exponential operation, reflecting the average cross-layer fan-out scale of the positive anchor point records at a specified layer depth.
[0084] It should be noted that the indicator function assigns a value of 1 to anchor records with a projection successor of zero and a value of 0 to anchor records with a projection successor greater than zero. The sum of the indicator function assignments of all anchor records in the anchor candidate set is the number of anchor records with a projection successor of zero. This value is then divided by the number of elements in the anchor candidate set to obtain the zero inflation rate. This invention addresses the zero inflation and heavy-tailed characteristics of projected successors in relational corpora. It splits the anchor candidate set into zero-value and positive-value parts based on the projected successor. The zero inflation rate quantifies the distribution characteristics of zero values, while natural logarithmic processing of the positive value part weakens the impact of extreme values caused by heavy tails. Furthermore, the distribution characteristics of the positive value part are quantified using the logarithmic mean and variance of the positive values. Finally, a multi-parameter layer depth cardinality function is constructed to quantify the scale of query results at a specified layer depth. Splitting the zero-value and positive-value parts avoids interference from zero values in the overall scale quantification. Natural logarithmic processing reduces the pull of extreme large values on the mean, making the numerical statistics more closely resemble the actual distribution. The layer depth cardinality function integrates the basic scale, effective proportion, and average fan-out scale, accurately quantifying the result scale at a specific layer depth. This provides a reliable quantitative basis for subsequent curvature calculations and critical layer depth identification. All operations are basic numerical operations, adaptable to corpus data analysis scenarios, and easy to implement.
[0085] In one embodiment of the present invention, the logarithmic cardinal curvature is obtained by taking the logarithm of the layer depth cardinal function and performing second-order difference. The point with the maximum logarithmic cardinal curvature is extracted as the critical layer depth. The suffix risk dimension is constructed by combining the cumulative value of the positive logarithmic cardinal curvature after the critical layer depth, including:
[0086] Calculate the logarithmic deep cardinal function The calculation formula is: ;
[0087] in For layer depth cardinality function, For natural logarithm operations, It is a logarithmic deep cardinal function;
[0088] Calculate the base curvature of the logarithm In order to satisfy The calculation formula within the range is:
[0089] ;
[0090] in The shortest path length from the anchor point layer to the target vertex. , as well as These are the logarithmic depth cardinal function values for adjacent layer depths, respectively. The base-log curvature;
[0091] Extracting critical layer depth The selection rules are as follows: ;
[0092] in To select the logarithmic base curvature within a limited layer depth range The rule for determining the value of the independent variable that takes the maximum value. The critical layer depth;
[0093] Constructing suffix burst volume The calculation formula is: ;
[0094] in This is the critical layer depth. To accumulate the final layer depth, To retain only the positive values of the logarithmic cardinal curvature, The burst volume is a suffix.
[0095] Constructing suffix risk size The calculation formula is: ;
[0096] in The depth cardinality function at the final state depth The value at that location, For the natural constant Exponential operations with base 0. For the burst volume of the suffix, This is a suffix indicating a risk dimension.
[0097] It should be noted that the logarithmic depth cardinality function is the result of performing the natural logarithmic operation on the depth cardinality function, reflecting the quantitative characteristics of the depth cardinality on a logarithmic scale. The logarithmic cardinality curvature is the value obtained by performing a second-order difference operation on the logarithmic depth cardinality function values of three adjacent layers, reflecting the changing characteristics of the growth rate of the depth cardinality. The current depth is the target depth within the depth range currently participating in curvature calculation. The critical depth corresponds to the depth with the largest curvature value in the set of logarithmic cardinality curvatures, reflecting the inflection point at which the scale of cross-layer query results shifts from controllable to explosive. The suffix burst is the sum of all positive logarithmic cardinality curvatures within the layer from the critical depth to the layer before the final state depth, reflecting the cumulative explosive degree of cardinality growth after the critical depth. The final state depth is the depth corresponding to the target vertex in the shortest path vertex sequence, reflecting the final level position of the cross-layer query. The cumulative interval is the depth range from the critical depth to the end of the layer before the final state depth, reflecting the calculation level range of the suffix burst. The suffix risk size is the product of the function value deep within the final state layer and the result of the suffix burst exponent calculation, reflecting the overall risk level of the suffix segment in cross-layer queries. The function value deep within the final state layer is the specific value of the layer depth cardinal function at the depth of the final state layer, reflecting the basic value of the result scale of cross-layer queries up to the final level.
[0098] It should be noted that the natural logarithm is performed only on all depth values of the depth-cardinality function, preserving the correspondence between depth and cardinality without altering the distribution of depth dimensions. Only the linear scale of cardinality is converted to a logarithmic scale, weakening the impact of extreme values on the growth trend of cardinality and making changes in the growth trend easier to identify. The magnitude of the logarithmic cardinality curvature is used as the criterion for determining the degree of growth acceleration; a larger curvature indicates a higher degree of acceleration in cardinality growth at that depth. This depth represents the critical inflection point where the query result scale shifts from stable growth to rapid explosion. Only the depth corresponding to the global maximum value is selected, ignoring local maxima. The function value at the final state depth is used as the base scale of the suffix segment, and the exponential result of the suffix explosion is used as the explosion risk coefficient. Multiplying the base scale by the risk coefficient comprehensively reflects the base scale plus the explosion degree of the suffix segment. This coupling allows the risk dimension to simultaneously reflect the result scale and growth risk. This invention addresses the scale growth characteristics of cross-layer queries in relational corpora. It transforms the layer depth cardinality function into a logarithmic scale to mitigate the impact of extreme values. Second-order differencing is used to obtain the logarithmic cardinality curvature, identifying the critical layer depth at which cardinality growth accelerates. The positive curvature after accumulating the critical layer depth is then used to obtain the suffix burst. Finally, the risk coefficient of the final-state layer depth cardinality scale and the burst are coupled to construct the suffix risk dimension, quantifying the risk of query suffix segments. The logarithmic transformation makes the cardinality growth trend easier to identify, the second-order differencing directly reflects changes in the growth rate, the extraction of the critical layer depth clarifies the hierarchical inflection point of query scale bursts, and the suffix burst only accumulates the positive curvature, accurately reflecting the cumulative acceleration of suffix segments. The suffix risk dimension integrates the basic scale and burst risk, providing a quantitative basis for subsequent path ranking. All operations are based on basic numerical transformations and differencing, making it easy to implement and suitable for cross-layer query risk analysis scenarios in corpora.
[0099] In one embodiment of the present invention, prefix shrinkage is performed while retaining the anchor layer primary key and the current layer primary key before the critical layer depth, generating a prefix compression result and extracting the anchor point live set, including:
[0100] Initialize prefix compression results The calculation formula is: ;
[0101] in For anchor point layer The corresponding relationship layer, To be applied to the relation layer Local predicates, For relational layer Apply local predicates The obtained screening results For anchor point layer The primary key field corresponding to the relationship layer, To keep only the fields Projection operation, To initialize the prefix compression result;
[0102] In satisfying Prefix compression results are generated recursively within the layer depth range. The calculation formula is: ;
[0103] in This is the critical layer depth. For the current layer depth of the recursion, Shortest path vertex sequence The One vertex, As vertices The corresponding relationship layer, To be applied to the relation layer Local predicates, To filter the results, This is the connection condition between adjacent vertices on the path. This is the prefix compression result for the previous unit depth. For join operations, As vertices The primary key field corresponding to the relationship layer, To keep only the fields With fields Projection operation, For layer depth The prefix compression result below;
[0104] Extracting anchor point live set The calculation formula is: ;
[0105] in This represents the prefix compression result at a depth of one unit layer before the critical layer depth. For projection operations, This is the set of anchor points that survive the path up to the critical depth.
[0106] It should be noted that the initial prefix compression result is the set of records after the anchor layer filtering result is projected, retaining only the anchor layer primary key field, reflecting the initial data foundation of the prefix contraction stage. The prefix compression result is the set of records at each depth before the critical depth, after concatenating the compression result of the previous unit depth with the current layer filtering result, retaining only the double primary key field, reflecting the intermediate data state of prefix contraction at the corresponding depth. The critical depth minus one is the previous adjacent depth of the critical depth, reflecting the final depth position of the prefix contraction stage. The current layer filtering result is the set of filtered records obtained by applying local predicates to the relation layer at the corresponding depth in the shortest path vertex sequence, reflecting the original filtered data at the corresponding depth. The prefix compression result of the previous unit depth is the prefix compression result generated at the previous adjacent depth of the current depth, reflecting the preceding data foundation for prefix contraction at the current depth.
[0107] It should be noted that the specific projection operation implementation method for generating the initial prefix compression result adopts the projection operation syntax of relational databases. The primary key field of the relational layer corresponding to the anchor layer is specified as the unique projection column. After applying a local predicate to the anchor layer, a column extraction operation is performed on the filtering results to remove all non-primary key columns, generating a one-dimensional dataset containing only the primary key field of the anchor layer. This dataset is the initial prefix compression result. The specific rule for recursively generating the prefix compression result before determining the critical layer depth is as follows: extract the identified critical layer depth value, subtract 1 from this value to obtain the termination layer depth, the initial layer depth is fixed at 1, and the final recursive layer depth range is a continuous integer layer depth from 1 to the critical layer depth minus one. If the critical layer depth is 1, there is no recursive layer depth range, and the initial result is used directly as the basis. The specific operation of joining the prefix compression result of the previous unit depth with the current layer's filtered result according to the join condition is as follows: An inner join operation is used, with the join condition between the current layer's corresponding relationship layer and the previous layer's relationship layer as the matching rule. The prefix compression result of the previous unit depth is used as the left table, and the current layer's filtered result is used as the right table. The join operation is performed, retaining only records from both tables that meet the join condition, forming the join result. Immediately after the join operation, a projection operation is performed. The primary key fields of the anchor layer and the current layer's corresponding relationship layer are explicitly specified in the projection syntax as the only retained columns. Column extraction is performed on the join result according to this specification, removing all unspecified columns, generating a record set containing only dual primary keys.
[0108] It should be noted that this invention addresses the issue of query results being prone to bursts after reaching a critical layer depth. It performs prefix contraction in the safe segment before the critical layer depth, retaining only the primary key fields necessary for cross-layer association. Prefix compression results for each layer depth are generated through hierarchical recursion. Finally, effective anchor points are extracted from the compression results one level below the critical layer depth to form an anchor point survival set. This ensures that subsequent high-risk segments only process data from effective anchor points. Retaining only primary key fields significantly reduces data load and avoids redundant fields consuming computational resources. The hierarchical recursive compression method continuously simplifies data at each layer. The anchor point survival set filters out effective anchor points capable of completing cross-layer associations before the critical layer depth, eliminating invalid anchor points to prevent them from entering subsequent high-risk segments and causing unnecessary expansion. The range of prefix contraction strictly matches the critical layer depth, making data compression more targeted. All operations are based on database-level projection and join operations, adapting to the risk control requirements of cross-layer queries in corpora.
[0109] In one embodiment of the present invention, the intersection of the anchor survival sets of each path is obtained to obtain a global set of survivable anchor points. The prefix compression result is then filtered into the global set of survivable anchor points using a left-hand join to complete the anchor point intersection, including:
[0110] Calculate the global set of survivable anchor points The calculation formula is: ;
[0111] in For each target vertex The corresponding path's anchor point survival set before the critical layer depth, For intersection operations, This is the set of globally viable anchor points.
[0112] Calculate the prefix compression result after anchor point intersection The calculation formula is:
[0113] ;
[0114] in For prefix compression results, This is the set of globally viable anchor points. For anchor point layer The primary key field corresponding to the relationship layer, This is a left-hand join operation performed on the primary key field. This is the prefix compression result after the anchor points intersect.
[0115] It should be noted that the global survivable anchor set is the set of anchor records obtained by intersecting the survivable anchor sets of all paths. It reflects the range of globally effective anchors that can complete cross-layer associations before the critical layer depth of all paths in a multi-path query scenario. The prefix compression result after anchor intersection is the set of records after filtering the prefix compression results of each path to the global survivable anchor set via a left-half join. This reflects the prefix compression data status of each path based on globally effective anchors. The intersection operation only retains anchor records that exist in all path anchor survivable sets, removing anchor records that exist only in a single or partial path. The global survivable anchor set is a common subset of all path anchor survivable sets, ensuring that anchors within this set can complete cross-layer associations before the critical layer depth of all paths. The specific matching rule for the left-half join filtering based on the anchor layer primary key field is an equality matching rule. The anchor layer primary key field of the prefix compression result in the left table is compared with the anchor layer primary key field of the global survivable anchor set in the right table. A match is considered successful only if the two fields have identical values; otherwise, the match fails. There are no fuzzy or partial matching rules. The specific operation of performing a left-half join on the single-path prefix compression result using the global survivable anchor set is as follows: the prefix compression result of that path is used as the left table, and the global survivable anchor set is used as the right table. The join field of both tables is specified as the primary key field of the corresponding relationship layer in the anchor layer. The left-half join operation is performed, and only records in the left table that successfully match the right table are retained, while records that fail to match are removed, generating a new record set. The left-half join filtering operation is performed sequentially on the prefix compression result of each path, in ascending order of suffix risk size. After filtering one path, the filtering of the next path is performed until all paths have completed anchor point intersection. Furthermore, the dataset of the prefix compression result after anchor point convergence is specifically represented in the form of a two-dimensional record table. The table contains only two fields: the primary key field of the relationship layer corresponding to the anchor point layer and the primary key field of the relationship layer corresponding to the depth of the path. Each record in the table is a unique combination of dual primary key values, with no other attribute fields and no duplicate records.
[0116] It should be noted that this invention addresses the issue of differing anchor survival sets across paths in multi-path query scenarios. By performing an intersection operation on the anchor survival sets of all paths, a globally viable anchor set acceptable to all paths is obtained. This set is then used as a unified filtering condition, and the prefix compression results of each path are filtered through a left-hand join, completing the anchor convergence across multiple paths. This ensures that subsequent high-risk segments only process globally valid anchor data. The intersection operation eliminates anchors that are only valid in a single path or a subset of paths, ensuring that global anchors can complete cross-layer associations before the critical depth of all paths. The left-hand join filtering only reduces the number of records without changing the original field structure, preserving the results of prefix compression. The unified global anchors ensure that the basic data for subsequent multi-path operations remains consistent, reducing deviations in multi-path collaborative operations. The anchor convergence operation is based on set operations and left-hand joins, adapting to the operational logic of relational databases and fitting the actual scenario of multi-path corpus queries.
[0117] In one embodiment of the present invention, suffix expansion is performed sequentially across the critical layer depth, sorted by suffix risk size from smallest to largest, to obtain the final state result, including:
[0118] The path processing order is determined by the suffix risk size from smallest to largest, resulting in the target vertex sequence. satisfy:
[0119] ;
[0120] in For the target vertex The corresponding suffix risk size, The total number of target vertices. This is the sequence of target vertices, used to determine the order of path processing.
[0121] For each sorted target vertex, generate a critical depth result across the critical depth. The calculation formula is:
[0122] ;
[0123] in For the corresponding target vertex The critical layer depth, This is the prefix compression result after anchor point intersection. To determine the correspondence between the critical layer and the deep layer Apply local predicates The screening results As a connection condition, To retain only the primary key field and Projection operation, Results for critical layer depth;
[0124] Perform postfix expansion after the critical depth to obtain the final state result. In order to satisfy The recursive formula within the depth range is:
[0125] ;
[0126] in The shortest path length. For the current layer depth, This is the result of the previous unit depth. As a connection condition, The current layer's filtering results. For projection operations; when At that time, output the final state result. .
[0127] It should be noted that the path processing order is determined by the multi-path execution order based on the suffix risk size from smallest to largest. The target vertex sequence is the result of sorting the target vertices by suffix risk size from smallest to largest, reflecting the target vertex relationships corresponding to the path processing order. The final result is a set of records containing only dual primary keys generated after suffix expansion recursively to the shortest path length, reflecting the final key-level data result of a single-path cross-layer query to the target vertex. Multi-path processing prioritizes paths with smaller suffix risk sizes, completing the critical traversal and suffix expansion of low-risk paths first. This avoids high-risk paths entering the computation stage too early, which could lead to abnormal expansion of intermediate results. Computational resources are initially allocated to low-risk paths, gradually processing high-risk paths, thus achieving hierarchical risk control of the suffix segment. The specific operation method for connecting the prefix compression result after anchor point intersection with the critical layer depth screening result according to the connection condition is to use an inner join operation. The prefix compression result after anchor point intersection is used as the left table, and the local predicate screening result of the corresponding relationship layer at the critical layer depth is used as the right table. The preset connection condition between the two layers depths is used as the matching rule, and only records that meet the connection condition in both tables are retained to form the connection result. In addition, the final result is represented in the form of a two-dimensional record table. The table only contains two columns: the primary key field of the anchor layer and the primary key field of the corresponding relationship layer of the target vertex. Each record in the table is a unique combination of double primary key values, with no duplicate records. During generation, a full deduplication is performed on the last layer projection result to ensure the uniqueness of all double primary key combinations and that there is no redundant or duplicate data.
[0128] It should be noted that this invention addresses the high-risk characteristics of suffix segments after reaching a critical depth. It determines the multi-path processing order based on the suffix risk size, from smallest to largest. First, it completes the critical traversal of low-risk paths, generating results at the critical depth. Then, it recursively executes suffix expansion layer by layer according to depth, maintaining the principle of retaining only the two primary keys throughout the process, ultimately obtaining the final result of a single path. Processing paths by risk sorting avoids premature computation of high-risk paths, preventing intermediate result inflation and achieving risk-layered control of suffix segments. The single cross-inflection point computation at the critical depth clearly defines the computational boundaries between safe and high-risk segments. The layer-by-layer recursion of suffix expansion aligns with the hierarchical characteristics of cross-layer queries in corpora. The rule of retaining only the two primary keys continuously reduces data load and computational resource consumption. All operations are based on database join and projection operations, adapting to the structured query scenarios of relational corpora databases, making the suffix expansion execution process more controllable.
[0129] In one embodiment of the present invention, the global set of survivable anchor points is concatenated with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval payload field, payload retrieval is completed and the final query result is output, including:
[0130] Forming core key-level results The calculation formula is:
[0131] ;
[0132] in This is the set of globally viable anchor points. For anchor layer primary key fields, For the first The final state result of the path, The target number of vertices. For core key level results;
[0133] Complete payload retrieval and output the final query results. The calculation formula is:
[0134] ;
[0135] in For core key level results, This is the set of relationships corresponding to the load field retrieved by the key press. Output the set of columns requested by the user. To retain only the projection operations of columns in the user-requested output column set, This is the final query result.
[0136] It should be noted that the core key-level result is the set of records concatenated by the global set of survivable anchor points and the final results of each path according to the anchor-level primary key. This reflects the core primary key association information fused after multi-path cross-layer queries. The key-retrieval payload field is the actual display field associated with the primary keys of each layer in the relational corpus database. It reflects the actual business content of the corpus data and can be obtained by retrieving the association mapping table between the business attribute fields and primary keys of each relation layer in the relational corpus database. The user-requested output column set is the set of fields specified by the user in the structured query to be displayed. It reflects the user's query result display requirements, with priority given to corpus transcription fields, morpheme annotation fields, Gross annotation fields, and collection batch fields. This adapts to the query scenario of the relational corpus database and matches the user's core viewing needs for the corpus data. The final query result is the set of records projected by the user-requested columns after concatenating the core key-level result and the key-retrieval payload field.
[0137] It should be noted that the join operation between the core key-level results and the key-retrieval payload fields employs a multi-field equality matching rule. Each primary key field in the core key-level results is matched against the corresponding primary key field in the key-retrieval payload field relationship set. Only after all primary keys have successfully matched is the corresponding payload field value associated with the core key-level results. The implementation of the projection operation on the join results based on the user-requested output column set, retaining only the target column, uses the projection operation syntax of relational databases. All field names in the user-requested output column set are used as projection columns. Column extraction is performed on the joined dataset, removing all fields not specified in the projection columns and retaining only the specified target columns. The final query result dataset is formatted as a two-dimensional structured table. Each row represents a complete corpus query result, and each column corresponds to a field in the user-requested output column set, with the field order consistent with the user's request order. The validity check rule verifies whether the user-specified required fields are empty. If a required field is empty, the record is removed; if an optional field is empty, it is retained and marked as null.
[0138] It should be noted that this invention addresses the characteristic that all preliminary optimization calculations are based on primary key data. It merges the globally viable anchor set with the multi-path final state results according to the anchor primary key, generating a core key-level result containing only the primary key. Then, it retrieves the payload by associating the primary key with the database payload field. Finally, it projects the result according to the user-requested column, thus decoupling primary key calculations from payload retrieval. The core key-level result integrates multi-path primary key information, ensuring the consistency of multi-path data based on the anchor primary key. Key-value separation ensures that preliminary optimization calculations are always based on lightweight primary key data, reducing computational resource consumption. Payload retrieval uses precise primary key matching to retrieve only valid payload information, avoiding the introduction of invalid data. On-demand projection strictly adheres to user display requirements, eliminating redundant fields. The format standardization and validity verification of the final result make the data more relevant to actual usage scenarios. All operations are based on relational database fundamentals, adapting to the structured query requirements of the corpus, creating a complete closed loop for the entire query process.
[0139] In one embodiment of the present invention, a structured query optimization method for relational corpus databases includes the following steps:
[0140] Step S1: Construct a layer diagram. Calculate the anchor point score based on the local selection rate and the average outward expansion. Take the relationship layer corresponding to the minimum anchor point score as the anchor point layer and define the layer depth.
[0141] Step S2: Obtain the anchor point candidate set, expand the prefix connection results, and calculate the projected successor number at each depth.
[0142] Step S3: Obtain the zero inflation rate and the set of positive values based on the projected successor, and construct the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values.
[0143] Step S4: Obtain the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. Extract the point with the maximum logarithmic base curvature as the critical layer depth. Construct the suffix risk size by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth.
[0144] Step S5: Before the critical layer depth, retain the anchor layer primary key and the current layer primary key, perform prefix shrinkage, generate prefix compression results, and extract the anchor point live set;
[0145] Step S6: Find the intersection of the anchor point survival sets of each path to obtain the global survivable anchor point set. Use the left half connection to filter the prefix compression result into the global survivable anchor point set to complete the anchor point intersection.
[0146] Step S7: Sort the suffix risk sizes from smallest to largest, and perform suffix expansion sequentially across the critical layer depth to obtain the final state result;
[0147] Step S8: Connect the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval load field, complete the load retrieval and output the final query result.
[0148] It should be noted that the deployment of this invention is based on the technical environment of the Karen language digital corpus. This corpus uses MySQL 8.0 as a relational database and is designed with five types of physical tables: vocabulary, sentences, short passages, dialogues, and proverbs. It has built an MVC architecture management platform and a BS-mode online retrieval platform, supporting cross-level relational queries across different corpus tables. The invention's eight functional modules are deployed within this database and retrieval platform. The module's operational logic is adapted to the storage characteristics of the multi-level corpus tables, and it is implemented through the platform's retrieval function. All operations are based on the database's fundamental operations, requiring no additional modifications to the existing corpus architecture. In the Karen language digital corpus construction phase, the field collection, preprocessing, and classification of the Skokaren language were first completed, forming structured multi-level corpus data. The invention then initiated an optimization process based on this structured data. The corpus inputs over 3,000 words into a vocabulary table, over 900 grammatical example sentences into a sentence table, and 189 everyday dialogues into a dialogue table. The tables are linked by collection numbers, and a full-process query optimization was initiated to address the retrieval needs of such cross-table associations.
[0149] Taking the retrieval of daily dialogues corresponding to specific words as an example, the proposed query optimization process is implemented as follows: First, a layer graph is constructed, with the vocabulary layer and dialogue layer as vertices and the association condition of the collection number as edges. The local selection rate and average outward expansion of the two layers are calculated to obtain the anchor point score. The appropriate anchor point layer is selected and the layer depth is defined. Then, the anchor point candidate set is obtained, and the prefix connection results are expanded to calculate the projected successor at each layer depth. Next, the zero expansion rate is statistically calculated based on the projected successor, the positive value set is extracted, and the layer depth cardinality function is constructed in combination with relevant parameters. Subsequently, the logarithmic cardinality curvature is calculated to identify the critical layer depth and construct the suffix risk size. Prefix contraction is performed before the critical layer depth, retaining only the anchor point layer and the primary key of the current layer to generate the compression result, and the anchor point survival set is extracted. Then, the intersection of the anchor point survival sets of each path is obtained to obtain the global survivable anchor point set, and the prefix compression result is filtered by the left half connection. The suffix risk size is sorted from smallest to largest, and suffix expansion is performed sequentially to obtain the final state result. Finally, the global set of survivable anchor points is connected to the final result, and payload fields such as audio and video addresses are retrieved. The query results containing vocabulary content, corresponding dialogues, and audio and video are output according to user requirements.
[0150] It should be noted that the interval and threshold sizes are set for ease of comparison. The size of the threshold depends on the amount of sample data and the base number set by those skilled in the art for each set of sample data, as long as it does not affect the proportional relationship between the parameter and the quantized value. Furthermore, the above formulas are all dimensionless calculations, and the formulas are derived from software simulations using a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0151] The embodiments of this example have been described above. However, this example is not limited to the specific implementation methods described above. The specific implementation methods described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms based on the guidance of this example, and all of them are within the protection scope of this example.
Claims
1. A structured query optimization system for relational corpus databases, characterized in that, include: The first module constructs a layer diagram, calculates anchor point scores based on local selectivity and average outward expansion, takes the relationship layer corresponding to the minimum anchor point score as the anchor point layer and defines the layer depth. The second module obtains the candidate set of anchor points, expands the prefix connection results, and calculates the projected successor number at each depth. The third module obtains the zero inflation rate and the set of positive values based on the projected successor, and constructs the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values. The fourth module obtains the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. The maximum logarithmic base curvature is extracted as the critical layer depth. The suffix risk size is constructed by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth. The fifth module retains the primary key of the anchor layer and the primary key of the current layer before the critical layer depth, performs prefix shrinkage, generates prefix compression results, and extracts the anchor survival set; The sixth module intersects the anchor survival sets of each path to obtain a global set of survivable anchor points. The prefix compression result is then filtered into the global set of survivable anchor points using a left half connection to complete the anchor point intersection. The seventh module sorts the suffix risk sizes from smallest to largest and performs suffix expansion sequentially across the critical layer depth to obtain the final state result; The eighth module connects the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval payload field, the payload is retrieved and the final query result is output.
2. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, The structured query is converted into a layer graph. Each vertex in the vertex set of the layer graph corresponds to a relation layer and is bound to a local predicate on the relation layer. Each edge in the edge set of the layer graph corresponds to the connection condition between relation layers. For each relation layer, the local predicate is used to filter the relation layer to obtain the number of filtered result records. The number of filtered result records is divided by the total number of records in the relation layer to obtain the local selection rate. For each relation layer, determine the set of edges starting from the corresponding vertex and the number of elements in the edge set. For each edge in the edge set, calculate the number of connection result records between the relation layer and the relation layer connected through the connection condition. Divide the number of connection result records by the total number of records in the relation layer to obtain the outward connection ratio. Sum all outward connection ratios and divide by the number of elements in the edge set to obtain the average outward expansion. The anchor score is obtained by multiplying the local selection rate by the average outward expansion. The anchor scores of all relation layers are compared, and the relation layer with the smallest anchor score is selected as the anchor layer. Determine the shortest path length between any vertex in the layer graph and the anchor layer. The shortest path length is calculated by the number of edges contained in the path, and is defined as the layer depth.
3. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, The local predicates corresponding to the anchor layer are used to filter the relation layer corresponding to the anchor layer to obtain the filtering results. The filtering results are then projected and the primary key field of the relation layer corresponding to the anchor layer is retained to obtain the anchor candidate set. For any target vertex in the layer graph, construct the shortest path vertex sequence from the anchor point layer to the target vertex, calculate the shortest path length, which is calculated by the number of edges contained in the path, and for any depth within the shortest path length range, perform a join operation on the local predicate filtering results corresponding to each relation layer involved in the path along the shortest path vertex sequence, and obtain the prefix join result. For each anchor record's primary key value in the anchor candidate set, the set of records whose primary key field in the corresponding relation layer of the anchor layer is equal to the anchor record's primary key value is selected from the prefix join results. The record set is then subjected to a projection operation, and the primary key field of the relation layer at the corresponding depth in the shortest path vertex sequence is retained. A counting operation is then performed on the projection operation result to obtain the projected successor number of the anchor record at the layer depth.
4. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, For the anchor candidate set, the number of anchor records with a projection successor of zero is counted by the indicator function, and the zero inflation rate is obtained by dividing the number of anchor records with a projection successor of zero by the number of elements in the anchor candidate set. Filter the primary key values of anchor records whose projected successor is greater than zero from the anchor candidate set, and gather the primary key values of anchor records whose projected successor is greater than zero to form a positive value set; For the set of positive values, take the natural logarithm of the successor of each projected item and sum them up. Divide the summation result by the number of elements in the set of positive values to obtain the mean of the logarithms of the positive values. For a set of positive values, calculate the sum of squared differences between the natural logarithm of the projected successor and the mean of the logarithm of the positive values, and divide the sum of squared differences by the number of elements in the set of positive values to obtain the variance of the logarithm of the positive values. The proportion of surviving anchor points is obtained by subtracting zero expansion rate from one. The positive logarithmic mean and half the positive logarithmic variance are summed and exponentially calculated to obtain the positive projection scale. The layer depth cardinality function is obtained by multiplying the number of anchor point candidate set elements, the proportion of surviving anchor points, and the positive projection scale.
5. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, Performing the natural logarithm operation on the depth cardinality function yields the logarithmic depth cardinality function; Within the layer depth range defined by the shortest path length, the logarithmic base curvature is obtained by performing a second-order difference operation using the logarithmic base function values corresponding to the current layer depth, the previous unit layer depth, and the next unit layer depth, respectively. In the calculated set of logarithmic cardinal curvature, find the corresponding layer depth that makes the logarithmic cardinal curvature reach its maximum value, and determine this layer depth as the critical layer depth; Determine the accumulation interval from the critical layer depth to the layer before the final state layer depth. Within this accumulation interval, extract only the logarithmic base curvature with a value greater than zero and perform summation to obtain the suffix burst quantity. Obtain the function value of the layer depth cardinality function at the depth of the final state layer, perform an exponential operation with the natural constant as the base on the suffix burst quantity, and multiply the function value at the depth of the final state layer with the result of the exponential operation to obtain the suffix risk size.
6. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, The local predicates corresponding to the anchor layer are used to filter the relation layer corresponding to the anchor layer to obtain the filtering results. The filtering results are then projected and only the primary key field of the relation layer corresponding to the anchor layer is retained to obtain the initial prefix compression result. Within the depth range determined by depth one to critical depth minus one, for each depth, the relation layer and its local predicate of the corresponding vertex in the shortest path vertex sequence are obtained. The local predicate is applied to the relation layer to obtain the current layer filtering result. The prefix compression result of the previous unit depth is connected with the current layer filtering result according to the connection condition. The connection result is projected and only the anchor layer primary key field and the current layer primary key field are retained to obtain the prefix compression result of the current depth. Projection operations are performed on the prefix compression result of the critical layer depth minus one point, and only the anchor point layer primary key field is retained to obtain the anchor point survival set of the corresponding path before the critical layer depth.
7. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, Extract the anchor point survival set corresponding to all paths and perform the intersection operation to obtain the global survivable anchor point set, where the anchor point survival set is the set of matching anchor point records that exist before the critical layer depth of the corresponding path; Using the global set of survivable anchor points as a filtering condition, for the path corresponding to each target vertex, the prefix compression result is filtered by a left half join. The filtering process is performed by matching the primary key field of the relationship layer corresponding to the anchor point layer, and only the records in the prefix compression result that match the global set of survivable anchor points are retained, thus obtaining the prefix compression result after anchor point intersection.
8. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, Extract the suffix risk size corresponding to all target vertices and perform a sorting operation from smallest to largest to obtain the target vertex sequence to determine the processing order for crossing the critical layer depth and performing suffix expansion; For each target vertex in the target vertex sequence, obtain the corresponding critical layer depth. Perform a connection operation on the prefix compression result after anchor point intersection and the local predicate filtering result of the relation layer with the corresponding critical layer depth on the path according to the connection condition. Perform a projection operation on the connection result and retain only the anchor layer primary key field and the current layer primary key field to obtain the critical layer depth result. For the layer depth range determined from the critical layer depth to the shortest path length, the result of the previous unit layer depth is joined with the local predicate filtering result of the current layer relation layer according to the connection condition, and a projection operation is performed. The projection operation only retains the primary key field of the anchor layer and the primary key field of the current layer, and is recursively applied until the layer depth equals the shortest path length to obtain the final result.
9. The structured query optimization system for relational corpus databases according to claim 1, characterized in that, Obtain the global set of survivable anchor points and the final state result corresponding to each path. Perform a join operation on the global set of survivable anchor points and the final state result corresponding to each path in sequence according to the primary key field of the anchor point layer to obtain the core key-level result. Obtain the set of output columns requested by the user and the set of relations corresponding to the key retrieved load fields. Perform a join operation on the core key-level results and the set of relations corresponding to the key retrieved load fields. Perform a projection operation on the result of the join operation according to the set of output columns requested by the user and retain only the columns in the set of output columns requested by the user to obtain the final query result.
10. A structured query optimization method for relational corpus databases, characterized in that, Implementing the structured query optimization system for relational corpus databases as described in any one of claims 1 to 9 includes the following steps: Step S1: Construct a layer diagram. Calculate the anchor point score based on the local selection rate and the average outward expansion. Take the relationship layer corresponding to the minimum anchor point score as the anchor point layer and define the layer depth. Step S2: Obtain the anchor point candidate set, expand the prefix connection results, and calculate the projected successor number at each depth. Step S3: Obtain the zero inflation rate and the set of positive values based on the projected successor, and construct the deep cardinal function by combining the positive logarithmic mean and positive logarithmic variance of the set of positive values. Step S4: Obtain the logarithmic base curvature by taking the logarithm of the layer depth base function and performing second-order difference. Extract the point with the maximum logarithmic base curvature as the critical layer depth. Construct the suffix risk size by combining the cumulative value of the positive logarithmic base curvature after the critical layer depth. Step S5: Before the critical layer depth, retain the anchor layer primary key and the current layer primary key, perform prefix shrinkage, generate prefix compression results, and extract the anchor point live set; Step S6: Find the intersection of the anchor point survival sets of each path to obtain the global survivable anchor point set. Use the left half connection to filter the prefix compression result into the global survivable anchor point set to complete the anchor point intersection. Step S7: Sort the suffix risk sizes from smallest to largest, and perform suffix expansion sequentially across the critical layer depth to obtain the final state result; Step S8: Connect the global set of survivable anchor points with the final state results of each path to form a core key-level result. Based on the core key-level result and the key-retrieval load field, complete the load retrieval and output the final query result.