Data model conversion method, device, equipment and medium
By converting the relational data model into a graph data model, using the nodes and edges of the graph data model to represent business entities and relationships, and performing optimization operations, the problem of high complexity in relational database models is solved, enabling efficient multi-dimensional data querying and simplified data statistical models.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- AGRICULTURAL BANK OF CHINA
- Filing Date
- 2022-11-21
- Publication Date
- 2026-06-02
AI Technical Summary
In existing technologies, relational database models are highly complex, requiring the association of numerous tables during data queries, resulting in low query efficiency.
The relational data model is transformed into a graph data model by constructing a node layer and a business layer of the graph data model. The nodes and edges of the graph data model are used to represent business entities and relationships, and optimization operations such as node splitting, merging and handling of isolated nodes are performed to simplify the data model structure.
It improves the efficiency and capability of data querying, simplifies the complexity of data statistical models, and enhances the performance of business systems and the clarity of query logic.
Smart Images

Figure CN115809291B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data model conversion method, apparatus, device and medium. Background Technology
[0002] Statistical data for large-scale businesses involves queries across multiple dimensions, as well as complex business concepts, logic, and relationships between business entities. Taking banking as an example, statistical data for banking operations involves various query dimensions such as product lines, product groups, product types, institutions, currencies, business types, departments, groups, contract types, account status, and so on.
[0003] To support complex and large-scale business operations, the underlying relational data model of the business system was designed in a complex way. In the relational data model, there are a large number of tables and complex relationships between them. Relationships between tables are often established by using related tables or redundant data.
[0004] It is evident that relational data models in business systems are highly complex. When performing data queries based on relational data models, a single query operation requires the association of numerous tables, resulting in low query efficiency. Summary of the Invention
[0005] This application provides a data model conversion method, apparatus, device, and medium to solve the problem that the high complexity of relational database models in business systems leads to low query efficiency when a single query operation requires association with numerous tables.
[0006] Firstly, this application provides a data model conversion method, including:
[0007] Based on the business scenario, determine the business data to be used to build the graph data model;
[0008] Based on the relational data model of the business scenario, the business entity relationships corresponding to the business data are determined, wherein the business entity relationships include business entities, entity attributes of the business entities, and association relationships between the business entities;
[0009] Based on the relationships between the business entities, construct the graph data model;
[0010] The graph data model's node layer includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. The query nodes correspond to multiple business query dimensions, and the business nodes correspond to business query data.
[0011] In one feasible implementation, constructing the graph data model based on the business entity relationships includes:
[0012] Using the business entities as nodes, the entity attributes of the business entities as node attributes, and the relationships between the business entities as edges, the graph data model is initially constructed.
[0013] The graph data model is optimized to obtain the optimized graph data model, wherein the optimization operation includes at least one of the following: node splitting operation, node merging operation, and isolated node handling operation.
[0014] In one feasible implementation, the preliminary construction of the graph data model, using the business entities as nodes, the entity attributes of the business entities as node attributes, and the relationships between the business entities as edges, includes:
[0015] In the graph data model, a business node corresponding to the business entity is established, and the entity attributes of the business entity are stored in the business node corresponding to the business entity.
[0016] Extract business categories from the business entities, establish query nodes corresponding to the business categories, and store the business categories in the query nodes;
[0017] Establish an edge connecting the query node corresponding to the business category and the business node corresponding to the business entity, and establish an edge connecting business nodes that have an association relationship.
[0018] In one feasible implementation, the optimization operation includes a node splitting operation, and the optimization operation on the graph data model includes:
[0019] In the graph data model, nodes with redundant data that need to be optimized are identified;
[0020] In the entity types of the business scenario, determine the target entity type to which the redundant data belongs;
[0021] Establish a business node corresponding to the target entity type, and store the redundant data in the business node corresponding to the target entity type;
[0022] Establish an edge connecting the node to be optimized to the business node corresponding to the target entity type;
[0023] The redundant data is deleted from the node to be optimized.
[0024] In one feasible implementation, the optimization operation includes a node merging operation, and the optimization operation on the graph data model includes:
[0025] In the graph data model, a first node and a second node that meet the merging conditions are determined. The merging conditions include: the first node and the second node are associated, the second node is not associated with the remaining nodes other than the first node, and no separate data processing is required for the first node and the second node.
[0026] Merge the first node and the second node.
[0027] In one feasible implementation, merging the first node and the second node includes:
[0028] Based on the business priority corresponding to the first node and the business priority corresponding to the second node, determine the master node and the slave node in the first node and the second node;
[0029] Merge the subordinate nodes into the master node.
[0030] In one feasible implementation, merging the subordinate node into the master node includes:
[0031] If the relationship between the master node and the subordinate node is determined to be a one-to-one relationship, the subordinate node is merged into the master node. If the subordinate node does not belong to the shared entity or shared attribute of the master node, a merge tag corresponding to the subordinate node is added to the master node during the process of merging the subordinate node into the master node.
[0032] If the relationship between the master node and the slave node is determined to be a one-to-many relationship, the slave node and the master node are not merged, and an edge connecting the slave node and the master node is established.
[0033] Secondly, this application provides a data model conversion apparatus, comprising:
[0034] The business data determination module is used to determine the business data used to build the graph data model based on the business scenario.
[0035] The entity relationship determination module is used to determine the business entity relationship corresponding to the business data based on the relational data model of the business scenario, wherein the business entity relationship includes the business entity, the entity attribute of the business entity, and the association relationship between the business entities;
[0036] A construction module is used to construct the graph data model based on the business entity relationships;
[0037] The graph data model's node layer includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. The query nodes correspond to multiple business query dimensions, and the business nodes correspond to business query data.
[0038] Thirdly, this application provides an electronic device, including: at least one processor and a memory;
[0039] The memory stores computer-executed instructions;
[0040] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data model conversion method as described in the first aspect above.
[0041] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the data model conversion method as described in the first aspect above.
[0042] Fifthly, this application provides a computer program product, which includes a computer program that, when executed by a processor, implements the data model conversion method as described in the first aspect above.
[0043] The data model conversion method, apparatus, equipment, and medium provided in this application determine the business data used to construct a graph data model based on the business scenario; determine the business entity relationships corresponding to the business data based on the relational data model of the business scenario, wherein the business entity relationships include business entities, entity attributes of business entities, and association relationships between business entities; and construct a graph data model based on the business entity relationships. In this way, the data statistical model of the business system is transformed from a complex, inefficient relational database into a simplified, highly efficient graph data model. The node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes in the query layer and business nodes in the business layer. Query nodes correspond to multiple business query dimensions, and business nodes correspond to business query data. As can be seen from the structure of the graph data model, it can realize multi-dimensional business queries and effectively improve query efficiency. Attached Figure Description
[0044] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0045] Figure 1 This is a schematic diagram illustrating an application scenario provided in the embodiments of this application;
[0046] Figure 2 A flowchart illustrating the data model conversion method provided in this application embodiment. Figure 1 ;
[0047] Figure 3a This is an example diagram of the ER diagram corresponding to the relational database provided in the embodiments of this application;
[0048] Figure 3b Example diagram of the optimized ER diagram provided in the embodiments of this application;
[0049] Figure 4 This is an example diagram illustrating the structure of the graph data model provided in the embodiments of this application;
[0050] Figure 5 Example diagram of the multi-dimensional query path provided in the embodiments of this application;
[0051] Figure 6 A flowchart illustrating the data model conversion method provided in this application embodiment. Figure 2 ;
[0052] Figure 7 Example diagram of node splitting provided in the embodiments of this application;
[0053] Figure 8 Node merging example provided in the embodiments of this application Figure 1 ;
[0054] Figure 9 Node merging example provided in the embodiments of this application Figure 2 ;
[0055] Figure 10 This is a schematic diagram of the structure of the data model conversion device provided in the embodiments of this application;
[0056] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0057] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0058] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0059] Large-scale businesses face challenges such as massive data volumes and complex business logic. In related technologies, the data statistical model of business systems typically employs a relational data model, utilizing relational data structures and databases. However, to handle complex and massive business data and logic, relational data structures and databases are inherently complex in design, involving numerous entities and intricate relationships between them. Table relationships often rely on join tables or redundant data for connections. Furthermore, performing multi-dimensional comprehensive statistical queries based on relational data structures and databases suffers from problems such as large data retrieval volumes, long response times, and low real-time performance.
[0060] To address the aforementioned issues, this application provides a data model conversion method, apparatus, device, and medium. In this application, the relational data model of a business system is converted into a graph data model. Compared to relational data models, graph data models are better at handling large amounts of complex, interconnected, and unstructured data, supporting rapid data changes and frequent data queries. Compared to relational databases, graph databases are better at maintaining complex relationships between entities, reducing overall model complexity, possessing strong traversal capabilities of relational networks, and maintaining constant-time complexity for query and analysis operations. Therefore, replacing the traditional relational data model with a graph data model can effectively simplify the complexity of the data statistical model, improve data query capabilities and efficiency, thereby improving the performance of the business system and the quality of services provided to users.
[0061] Graph databases are databases that use a graph structure for semantic queries, representing and storing data using nodes, edges, and attributes within the graph structure. A graph data model treats data records as nodes, relationships between data records as edges, and uses edges to connect nodes, forming a graph structure that can be used to solve complex data retrieval problems.
[0062] In this application, the node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. Query nodes correspond to multiple query dimensions, and business nodes correspond to business query data. In this way, the graph data model has a clear structure and simple query logic. Moreover, by maintaining multiple query nodes, multi-dimensional queries are achieved, thereby improving query efficiency.
[0063] The data model conversion method provided in this application embodiment can be applied to Figure 1 The application scenarios shown are as follows. Figure 1 As shown, the application scenario involves a business system 101, a data statistics model 102 corresponding to the business system 101, and a data model conversion device 103. The business system 101 can perform data querying and data storage based on the data statistics model 102, and the data model conversion device 103 can convert the data statistics model 102 from a relational data model to a graph data model.
[0064] The data model conversion device 103 can be an electronic device, which can be a terminal and / or a server. The terminal can be a personal digital assistant (PDA) device, a handheld device (e.g., a smartphone, tablet computer), a computing device (e.g., a personal computer, PC), a wearable device (e.g., a smartwatch, smart bracelet), or a smart home device (e.g., a smart display device). The server can be a distributed server, a centralized server, a cloud server, etc.
[0065] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0066] In this application, the execution subject of each method embodiment is a data model conversion device.
[0067] refer to Figure 2 , Figure 2 A flowchart illustrating the data model conversion method provided in this application embodiment. Figure 1 .like Figure 2 As shown, the data model conversion method provided in this embodiment includes:
[0068] S201. Based on the business scenario, determine the business data used to build the graph data model.
[0069] These business scenarios include, for example, a bank's deposit business and credit business.
[0070] In this embodiment, business data for constructing a graph data model can be extracted from a large amount of data based on business needs and / or business metrics in a business scenario. This business data is related to the data to be displayed in the graph data model, which refers to the business data statistically analyzed by the graph data model. For example, using business needs and / or business metrics as query keywords, business data for constructing a graph data model can be queried and obtained from one or more business databases.
[0071] Among them, the business data used to build the graph data model includes, for example, the contract balance, transaction time, transaction status, account type, and department required for data statistics.
[0072] S202. Based on the relational data model of the business scenario, determine the business entity relationships corresponding to the business data. The business entity relationships include business entities, entity attributes of business entities, and association relationships between business entities.
[0073] Among them, business entities include products and contracts in business scenarios, entity attributes of business entities such as product number and product name of products, and relationships between business entities such as the subordinate relationship that a certain product belongs to a certain contract.
[0074] In this embodiment, when obtaining business data for constructing a graph data model, since the business entities and relationships between these business entities are all reflected in the relational data model of the business scenario, it is necessary to sort out the business entities, the entity relationships between business entities, and the management relationships between business entities based on the relational data model of the business scenario and the business data.
[0075] In one feasible implementation, due to the complexity of the relational data model's structure, it can be first streamlined to obtain the corresponding Entity-Relationship Diagram (ER Diagram). Then, based on business data, the ER Diagram is filtered for fields and business entities, resulting in an optimized ER Diagram. This optimized ER Diagram reflects the relationships between business entities corresponding to the business data. Thus, on the one hand, the ER Diagram makes the relationships between business entities clearer and more concise; on the other hand, by filtering the fields and business entities in the ER Diagram based on business data, the ER Diagram becomes more concise and more closely related to the business data used to construct the graph data model.
[0076] Specifically, during the filtering process, keywords from the business data are used to filter out fields and their associated tables from the ER diagram corresponding to the relational data model. The field-assigned table is the entity table to which the field belongs. Since a business entity can be represented as an entity table, the field-assigned table can be understood as the business entity, and the field can be understood as the business attribute of the business entity. Afterwards, the fields and their associated tables related to the business data in the ER diagram corresponding to the relational data model are retained, while other data in the ER diagram is deleted.
[0077] As an example, Figure 3a This is an example diagram of the ER diagram corresponding to the relational database provided in the embodiments of this application. Figure 3b An example diagram of the optimized ER diagram provided in the embodiments of this application.
[0078] like Figure 3a As shown, the business entities include product groups, product lines, salable products, product A, exchange rate parameters, customers, contract A, contract and participant relationship table, balance A, condition parameters, external service identifier A, contract type configuration, end-of-day balance adjustment information, and account balance type information; the entity attributes of product A include product number, business type code, salable product name, other a, other b, and other c; the entity attributes of contract A include: currency, customer number, product number, province / city code, contract number, lifecycle status code, other a, other b, and other c; the entity attributes of balance A include... Sequence number, subcontract number, contract number, currency code, product number, business type code, last transaction date, last transaction balance, contract account balance, last transaction date, account balance type, other a, other b, other c; entity attributes of condition parameters include condition parameter number, effective date, expiration date, lifecycle status code, contract number, simple product number, other a, other b, other c; entity attributes of external service identifier A include: contract number, subcontract number, province / city code, financial entity code, contract external service identifier number, other a, other b, other c.
[0079] Compared to Figure 3a ER diagram corresponding to a relational data model Figure 3b The optimized ER diagram removes the following business entities: available products, contract and participant relationship table, contract type configuration, end-of-day balance adjustment information, and account balance type information. The entity attributes of business entities such as Product A, Contract A, Balance A, condition parameters, and external service identifiers have also been reduced. It is evident that the structure of the ER diagram is significantly simplified, more clearly and tightly representing the relationships between business entities corresponding to the business data.
[0080] S203. Construct a graph data model based on the relationships between business entities.
[0081] In this embodiment, after obtaining the business entity relationships corresponding to the business data, a graph data model is constructed by using the business entities in the business entity relationships as nodes in the graph data model, the entity attributes of the business entities as node attributes of the nodes in the graph data model, and the relationships between the business entities as edges in the graph data model. In other words, a graph data model is constructed by using entity tables as nodes, entity table fields as node attributes, and inter-table relationships of entity tables as edges.
[0082] The node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. Query nodes correspond to multiple business query dimensions, and business nodes correspond to business query data.
[0083] Among them, business query dimensions are equivalent to business query perspectives. Different business query dimensions are different query conditions (or query business types, where each condition represents a query business type), such as currency dimension, product category dimension, etc.; business query data are equivalent to business query results (or business data to be queried), such as querying a specific currency or a specific product.
[0084] In a graph data model, the query layer is located on the outer layer, and the business layer is located on the inner layer. Multi-dimensional query paths need to converge on frequently used business nodes. Therefore, for a set of business data, the structure of the graph data model resembles a star schema. When performing business queries based on the graph data model, queries are sequentially executed from the query nodes to the business layer, ultimately yielding the business query data.
[0085] Therefore, when constructing a graph data model, business entities that have business query dimension characteristics are identified as query nodes, business entities that have business query data characteristics are identified as business nodes, query nodes are set in the outer layer of the graph data model, and business nodes are set in the inner layer of the graph data model.
[0086] As an example, Figure 4 This is a structural example diagram of the graph data model provided in an embodiment of this application. For example... Figure 4 As shown, the outer circle of the graph data model represents the query layer, and the inner circle represents the business layer. The query layer includes query nodes corresponding to query dimensions a, b, c, d, e, and f. The business layer includes business nodes corresponding to business entities A, B, C, D, and the core business entity E. The core business entity is the intersection point of multi-dimensional query paths.
[0087] Optionally, query nodes include query header nodes and query entity nodes. A query dimension can consist of a set of query header nodes and query entity nodes. In a graph data model, this can include multiple query header nodes and multiple query entity nodes of the same type. A set of query header nodes and query entity nodes can be labeled with the same tag. Thus, by subdividing query nodes into query header nodes and query entity nodes, more granular, comprehensive, and accurate business queries can be achieved. The query header node is equivalent to a major business category, and the query entity node is equivalent to a subcategory under that major business category.
[0088] For example, the query header nodes include <Currency Header Node: Composite Currency A> and <Currency Header Node: Composite Currency B>. Under the query header node <Currency Header Node: Composite Currency A>, the corresponding query entity nodes are <Currency = Sub-Currency a>, <Currency = Sub-Currency b1>, and <Currency = Sub-Currency b2>. Under the query header node <Currency Header Node: Composite Currency B>, the corresponding query entity nodes are <Currency = Sub-Currency b1> and <Currency = Sub-Currency b2>. Therefore, as... Figure 5 ( Figure 5 The following is an example diagram of a multi-dimensional query path provided in an embodiment of this application. As shown, in the query layer, the query dimensions may include: <currency head node: comprehensive currency A> → <currency = sub-currency a>, <currency head node: comprehensive currency A> → <currency = sub-currency b1>, <currency head node: comprehensive currency A> → <currency = sub-currency b2>, <currency head node: comprehensive currency B> → <currency = sub-currency b1>, <currency head node: comprehensive currency B> → <currency = sub-currency b2>.
[0089] In summary, the concepts in graph data models can be summarized as follows:
[0090] Query Dimension: Each query condition represents a query business type, which is called a query dimension in the graph data model. A query dimension can consist of a set of query head nodes and query entity nodes. There can be multiple query head nodes and multiple query entity nodes of the same type. A set of query head nodes and query entity nodes can be labeled with the same type of tag.
[0091] Multi-dimensional query path intersection point: The business nodes corresponding to the core business entities are the main business carriers of the data to be statistically queried in the graph data model, such as contracts.
[0092] Multi-dimensional query paths: Multi-dimensional query paths connect query nodes with business nodes related to those query nodes. In a graph data model, each query dimension must be related to a certain business node, and the endpoint of a multi-dimensional query path can be the intersection point of the multi-dimensional query paths. For example, a multi-dimensional query path may include: <Currency Header Node: Composite Currency A> → <Currency = Sub-Currency a> → <Contract>.
[0093] As an example, such as Figure 5 As shown, query dimension a corresponds to currency query, and query dimension b corresponds to product category query. From query dimensions a and b, you can query each business node in the business node group. Specifically, on the query dimension a side, you can query the query entity nodes (sub-currency a, sub-currency b1, sub-currency b2) through the currency head nodes: Comprehensive Currency A, Comprehensive Currency B, and then query the business nodes (contract A, contract B, contract C). On the query dimension b side, you can query the query entity nodes (product line A, product group A) through the currency head nodes: Product A, Product B, and then query the business nodes (contract A, contract B, contract C).
[0094] In this embodiment, based on the complex business entities and their relationships in the relational data model under the business scenario, graph model thinking is used to extract, summarize and build the relationships between business entities, resulting in a graph data model that can realize multi-dimensional data statistics and multi-dimensional data query. This effectively reduces the complexity of the data statistics model, increases the readability and scalability of the data statistics model, and improves the efficiency of business query based on the data statistics model.
[0095] refer to Figure 6 , Figure 6 A flowchart illustrating the data model conversion method provided in this application embodiment. Figure 2 .like Figure 6 As shown, the data model conversion method provided in this embodiment includes:
[0096] S601. Based on the business scenario, determine the business data used to build the graph data model;
[0097] S602. Based on the relational data model of the business scenario, determine the business entity relationships corresponding to the business data. The business entity relationships include business entities, entity attributes of business entities, and association relationships between business entities.
[0098] S603. Using business entities as nodes, entity attributes of business entities as node attributes, and relationships between business entities as edges, a preliminary graph data model is constructed.
[0099] The implementation principles and technical effects of S601 to S603 can be referred to the aforementioned embodiments. Further details will not be provided.
[0100] In one feasible implementation, such as Figure 6 As shown, S603 includes S6031 to S6033:
[0101] S6031. In the graph data model, establish business nodes corresponding to business entities and store the entity attributes of business entities in the business nodes corresponding to business entities.
[0102] In S6031, nodes in the graph data model serve as storage units, with business nodes used to store the entity attributes of business entities. Therefore, after identifying the business entity relationships corresponding to the business data, business nodes corresponding to the business entities can be established based on these relationships, and the entity attributes of the business entities can be stored in the business nodes.
[0103] S6032. Extract business categories from business entities, establish query nodes corresponding to business categories, and store business categories in query nodes.
[0104] In S6032, business entities can include both dynamically changing and statically unchanged business information. For example, products and contracts can change dynamically as business activities progress, while currencies and product groups do not. Therefore, statically unchanged business categories (such as currencies and product groups) can be extracted from business entities, and query nodes corresponding to these categories can be established and stored in the query nodes. The query nodes are essentially static business nodes. Because the business categories remain static, the query nodes also remain unchanged, improving the stability of the query nodes and consequently the stability of the query dimensions. Furthermore, by blurring the concept of classification and extracting the business categories from the business nodes into separate static business entity nodes (i.e., query nodes), the complexity of the business nodes is effectively reduced.
[0105] S6033. Establish an edge connecting the query node corresponding to the business category and the business node corresponding to the business entity, and establish an edge connecting business nodes that have an association relationship.
[0106] In S6033, after establishing business nodes and query nodes, based on the logical relationship (association) between business categories and business entities, edges are established to connect query nodes corresponding to business categories with business nodes corresponding to business entities, and edges are also established between business nodes that have association relationships. In this way, a preliminary graph data model is constructed.
[0107] S604. Perform optimization operations on the graph data model to obtain an optimized graph data model, wherein the optimization operations include at least one of the following: node splitting operation, node merging operation, and isolated node handling operation.
[0108] Among them, node splitting operation refers to splitting a node in the graph data model into at least two nodes, node merging operation refers to merging at least two nodes in the graph data model into one node, and isolated node processing operation refers to processing nodes in the graph data model that are not connected to any other nodes.
[0109] In this embodiment, the initially established graph data model may still have shortcomings such as node redundancy and insufficient node refinement. Therefore, each node in the graph data model can be traversed, and at least one of the following operations can be performed on the traversed node: determine whether the node meets the node splitting condition; if it meets the node splitting condition, then perform a node splitting operation on the node; determine whether the node meets the node merging condition; if it meets the node merging condition, then perform a node merging operation on the node; determine whether the node is an isolated node; if the node is an isolated node, then perform an isolated node processing operation on the node. In this way, the structural rationality of the graph data model is improved through node splitting, node merging, and / or isolated node processing.
[0110] In one feasible implementation, when the optimization operation includes node splitting, the optimization operation on the graph data model includes: identifying nodes with redundant data to be optimized in the graph data model; identifying the target entity type to which the redundant data belongs in the entity types of the business scenario; establishing a business node corresponding to the target entity type and storing the redundant data in the business node corresponding to the target entity type; establishing an edge connecting the node to be optimized and the business node corresponding to the target entity type; and deleting the redundant data in the node to be optimized.
[0111] In this implementation, redundant data may exist within business entities in the relational data model. This redundant data could be inter-table relationship data, such as data representing relationships between tables. Therefore, redundant data may also exist in the nodes of the graph data model built upon the relational data model. To simplify the nodes in the graph data model and make its logic clearer, this redundant data needs to be separated. This separation can be achieved by extracting the redundant data from the nodes and constructing new nodes to store the redundant data.
[0112] First, in the graph data model, nodes with redundant data are identified as nodes to be optimized. For example, it can be determined whether the stored data in a node includes redundant data; if so, the node is identified as a node to be optimized. Next, in the entity types of the business scenario, the entity type to which the redundant data in the node to be optimized belongs is identified. For ease of distinction, the entity type to which the redundant data in the node to be optimized belongs is called the target entity type. Then, a business node corresponding to the target entity type is created. This business node is a new node, and the redundant data is stored in this business node. Since the redundant data is separated from the node to be optimized, it indicates that there is a certain relationship between the redundant data and the node to be optimized; therefore, an edge is established connecting the node to be optimized and the business node corresponding to the target entity type. Finally, the redundant data is deleted from the node to be optimized, completing the optimization of the node and making the data in the node simpler and more singular.
[0113] Optionally, in addition to establishing edges connecting the node to be optimized to the business node corresponding to the target entity type, edges can also be established connecting the business node corresponding to the target entity type to the query node corresponding to the business category to which the target entity type belongs, so as to improve the relationship between nodes in the graph data model.
[0114] As an example, Figure 7 This is an example diagram of node splitting provided in an embodiment of this application. For example... Figure 7 As shown, the contract node stores redundant data such as "Province / City Code: City A". The entity type of this redundant data can be identified. After identifying the entity type of "Province / City Code: City A" as an organization, a business node corresponding to the organization is created, and "Province / City Code: City A" is stored in the business node corresponding to the organization. Then, an edge is established between the business node corresponding to the organization and the contract node, and an edge is established between the business node corresponding to the organization and the organization head node. The organization head node stores "Region Type: Municipality".
[0115] In one feasible implementation, when the optimization operation includes a node merging operation, the optimization operation on the graph data model includes: in the graph data model, determining a first node and a second node that meet the merging conditions, wherein the merging conditions include: the first node and the second node have an association relationship, the second node has no association relationship with the remaining nodes other than the first node, and there is no need to perform separate data processing on the first node and the second node; merging the first node and the second node.
[0116] In this context, the first node and the second node are related, meaning there is an edge between them; the second node is not related to any of the remaining nodes except the first node, meaning the second node is only connected to the first node; and no separate data processing is required for the first and second nodes, indicating that data processing (such as data operations) can be performed on the first and second nodes together.
[0117] In this implementation, if the second node is only related to the first node, and there are no special requirements for independent calculation of the second node in statistical dimensions or data processing, then it is necessary to consider merging the first and second nodes. This reduces unnecessary nodes and improves the simplicity of the graph data model.
[0118] Furthermore, the first node and the second node are merged, including: determining the master node and the subordinate node in the first node and the second node according to the business priority corresponding to the first node and the business priority corresponding to the second node; and merging the subordinate node into the master node.
[0119] The business priority corresponding to a business node can be included in the node attributes of the business node, or it can be determined according to the business category to which the business node belongs, i.e. the query node to which the business node is connected, or the business priority corresponding to the business node can be entered by the user.
[0120] In this merging method, the business priorities corresponding to the first node and the second node are determined. The business priorities of the first and second nodes are compared. If the business priority of the first node is higher than that of the second node, the first node is determined as the master node and the second node as the slave node; otherwise, the first node is determined as the slave node and the second node as the master node. Afterwards, the slave nodes are merged into the master node, and the master node integrates the relationships between the slave nodes and other nodes.
[0121] Furthermore, the process of merging subordinate nodes into the master node includes: merging subordinate nodes into the master node if the relationship between the master node and subordinate nodes is determined to be a one-to-one relationship; and adding a merge tag corresponding to the subordinate node to the master node during the merging process if the subordinate node is not a shared entity or shared attribute of the master node. Thus, the merge tag identifies the addition of subordinate nodes that are not shared entities or shared attributes to the master node, distinguishing them from nodes that have not had this information added.
[0122] Furthermore, when the relationship between the master node and its subordinate nodes is determined to be a one-to-many relationship, the subordinate nodes and the master node are not merged, and edges connecting the subordinate nodes and the master node are established. Thus, even when the relationship between the master node and its subordinate nodes is determined to be a one-to-many relationship, although the master node and its subordinate nodes are not merged, the structure of the graph data model can be improved by establishing edges connecting the subordinate nodes and the master node. Here, a one-to-many relationship between the master node and its subordinate nodes means that the master node corresponds to multiple subordinate nodes.
[0123] As an example, based on the business priorities corresponding to business node C and business node D, business node C is determined to be the master node, and business node D is the slave node. Then, business node C and business node D can be processed as follows:
[0124] If the correspondence between business node C and business node D is 1:N, then business nodes C and D are not merged; instead, an edge is created for each correspondence between business nodes C and D. For example, if the business system has a contract table and a freeze record table, and freeze records are only associated with the freeze status of contracts, but the relationship between contracts and freeze records is 1:N, then the freeze record table and the contract table are not merged. Instead, a business entity node is created for each freeze record, and a relationship is established between it and the contract node.
[0125] If the correspondence between business node C and business node D is 1:1 and business node D is a common entity / attribute (i.e., a shared entity / shared attribute), then business node D can be directly merged into business node C. For example, Figure 8 Node merging example provided in the embodiments of this application Figure 1 ,like Figure 8 As shown, the contract node and the balance node meet the merging conditions, and the balance node is a common attribute of the contract node. The balance node will be directly merged into the contract node, that is, the node attributes of the balance node "last transaction date: XX, last transaction balance: XX" will be stored in the contract node.
[0126] If the correspondence between business node C and business node D is 1:1 and business node D is a non-generic entity / attribute, then business node D can be directly merged into business node C, and a unique label (Label: D) can be added to business node C to distinguish it. Thus, this method can expand the information storage dimension of business entity nodes; that is, by using multiple labels (Labels) to annotate the comprehensive entity after merging multiple entity attributes, it can identify what kind of proprietary entity attributes the entity possesses, facilitating multi-category and multi-condition filtering queries using graph database query statements.
[0127] As an example, Figure 9 Node merging example provided in the embodiments of this application Figure 2 ,like Figure 9As shown, contract nodes include contract A, contract B, and contract C, and condition parameter nodes include condition parameter A, condition parameter B, and condition parameter C. The node attribute of the condition parameter nodes includes "parameter: XXX". Contract A and condition parameter A satisfy the merging condition, and contract B, condition parameters B, and condition parameter C satisfy the merging condition. Since the parameters in the condition parameter nodes are not common attributes of contract nodes, after merging condition parameter A into contract A, a tag 'a' can be added to contract A to indicate that contract A merged with condition parameter A; similarly, after merging condition parameters B and C into contract B, a tag 'b' can be added to contract B to indicate that contract B merged with condition parameters B and condition parameter C.
[0128] In one feasible implementation, when the optimization operation includes orphan handling, the graph data model is optimized. This optimization includes: mining the potential relationships between orphans and remaining nodes in the graph data model, and establishing edges between orphans and remaining nodes based on these potential relationships; or, determining the relationships between orphans and business nodes in the graph data model based on business logic, and establishing edges between orphans and business nodes based on these relationships. Further, if there is no direct business logic between orphans and business nodes in the graph data model, indirect business logic between the orphans and business nodes can be found in the relational data model, and the fields corresponding to this indirect business logic can be added to the graph data model and a relationship established with the orphan; or, a new query node can be created for the orphan, and this new query node can be used as a connection node between the orphan and the graph data model, establishing an edge between the new query node and the orphan. This resolves the orphans in the graph data model and improves its model integrity.
[0129] The following are embodiments of the apparatus described in this application, which can be used to execute the corresponding method embodiments of this application. For details not disclosed in the apparatus embodiments of this application, please refer to the corresponding method embodiments of this application.
[0130] Figure 10 This is a schematic diagram of the data model conversion device provided in an embodiment of this application. Figure 10 As shown, the data model conversion device 1000 provided in this embodiment includes:
[0131] The business data determination module 1001 is used to determine the business data used to build the graph data model based on the business scenario. The model type of the graph data model is graph data model.
[0132] The entity relationship determination module 1002 is used to determine the business entity relationship corresponding to the business data based on the relational data model of the business scenario. The business entity relationship includes the business entity, the entity attribute of the business entity, and the association relationship between the business entities.
[0133] Module 1003 is used to build a graph data model based on the relationships between business entities;
[0134] The node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. Query nodes correspond to multiple business query dimensions, and business nodes correspond to business query data.
[0135] In one feasible implementation, the construction module 1003 is specifically used to: initially construct a graph data model using business entities as nodes, entity attributes of business entities as node attributes, and relationships between business entities as edges; and perform optimization operations on the graph data model to obtain an optimized graph data model, wherein the optimization operations include at least one of the following: node splitting operation, node merging operation, and isolated node processing operation.
[0136] In one feasible implementation, during the initial construction of a graph data model using business entities as nodes, entity attributes of business entities as node attributes, and relationships between business entities as edges, the construction module 1003 is specifically used for: establishing business nodes corresponding to business entities in the graph data model, and storing the entity attributes of business entities in the corresponding business nodes; extracting business categories from business entities, establishing query nodes corresponding to business categories, and storing business categories in the query nodes; establishing edges connecting the query nodes corresponding to business categories and the business nodes corresponding to business entities, and establishing edges connecting business nodes with relationships.
[0137] In one feasible implementation, the optimization operation includes node splitting. During the optimization operation on the graph data model, the construction module 1003 is specifically used to: identify nodes with redundant data to be optimized in the graph data model; identify the target entity type to which the redundant data belongs in the entity types of the business scenario; establish business nodes corresponding to the target entity type and store the redundant data in the business nodes corresponding to the target entity type; establish edges connecting the nodes to be optimized and the business nodes corresponding to the target entity type; and delete the redundant data in the nodes to be optimized.
[0138] In one feasible implementation, the optimization operation includes a node merging operation. During the optimization operation on the graph data model, the construction module 1003 is specifically used to: determine the first node and the second node that meet the merging conditions in the graph data model. The merging conditions include: the first node and the second node have an association relationship, the second node has no association relationship with the remaining nodes other than the first node, and there is no need to perform separate data processing on the first node and the second node; and merge the first node and the second node.
[0139] In one feasible implementation, during the merging of the first node and the second node, the construction module 1003 is specifically used to: determine the master node and the subordinate node in the first node and the second node according to the business priority corresponding to the first node and the business priority corresponding to the second node; and merge the subordinate node into the master node.
[0140] In one feasible implementation, during the process of merging subordinate nodes into the master node, the construction module 1003 is specifically used to: merge subordinate nodes into the master node when the relationship between the master node and subordinate nodes is determined to be a one-to-one relationship; wherein, if the subordinate node does not belong to the shared entity or shared attribute of the master node, a merge tag corresponding to the subordinate node is added to the master node during the process of merging subordinate nodes into the master node; and when the relationship between the master node and subordinate nodes is determined to be a one-to-many relationship, the subordinate nodes and the master node are not merged, and an edge connecting the subordinate nodes and the master node is established.
[0141] It is worth noting that the data model conversion apparatus provided in the above embodiments can be used to execute each step in the data model conversion method provided in any of the above embodiments. The specific implementation methods and technical effects are similar, and will not be repeated here.
[0142] The device embodiments provided in this application are merely illustrative, and the module division is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system. The coupling between the modules can be achieved through interfaces, which are usually electrical communication interfaces, but mechanical interfaces or other forms of interfaces are also possible. Therefore, the modules described as separate components may or may not be physically separate; they may be located in one place or distributed in different locations on the same or different devices.
[0143] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 11 As shown, the electronic device 1100 may include at least one processor 1101 and a memory 1102. Figure 11 The example shown is an electronic device using a processor.
[0144] The memory 1102 is used to store the program of the processor 1101. Specifically, the program may include program code, which includes computer operation instructions.
[0145] The memory 1102 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage.
[0146] The processor 1101 is configured to execute computer programs stored in the memory 902 to implement the steps in the data model conversion methods in the above method embodiments.
[0147] The processor 1101 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0148] Optionally, the memory 1102 can be either independent or integrated with the processor 1101. When the memory 1102 is a device independent of the processor 1101, the electronic device 1100 may further include a bus 1103 for connecting the processor 1101 and the memory 1102. The bus can be an industry standard architecture (ISA) bus, a peripheral component (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. Buses can be classified as address buses, data buses, control buses, etc., but this does not mean that there is only one bus or one type of bus.
[0149] Optionally, in a specific implementation, if the memory 1102 and the processor 1101 are integrated on a single chip, then the memory 1102 and the processor 1101 can communicate through an internal interface.
[0150] This application also provides a computer-readable storage medium, which may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk. Specifically, the computer-readable storage medium stores computer-executable instructions. When at least one processor of the electronic device executes the computer instructions, the electronic device performs each step of the data model conversion method provided in the above-described embodiments.
[0151] This application also provides a computer program product comprising a computer program stored in a readable storage medium. At least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to perform the various steps of the data model conversion methods provided in the various embodiments described above.
[0152] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0153] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A data model conversion method, characterized in that, include: Based on the business scenario, determine the business data to be used to build the graph data model; Based on the relational data model of the business scenario, the business entity relationships corresponding to the business data are determined, wherein the business entity relationships include business entities, entity attributes of the business entities, and association relationships between the business entities; Using the business entities as nodes, the entity attributes of the business entities as node attributes, and the relationships between the business entities as edges, the graph data model is initially constructed. The graph data model is optimized to obtain the optimized graph data model, wherein the optimization operation includes at least one of the following: node splitting operation, node merging operation, and isolated node handling operation; The node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. The query nodes correspond to multiple business query dimensions, and the business nodes correspond to business query data. The optimization operation includes a node merging operation, and the optimization operation on the graph data model includes: In the graph data model, a first node and a second node that meet the merging conditions are determined. The merging conditions include: the first node and the second node are associated, the second node is not associated with the remaining nodes other than the first node, and no separate data processing is required for the first node and the second node. Based on the business priority corresponding to the first node and the business priority corresponding to the second node, determine the master node and the slave node in the first node and the second node; If the relationship between the master node and the subordinate node is determined to be a one-to-one relationship, the subordinate node is merged into the master node. If the subordinate node does not belong to the shared entity or shared attribute of the master node, a merge tag corresponding to the subordinate node is added to the master node during the process of merging the subordinate node into the master node. If the relationship between the master node and the slave node is determined to be a one-to-many relationship, the slave node and the master node are not merged, and an edge connecting the slave node and the master node is established.
2. The data model conversion method according to claim 1, characterized in that, The graph data model is initially constructed by using the business entities as nodes, the entity attributes of the business entities as node attributes, and the relationships between the business entities as edges, including: In the graph data model, a business node corresponding to the business entity is established, and the entity attributes of the business entity are stored in the business node corresponding to the business entity. Extract business categories from the business entities, establish query nodes corresponding to the business categories, and store the business categories in the query nodes; Establish an edge connecting the query node corresponding to the business category and the business node corresponding to the business entity, and establish an edge connecting business nodes that have an association relationship.
3. The data model conversion method according to claim 1, characterized in that, The optimization operation includes node splitting, and the optimization operation on the graph data model further includes: In the graph data model, nodes with redundant data that need to be optimized are identified; In the entity types of the business scenario, determine the target entity type to which the redundant data belongs; Establish a business node corresponding to the target entity type, and store the redundant data in the business node corresponding to the target entity type; Establish an edge connecting the node to be optimized to the business node corresponding to the target entity type; The redundant data is deleted from the node to be optimized.
4. A data model conversion device, characterized in that, include: The business data determination module is used to determine the business data used to build the graph data model based on the business scenario. The entity relationship determination module is used to determine the business entity relationship corresponding to the business data based on the relational data model of the business scenario, wherein the business entity relationship includes the business entity, the entity attribute of the business entity, and the association relationship between the business entities; The construction module is used to initially construct the graph data model using the business entities as nodes, the entity attributes of the business entities as node attributes, and the relationships between the business entities as edges; The graph data model is optimized to obtain the optimized graph data model, wherein the optimization operation includes at least one of the following: node splitting operation, node merging operation, and isolated node handling operation; The node layer of the graph data model includes a query layer and a business layer. The nodes of the graph data model include query nodes located in the query layer and business nodes located in the business layer. The query nodes correspond to multiple business query dimensions, and the business nodes correspond to business query data. The construction module is specifically used to determine, in the graph data model, a first node and a second node that meet the merging conditions. The merging conditions include: the first node and the second node are associated, the second node is not associated with any of the remaining nodes other than the first node, and no separate data processing is required for the first node and the second node. Based on the business priority corresponding to the first node and the business priority corresponding to the second node, determine the master node and the slave node in the first node and the second node; If the relationship between the master node and the subordinate node is determined to be a one-to-one relationship, the subordinate node is merged into the master node. If the subordinate node does not belong to the shared entity or shared attribute of the master node, a merge tag corresponding to the subordinate node is added to the master node during the process of merging the subordinate node into the master node. If the relationship between the master node and the slave node is determined to be a one-to-many relationship, the slave node and the master node are not merged, and an edge connecting the slave node and the master node is established.
5. An electronic device, comprising: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data model conversion method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the data model conversion method as described in any one of claims 1 to 3.