Method, medium, device and computing device for constructing a data model
By parsing the business system code to generate a data flow diagram, merging it into a second data flow diagram, and using an identification strategy to build a data model, the problem of low efficiency in ER model construction and maintenance is solved, and efficient and accurate model construction and maintenance are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HANGZHOU NETEASE CLOUD MUSIC TECH CO LTD
- Filing Date
- 2023-05-09
- Publication Date
- 2026-04-28
AI Technical Summary
Existing technologies suffer from low efficiency and accuracy in building and maintaining ER models, high labor costs, and difficulties in maintenance as business systems become more complex, with inconsistencies between entity relationships and code.
By parsing the business system code, a first data flow diagram is generated, which is then merged into a second data flow diagram. A data model is constructed using an identification strategy to replace manual processing and improve the efficiency of construction and maintenance.
It improves the efficiency of ER model construction and maintenance, reduces labor costs, and ensures the accuracy of the model and its synchronization with business system code.
Smart Images

Figure CN116594980B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this disclosure relate to the field of data processing, and more specifically, the embodiments of this disclosure relate to methods, media, apparatus and computing devices for constructing data models. Background Technology
[0002] This section is intended to provide background or context for the embodiments of this disclosure as set forth in the claims. The description herein is not intended to be a prior art simply because it is included in this section.
[0003] The Entity-Relationship (ER) model is a conceptual model used for data modeling. It is typically used to describe the relationships and constraints between data. It can abstract the essential characteristics of real-world problems, thereby representing the essential relationships between data in a more intuitive and easier-to-understand way, and has been widely used in business systems.
[0004] The ER model includes entities, attributes, and relationships. In the current technology, the construction and maintenance of the ER model need to be carried out manually, which results in low efficiency and accuracy in the construction and maintenance of the ER model. Summary of the Invention
[0005] This disclosure provides a method, medium, apparatus, and computing device for constructing a data model to address the problem of low efficiency and accuracy in constructing and maintaining ER models in the prior art.
[0006] In a first aspect of this disclosure, a method for constructing a data model is provided, comprising:
[0007] The code of the business system is parsed to obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table;
[0008] For each statement in the code of the business system that can generate data flow, a corresponding first data flow diagram is generated. The first data flow diagram includes multiple nodes and the data flow between nodes. The nodes are elements in the statement used for data transmission or data storage.
[0009] Merge the identical nodes in the multiple first data flow graphs to generate a second data flow graph;
[0010] A data model is constructed based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes. The identification strategy is pre-set according to the business requirements of the business system.
[0011] In one embodiment of this disclosure, the step of constructing a data model based on the second data flow diagram, the identification strategy, each entity, and its corresponding attributes includes:
[0012] Based on the second data flow diagram and the attributes of the entities corresponding to each database table, the data flow between entities is determined;
[0013] The pointing relationship between entities is determined based on the data flow between the entities and the identification strategy;
[0014] The data model is constructed based on the pointing relationships between the entities and each entity.
[0015] In another embodiment of this disclosure, determining the data flow direction between entities based on the second data flow diagram and the attributes of the entities corresponding to each database table includes:
[0016] In the second data flow diagram, if the first node of the second data flow diagram is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the data flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
[0017] In another embodiment of this disclosure, constructing the data model based on the pointing relationships between the entities and each entity includes:
[0018] The corresponding entities are associated based on the pointing relationships between them to generate the data model.
[0019] In another embodiment of this disclosure, merging the identical nodes in the plurality of first data flow graphs to generate a second data flow graph includes:
[0020] For all first data flow graphs, merge the same nodes in the first data flow graphs belonging to the same method to generate multiple third data flow graphs;
[0021] For all third data flow graphs, merge identical nodes in the third data flow graphs belonging to the same category to generate multiple fourth data flow graphs;
[0022] Merge all nodes with the same fourth data flow direction in the graph to generate the second data flow direction graph.
[0023] In another embodiment of this disclosure, parsing the code of the business system to obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table includes:
[0024] The code of the business system is parsed to obtain multiple initial entities and their corresponding attributes;
[0025] The plurality of initial entities are filtered to identify the entity corresponding to each database table and the attributes of the entity corresponding to the database table from the plurality of initial entities.
[0026] In another embodiment of this disclosure, the data model is an entity-relationship (ER) model.
[0027] In a second aspect of this disclosure, a data model construction apparatus is provided, comprising:
[0028] The first processing module is used to parse the code of the business system and obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table.
[0029] The second processing module is used to generate a corresponding first data flow diagram for each statement in the code of the business system that can generate data flow direction. The first data flow diagram includes multiple nodes and the data flow direction between nodes. The nodes are elements in the statement used for data transmission or data storage.
[0030] The third processing module is used to merge the same nodes in the multiple first data flow diagrams to generate a second data flow diagram;
[0031] The fourth processing module is used to construct a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes. The identification strategy is preset according to the business requirements of the business system.
[0032] In one embodiment of this disclosure, the fourth processing module is specifically used for:
[0033] Based on the second data flow diagram and the attributes of the entities corresponding to each database table, the data flow between entities is determined;
[0034] The pointing relationship between entities is determined based on the data flow between the entities and the identification strategy;
[0035] The data model is constructed based on the pointing relationships between the entities and each entity.
[0036] In another embodiment of this disclosure, the fourth processing module is specifically used for:
[0037] In the second data flow diagram, if the first node of the second data flow diagram is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the data flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
[0038] In another embodiment of this disclosure, the fourth processing module is specifically used for:
[0039] The corresponding entities are associated based on the pointing relationships between them to generate the data model.
[0040] In another embodiment of this disclosure, the third processing module is specifically used for:
[0041] For all first data flow diagrams, the same nodes in the first data flow diagrams belonging to the same device are merged to generate multiple third data flow diagrams;
[0042] For all third data flow graphs, merge identical nodes in the third data flow graphs belonging to the same category to generate multiple fourth data flow graphs;
[0043] Merge all nodes with the same fourth data flow direction in the graph to generate the second data flow direction graph.
[0044] In another embodiment of this disclosure, the first processing module is specifically used for:
[0045] The code of the business system is parsed to obtain multiple initial entities and their corresponding attributes;
[0046] The plurality of initial entities are filtered to identify the entity corresponding to each database table and the attributes of the entity corresponding to the database table from the plurality of initial entities.
[0047] In another embodiment of this disclosure, the data model is an ER model.
[0048] In a third aspect of this disclosure, a storage medium is provided that stores computer program instructions, which, when executed, implement the methods provided in the first aspect and various possible designs.
[0049] In a fourth aspect of this disclosure, a computing device is provided, comprising: a processor, and a memory communicatively connected to the processor;
[0050] The memory stores computer-executed instructions;
[0051] The processor executes computer execution instructions stored in the memory to implement the methods provided by the first aspect and various possible designs.
[0052] According to the data model construction method, medium, apparatus, and computing device of this disclosure, in the data model construction method, the computing device parses the code of the business system to obtain the entities and attributes corresponding to each database table. For each statement in the business system code that can generate data flow, a corresponding first data flow diagram is generated. Identical nodes in multiple first data flow diagrams are merged to generate a second data flow diagram. Based on the second data flow diagram, the identification strategy, each entity, and its corresponding attributes, a data model is constructed. In this technical solution, based on the code of the business system, a second data flow diagram of the entire business system is obtained. Based on this second data flow diagram, it is determined whether there are relationships between entities corresponding to each database table, thereby constructing the data model of the business system. This replaces the manual construction process and effectively improves the efficiency and accuracy of the construction process. Attached Figure Description
[0053] The above and other objects, features, and advantages of this disclosure will become readily apparent from the following detailed description of exemplary embodiments, taken in conjunction with the accompanying drawings. Several embodiments of this disclosure are illustrated in the drawings by way of example and not limitation, in which:
[0054] FIG. 1 A schematic diagram illustrating a scenario for a data model construction method provided in an embodiment of this disclosure;
[0055] FIG. 2 A flowchart illustrating a method for constructing a data model according to an embodiment of this disclosure;
[0056] FIG. 3 This is a structural diagram of a second data flow diagram provided in an embodiment of the present disclosure;
[0057] FIG. 4 A flowchart illustrating a method for constructing a data model according to another embodiment of this disclosure;
[0058] FIG. 5 A structural diagram of a storage medium provided in an embodiment of this disclosure;
[0059] FIG. 6 A structural diagram of a data model construction apparatus provided in an embodiment of this disclosure;
[0060] FIG. 7 This is a structural diagram of a computing device provided in an embodiment of the present disclosure.
[0061] In the accompanying drawings, the same or corresponding reference numerals indicate the same or corresponding parts. Detailed Implementation
[0062] The principles and spirit of this disclosure will now be described with reference to several exemplary embodiments. It should be understood that these embodiments are given merely to enable those skilled in the art to better understand and implement this disclosure, and are not intended to limit the scope of this disclosure in any way. Rather, these embodiments are provided to make this disclosure more thorough and complete, and to fully convey the scope of this disclosure to those skilled in the art.
[0063] Those skilled in the art will recognize that embodiments of this disclosure can be implemented as a method, medium, apparatus, and computing device for constructing a data model. Therefore, this disclosure can be specifically implemented in the following forms: entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0064] According to embodiments of this disclosure, a method, medium, apparatus, and computing device for constructing a data model are proposed.
[0065] In this article, it is important to understand the following terms:
[0066] Entity: A data object refers to an objectively existing thing that can be distinguished in an application. In this disclosure, it specifically refers to the entity corresponding to a database table.
[0067] Attributes: Entity attributes, such as a user's identity document (Id), name, age, etc.
[0068] Relationship: Represents the relationship between entities. In this disclosure, it specifically refers to the pointing relationship of the primary key of a database table. For example, a certain field of entity A points to the primary key id of entity B.
[0069] Relationship types: divided into one-to-one, one-to-many, and many-to-many.
[0070] Data flow graph nodes: Elements in the project code that can store and pass values are called flow graph nodes, which are simply referred to as nodes in this publication. Within a project, each node has a unique identifier. For example, in a variable declaration: `int a`, `a` is a node.
[0071] Data flow: In engineering code, if there are two nodes that transfer data, then a data flow is considered to exist between these two nodes. For example, the simplest assignment statement, `int a = b`, will generate a data flow from node b to node a.
[0072] Data flow diagram: By analyzing all data flows in the project and piecing together all the nodes and data flows, a data flow diagram of the project (i.e., the business system in the following embodiments) is formed.
[0073] Furthermore, the number of any elements in the accompanying drawings is for illustrative purposes only and not for limitation, and any naming is for distinction only and has no limiting meaning.
[0074] In addition, the data involved in this disclosure may be data authorized by the user or fully authorized by all parties. The collection, dissemination and use of the data shall comply with the requirements of relevant national laws and regulations. The implementation methods / executives of this disclosure may be combined with each other.
[0075] The principles and spirit of this disclosure will be explained in detail below with reference to several representative embodiments. SUMMARY
[0077] The inventors have discovered that the ER model is a model used to describe the data stored in a database by a business system. It is used to explain the domain model and the relationship between domain models in the business system, and can help users quickly understand the business system.
[0078] Currently, ER models are entirely built and maintained manually. Specifically, the ER models of the business systems are built and maintained by manually analyzing the relationships between the database tables.
[0079] However, existing technologies have the following technical problems:
[0080] 1. Manual processing requires a lot of time and cannot guarantee the rigor of the process, resulting in low accuracy and efficiency in building and maintaining ER models, and high labor costs.
[0081] 2. As business systems evolve, their code becomes increasingly complex, making manual maintenance of the ER model more difficult and leading to inconsistencies between the relationships between entities in the ER model and the actual code.
[0082] To address the aforementioned issues, this disclosure provides a method, medium, apparatus, and computing device for constructing a data model. By analyzing each statement in the code of a business system that generates data flow, a first data flow diagram corresponding to each statement is generated. Then, all first data flow diagrams in the business system are merged into one to obtain a second data flow diagram corresponding to the business system. This allows for the determination of relationships between entities based on the second data flow diagram and a pre-set identification strategy, thereby constructing a data model. This replaces manual processing, improving the efficiency and accuracy of constructing and maintaining ER models, and saving labor costs.
[0083] After introducing the basic principles of this disclosure, various non-limiting embodiments of this disclosure will be described in detail below.
[0084] Overview of Application Scenarios
[0085] For example, the data model construction method provided in this disclosure can be applied to... FIG. 1 The scene diagram shown. FIG. 1 This is a schematic diagram illustrating a scenario for a data model construction method provided in an embodiment of this disclosure. For example... FIG. 1 As shown, the scenario includes a computing device 70 and a business system 10.
[0086] In this application scenario, computing device 70 obtains the code from business system 10, parses the code of business system 10, and constructs a data model corresponding to business system 10. This data model is used to represent the database tables of business system 10 and the relationships between the database tables. The specific implementation process of constructing the data model based on the code of business system 10 can be found in the solutions of the following embodiments.
[0087] It should be noted that, FIG. 1 This is merely a schematic diagram illustrating one application scenario provided by an embodiment of this disclosure; this embodiment does not necessarily represent an application scenario. FIG. 1 The included equipment is not limited, nor is it restricted. FIG. 1 The positional relationships between devices are defined. For example, in FIG. 1 The application scenario shown may also include a data storage device for storing the code of the business system. The data storage device may be an external memory relative to the computing device 70 or the business system 10, or it may be an internal memory integrated into the computing device 70 or the business system 10.
[0088] Exemplary Method
[0089] The following is combined with FIG. 1 Application scenarios, refer to FIG. 2 This document describes a method for constructing a data model according to exemplary embodiments of the present disclosure. It should be noted that the above application scenarios are shown only to facilitate understanding of the spirit and principles of the present disclosure, and the embodiments of the present disclosure are not limited in any way. Rather, the embodiments of the present disclosure can be applied to any applicable scenario.
[0090] FIG. 2 This is a flowchart illustrating a method for constructing a data model according to an embodiment of this disclosure. The method described in this embodiment can be applied to a computing device, which may be a server or server cluster, or a terminal device. FIG. 2 As shown, the method in this embodiment includes:
[0091] S201. Parse the code of the business system to obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table.
[0092] In this step, the primary task in constructing the data model corresponding to the business system is to first identify the entities within that data model. These entities are the entities corresponding to the database tables of the business system. The business system's code contains various entities required for its operation; these entities include those corresponding to the database tables and those not directly related to them. Therefore, it is necessary to first parse the business system's code to determine the entities corresponding to the database tables from among the entities contained within the business system.
[0093] Furthermore, since this embodiment determines whether data flow exists between entities by checking whether data flow exists between entity attributes, it is also necessary to obtain the attributes of the entities corresponding to each database table after obtaining the entities corresponding to each database table.
[0094] For example, when the entity is the entity corresponding to a database table, this attribute can be the user's ID, name, age, etc.
[0095] In one possible implementation, S201 can be achieved through the following steps (1) and (2):
[0096] Step (1): Parse the code of the business system to obtain multiple initial entities and their corresponding attributes.
[0097] Optionally, an OX parser can be used to parse the business system's code to obtain multiple initial entities. These initial entities can be entities corresponding to database tables or entities not corresponding to database tables. Therefore, it is necessary to further filter from the initial entities to extract the entities corresponding to database tables and their attributes.
[0098] Step (2): Filter multiple initial entities and identify the entity corresponding to each database table and the attributes of the entity corresponding to the database table from the multiple initial entities.
[0099] Optionally, different identification methods can be determined based on the engineering characteristics of the business system, so that the initial entities can be filtered according to the identification method, thereby obtaining the entities corresponding to the filtered database tables and the attributes of the entities corresponding to the database tables.
[0100] For example, the identification method can be MyBatis, or it can be the @Table annotation, or some other existing identification methods that can identify the entities corresponding to the database table. It can be determined according to the actual situation, and this disclosure does not impose specific limitations on it.
[0101] S202. For each statement in the business system's code that can generate data flow, generate the corresponding first data flow diagram.
[0102] In this step, after identifying the entities corresponding to each database table in the business system, it is necessary to further determine whether relationships exist between these entities. Since there must be data flow between applications corresponding to related entities, and this data flow can be obtained from the business system's code, the business system's code can be analyzed first to determine the data flow within the business system. This involves constructing a data flow diagram for the business system (the second data flow diagram below), which will then be used to determine whether relationships exist between the entities corresponding to each database table.
[0103] To construct the overall data flow diagram of a business system, it is necessary to start from each place where data flow occurs. That is, it is necessary to first construct the first data flow diagram corresponding to each statement that can generate data flow, and then merge each first data flow diagram to obtain the overall data flow diagram of the business system.
[0104] The computing device can traverse all classes in the business system, then traverse the static code blocks and methods within each class, and further traverse the statements within the static code blocks and methods that can generate data flow directions (referred to as data flow direction statements). Based on each data flow direction statement, the elements in that statement used for data transmission or data storage are identified as nodes, and the data flow direction between nodes is determined according to the data transmission direction or data storage direction in that statement.
[0105] Optionally, since identifying nodes from data flow to statements involves complete type information, this can be achieved through symbol resolution techniques.
[0106] The first data flow diagram includes multiple nodes and the data flow between nodes. Nodes are elements in a statement used for data transfer or data storage.
[0107] For example, suppose the code of the business system contains the assignment statement int a = b. The first data flow diagram constructed based on the assignment statement includes two nodes and the data flow between the nodes. The two nodes are node a and node b, where node b is the starting node and node a is the ending node. The data flow between the nodes is: the data flow from node b to node a (node b → node a).
[0108] Since nodes are elements in a statement used for data transfer or storage, meaning any element that involves value storage and value transfer can be considered a node, the following four types of nodes exist in the code of a business system:
[0109] F field: A field of a class or interface.
[0110] R method return: The return value of the method call.
[0111] P method parameters: The parameters defined in the method definition.
[0112] V Local variables: Variables defined within the method body.
[0113] For example, based on the above nodes, there are three types of statements in the business system code that will generate data flow:
[0114] 1. Assignment statement, to expression = from expression:
[0115] 11. This will generate a data flow from (from expression) to (to expression).
[0116] 12. The type of the to expression can be: F / P / V.
[0117] 13. The type of the from expression can be: F / P / V / R.
[0118] 2. Method call statement, methodCall(parameter expression):
[0119] 21. This will generate a data flow from (parameter expression) to (method parameter definition).
[0120] 22. The type of the parameter expression may be: F / R / V / P.
[0121] 3. The return expression of the return statement:
[0122] 31. This will generate a data flow from (return expression) to (method return).
[0123] 32. The type of the returned expression may be: F / R / V / P.
[0124] It should be understood that the code of a business system may also contain other statements that can generate data flow, such as in the copy method: BeanUtil.copyProperties(appDTO, app).
[0125] Furthermore, since data flow refers to the flow between nodes, and there are four types of nodes, if we classify data flow according to the type of node, there are a total of 16 (4×4) types of data flow.
[0126] S203. Merge the same nodes in the first data flow diagram to generate the second data flow diagram.
[0127] In this step, after determining the first data flow diagram, all the first data flow diagrams need to be merged into one to obtain the second data flow diagram of the entire business system.
[0128] In one possible implementation, any two identical nodes in the first data flow graph can be merged to generate a new first data flow graph. This process is repeated until all the first data flow graphs are merged into a single data flow graph.
[0129] For example, suppose one first data flow graph is: node b → node a, and another first data flow graph is: node c → node b. Then, the nodes b in the two first data flow graphs are merged to obtain a new first data flow graph, which is: node c → node b → node a.
[0130] In another possible implementation, merging can be performed according to a pre-defined merging rule, which can be: statement → method → class → project (business system). Specifically, S203 can be implemented through the following steps (3) to (5):
[0131] Step (3): For all first data flow graphs, merge the same nodes in the first data flow graphs belonging to the same method to generate multiple third data flow graphs.
[0132] Step (4): For all third data flow graphs, merge the same nodes in the third data flow graphs belonging to the same category to generate multiple fourth data flow graphs.
[0133] Step (5): Merge all identical nodes in the fourth data flow graph to generate the second data flow graph.
[0134] It should be understood that the merging method of the third data flow diagram is the same as that of the fourth data flow diagram, and can be referred to the merging method of the first data flow diagram mentioned above, which will not be repeated here.
[0135] In other words, we can first merge the first data flow graphs corresponding to all statements within a static code block or method to construct a third data flow graph at the method level, then merge the third data flow graphs at the method level to construct a fourth data flow graph at the class level, and finally merge the fourth data flow graphs at the class level to construct a second data flow graph for the entire business system.
[0136] In the above implementation, by merging the data flow diagrams layer by layer according to level, the data flow diagrams corresponding to different levels in the business system are obtained, so that when a problem occurs in the second data flow diagram, the error location can be found layer by layer downwards.
[0137] Furthermore, FIG. 3 This is a structural diagram of a second data flow graph provided in an embodiment of this disclosure. For example...FIG. 3 As shown, each circle represents a node, and the arrows between the circles indicate the data flow between them. The code is a data flow statement that includes the corresponding node and the data flow between nodes.
[0138] For example, field F1 can be User.id, the parameter of method P can be App.setUserld().p, the local variable V can be int id, and field F1 can be App.userld.
[0139] For example, code 1 could be:
[0140]
[0141]
[0142] It should be understood that only Code 1, Code 2 and Code 3 are used as examples here. Code 1, Code 2 and Code 3 can also have other forms of expression, which will not be elaborated here.
[0143] S204. Construct a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes.
[0144] In this step, since relationships exist between entities corresponding to different database tables, the corresponding application must have data flow. Therefore, after determining the second data flow diagram, the entities corresponding to all databases with data flow can be identified based on the second data flow diagram and the identification strategy, thereby constructing a data model.
[0145] The identification strategy is pre-set based on the business requirements of the business system.
[0146] The computing device can determine the data flow between entities based on the second data flow diagram and the attributes of the entities corresponding to each database table. Then, based on the data flow between entities and the identification strategy, it can determine the pointing relationship between entities. Finally, based on the pointing relationship between entities and each entity, it can construct a data model.
[0147] Optionally, the data model can be an ER model.
[0148] The data model construction method provided in this disclosure involves a computing device parsing the code of a business system to obtain the entities and attributes corresponding to each database table. For each statement in the business system code that generates data flow, a corresponding first data flow diagram is generated. Identical nodes in multiple first data flow diagrams are merged to generate a second data flow diagram. Based on the second data flow diagram, an identification strategy, each entity, and its corresponding attributes, a data model is constructed. In this technical solution, based on the business system code, a second data flow diagram of the entire business system is obtained. Based on this second data flow diagram, it is determined whether relationships exist between entities corresponding to each database table, thereby constructing the data model of the business system. This replaces the manual construction process and effectively improves the efficiency and accuracy of the construction process.
[0149] based on FIG. 2 The embodiment shown will now be further described in detail below. FIG. 4 A flowchart illustrating a method for constructing a data model according to another embodiment of this disclosure. (See flowchart for example.) FIG. 4 As shown, S204 may include the following steps:
[0150] S401. Determine the data flow direction between entities based on the second data flow diagram and the attributes of the entities corresponding to each database table.
[0151] In this step, after determining the second data flow diagram, it is possible to determine whether there is a data flow between entities, so that after determining that there is a data flow between entities, it is possible to further determine whether there is a relationship between entities.
[0152] In one possible implementation, in the second data flow graph, if the first node of the second data flow graph is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
[0153] For example, suppose node a is of field type (F) and belongs to entity A. Then search for all downstream nodes. If there is a downstream node b that is also of field type (F) and belongs to entity B, then it is considered that there is a data flow from field a of entity A to field b of entity B.
[0154] For example, a downstream node is a node located after the current node in the direction of data flow. For instance... FIG. 3 As shown, the node returned by the R method and the node in field F2 are both downstream nodes of field F1.
[0155] S402. Determine the pointing relationship between entities based on the data flow between entities and the identification strategy.
[0156] In this step, after determining the data flow direction between entities, it is possible to determine whether there is a pointing relationship (also known as a relationship) between entities with data flow direction based on the identification strategy.
[0157] For example, the identification strategy is pre-set according to the business needs of the business system. The identification strategy will be explained and illustrated with two specific examples below.
[0158] Identification Strategy 1:
[0159] If there is a unidirectional data flow between fields of different entities, then the two entities are considered to be related.
[0160] If fields of the same entity show data flow, they are considered unrelated.
[0161] Direction of the relationship:
[0162] If there is only a one-way data flow, the relationship direction is the same as the data flow direction.
[0163] If bidirectional data flow exists:
[0164] If one field is a primary key and the other is a non-primary key, the relationship is considered to be: non-primary key → primary key.
[0165] If both are primary keys, then they are considered unrelated.
[0166] If both are non-primary keys, then they are considered unrelated.
[0167] Identification Strategy Two:
[0168] If the attribute of the terminating node is a primary key, then it is assumed that there is a pointing relationship between the starting node and the terminating node.
[0169] Optionally, if the business system has some special scenarios that can generate data streams, such as the existence of a copy method: BeanUtil.copyProperties(appDTO, app), then the entity F→entity F pointer relationship can be directly generated.
[0170] S403. Construct a data model based on the pointing relationships between entities and each entity.
[0171] In this step, after determining the pointing relationships between entities, the corresponding entities can be associated based on these relationships to generate a data model.
[0172] In the above embodiments, the computing device determines the data flow direction between entities through the second data flow diagram, and further determines whether there is a pointing relationship between entities with data flow directions based on the identification strategy, thereby constructing a data model. In this way, after subsequent changes to the business system code, the second data flow diagram can be updated synchronously, and the data model can be updated synchronously based on the updated second data flow diagram, eliminating the need for manual maintenance, greatly reducing maintenance costs, and preventing inconsistencies between the business system code and the data model, thus ensuring data accuracy.
[0173] Based on any of the above embodiments, when constructing the first data flow diagram, it is necessary to identify nodes in the statements that can generate data flow. Furthermore, when merging different data flow diagrams, it is necessary to identify identical nodes. Therefore, each node in the data flow diagram must have a unique identifier within the business system to ensure accurate identification. The definition scheme for node identifiers will be explained in detail below.
[0174] For example, the identifiers of each node can be represented in the following way:
[0175] F field: F / fully qualified class name / field name.
[0176] The R method returns: R / fully qualified class name / method signature.
[0177] P parameter: P / fully qualified class name / method signature / parameter name.
[0178] V local variables: V / fully qualified class name / method signature / variable name / line number.
[0179] It should be understood that the reason why local variables in V need line numbers is because there may be cases where variable names in different scopes within a method are duplicated.
[0180] Exemplary Medium
[0181] After introducing the methods of exemplary embodiments of this disclosure, the following references are made. FIG. 5 The storage medium of the exemplary embodiments of this disclosure will be described.
[0182] FIG. 5 This is a structural diagram of a storage medium provided according to an embodiment of the present disclosure. (See reference...) FIG. 5 As shown, the storage medium 50 stores a program product for implementing the above-described method according to an embodiment of the present disclosure. This program product may be a portable compact disc read-only memory (CD-ROM) and includes computer-executable instructions for causing a computing device to execute the data model construction method provided in this disclosure. However, the program product of this disclosure is not limited thereto.
[0183] The program product may employ any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0184] A readable signal medium may include data signals propagated in baseband or as part of a carrier wave, carrying computer-executed instructions. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium.
[0185] Computer-executable instructions for performing the operations disclosed herein can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java and C++, and conventional procedural programming languages such as C or similar languages. The computer-executable instructions can be executed entirely on the user's computing device, partially on the user's computing device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing devices can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN).
[0186] Exemplary Apparatus
[0187] Having introduced the medium of exemplary embodiments of this disclosure, the following references are made to... FIG. 6 The apparatus for constructing a data model according to an exemplary embodiment of the present disclosure will be described. It is used to implement the method in any of the above method embodiments. The implementation principle and technical effect are similar, and will not be repeated here.
[0188] FIG. 6 This is a structural diagram of a data model construction apparatus provided in one embodiment of the present disclosure. FIG. 6 As shown, the data model construction apparatus 600 includes:
[0189] The first processing module 601 is used to parse the code of the business system and obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table.
[0190] The second processing module 602 is used to generate a corresponding first data flow diagram for each statement in the code of the business system that can generate data flow. The first data flow diagram includes multiple nodes and the data flow between nodes. The nodes are elements in the statement used for data transmission or data storage.
[0191] The third processing module 603 is used to merge multiple identical nodes in the first data flow diagram to generate a second data flow diagram.
[0192] The fourth processing module 604 is used to construct a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes. The identification strategy is pre-set according to the business requirements of the business system.
[0193] In one embodiment of this disclosure, the fourth processing module 604 is specifically used for:
[0194] Based on the second data flow diagram and the attributes of the entities corresponding to each database table, the data flow between entities is determined.
[0195] The directional relationships between entities are determined based on the data flow between entities and the identification strategy.
[0196] Construct a data model based on the pointing relationships between entities and each entity.
[0197] In another embodiment of this disclosure, the fourth processing module 604 is specifically used for:
[0198] In the second data flow diagram, if the first node of the second data flow diagram is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the data flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
[0199] In another embodiment of this disclosure, the fourth processing module 604 is specifically used for:
[0200] The corresponding entities are associated based on the pointing relationships between them to generate a data model.
[0201] In another embodiment of this disclosure, the third processing module 603 is specifically used for:
[0202] For all first data flow diagrams, identical nodes belonging to the same device in the first data flow diagrams are merged to generate multiple third data flow diagrams.
[0203] For all third data flow graphs, identical nodes belonging to the same category in the third data flow graphs are merged to generate multiple fourth data flow graphs.
[0204] Merge all nodes with the same fourth data flow into the graph to generate the second data flow graph.
[0205] In another embodiment of this disclosure, the first processing module 601 is specifically used for:
[0206] The code of the business system is parsed to obtain multiple initial entities and their corresponding attributes.
[0207] The system filters multiple initial entities and identifies the entity corresponding to each database table and the attributes of that entity.
[0208] In another embodiment of this disclosure, the data model is an ER model.
[0209] The data model construction apparatus provided in this disclosure can be used to execute the data model construction method in any of the above embodiments. Its implementation principle and technical effect are similar, and will not be described again here.
[0210] Exemplary Computing Device
[0211] Having described the methods, media, and apparatus of exemplary embodiments of this disclosure, the following references... FIG. 7 A computing device according to an exemplary embodiment of the present disclosure will be described.
[0212] FIG. 7 This is a structural diagram of a computing device provided in an embodiment of the present disclosure. FIG. 7 The computing device 70 shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.
[0213] like FIG. 7 As shown, the computing device 70 is presented in the form of a general-purpose computing device. The components of the computing device 70 may include, but are not limited to: at least one processing unit 701, at least one storage unit 702, and a bus 703 connecting different system components (including the processing unit 701 and the storage unit 702). The at least one storage unit 702 stores computer-executable instructions; the at least one processing unit 701 includes a processor that executes the computer-executable instructions to implement the methods described above.
[0214] The 703 bus includes a data bus, a control bus, and an address bus.
[0215] Storage unit 702 may include readable media in the form of volatile memory, such as random access memory (RAM) 7021 and / or cache memory 7022, and may further include readable media in the form of non-volatile memory, such as read-only memory (ROM) 7023.
[0216] Storage unit 702 may also include a program / utility 7025 having a set (at least one) program module 7024, such program module 7024 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.
[0217] The computing device 70 can also communicate with one or more external devices 704 (e.g., keyboard, pointing device, etc.). This communication can be performed via the input / output (I / O) interface 705. Furthermore, the computing device 70 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via a network adapter 706. FIG. 7 As shown, network adapter 706 communicates with other modules of computing device 70 via bus 703. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with computing device 70, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0218] It should be noted that although several units / modules or sub-units / modules of the data model construction apparatus have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.
[0219] Furthermore, although the operations of the methods disclosed herein are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0220] While the spirit and principles of this disclosure have been described with reference to several specific embodiments, it should be understood that this disclosure is not limited to the disclosed specific embodiments, and the division of aspects does not imply that features in these aspects cannot be combined for benefit; such division is merely for convenience of expression. This disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A method for constructing a data model, comprising: The code of the business system is parsed to obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table; For each statement in the code of the business system that can generate data flow, a corresponding first data flow diagram is generated. The first data flow diagram includes multiple nodes and the data flow between nodes. The nodes are elements in the statement used for data transmission or data storage. For all first data flow graphs, merge the same nodes in the first data flow graphs belonging to the same method to generate multiple third data flow graphs; For all third data flow graphs, merge identical nodes in the same category of third data flow graphs to generate multiple fourth data flow graphs; Merge all identical nodes in the fourth data flow diagram to generate a second data flow diagram; construct a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes, wherein the identification strategy is pre-set according to the business requirements of the business system.
2. The method according to claim 1, wherein constructing a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes includes: Based on the second data flow diagram and the attributes of the entities corresponding to each database table, the data flow between entities is determined; The pointing relationship between entities is determined based on the data flow between the entities and the identification strategy; The data model is constructed based on the pointing relationships between the entities and each entity.
3. The method according to claim 2, wherein determining the data flow direction between entities based on the second data flow diagram and the attributes of the entities corresponding to each database table includes: In the second data flow diagram, if the first node of the second data flow diagram is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the data flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
4. The method according to claim 2, wherein constructing the data model based on the pointing relationships between the entities and each entity comprises: The corresponding entities are associated based on the pointing relationships between them to generate the data model.
5. The method according to any one of claims 1 to 4, wherein parsing the code of the business system to obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table includes: The code of the business system is parsed to obtain multiple initial entities and their corresponding attributes; The plurality of initial entities are filtered to identify the entity corresponding to each database table and the attributes of the entity corresponding to the database table from the plurality of initial entities.
6. The method according to any one of claims 1 to 4, wherein the data model is an entity-relationship (ER) model.
7. A data model construction apparatus, comprising: The first processing module is used to parse the code of the business system and obtain the entity corresponding to each database table and the attributes of the entity corresponding to the database table. The second processing module is used to generate a corresponding first data flow diagram for each statement in the code of the business system that can generate data flow direction. The first data flow diagram includes multiple nodes and the data flow direction between nodes. The nodes are elements in the statement used for data transmission or data storage. The third processing module is used to merge identical nodes in the first data flow graphs belonging to the same device to generate multiple third data flow graphs; to merge identical nodes in the third data flow graphs belonging to the same category to generate multiple fourth data flow graphs; and to merge identical nodes in all fourth data flow graphs to generate a second data flow graph. The fourth processing module is used to construct a data model based on the second data flow diagram, the identification strategy, each entity and its corresponding attributes. The identification strategy is preset according to the business requirements of the business system.
8. The apparatus according to claim 7, wherein the fourth processing module is specifically used for: Based on the second data flow diagram and the attributes of the entities corresponding to each database table, the data flow between entities is determined; The pointing relationship between entities is determined based on the data flow between the entities and the identification strategy; The data model is constructed based on the pointing relationships between the entities and each entity.
9. The apparatus according to claim 8, wherein the fourth processing module is specifically used for: In the second data flow diagram, if the first node of the second data flow diagram is an attribute of the first entity, the second node downstream of the first node is an attribute of the second entity, and the type of the first node is the same as that of the second node, then the data flow from the first entity to the second entity is determined as the data flow between the first entity and the second entity.
10. The apparatus according to claim 8, wherein the fourth processing module is specifically used for: The corresponding entities are associated based on the pointing relationships between them to generate the data model.
11. The apparatus according to any one of claims 7 to 10, wherein the first processing module is specifically configured to: The code of the business system is parsed to obtain multiple initial entities and their corresponding attributes; The plurality of initial entities are filtered to identify the entity corresponding to each database table and the attributes of the entity corresponding to the database table from the plurality of initial entities.
12. The apparatus according to any one of claims 7 to 10, wherein the data model is an entity-relationship (ER) model.
13. A storage medium storing computer program instructions that, when executed, implement the method as described in any one of claims 1 to 6.
14. A computing device, comprising: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Information processing method and device
CN104199831A