Method and device for generating data model

CN118556232APending Publication Date: 2024-08-27SIEMENS AG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202180104732.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2021-11-30
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

For large and medium-sized enterprises, due to the complex database table structure in the application system developed by third-party companies, it is difficult for the enterprise to conduct independent research and development. The efficiency and accuracy of the existing technology are low, and there are shortcomings in relying on manual analysis or database schema analysis.

Method used

By obtaining the data access statement sent by the client, analyzing the identification of the target table and target column, and combining the data type and table structure, a data model closely related to the target business is generated to avoid relying on manual experience and schema reference foreign keys.

Benefits of technology

It improves the accuracy and efficiency of data model generation, can dynamically perceive the tables and columns used in business databases, and generates data models closely related to the business, which is suitable for complex enterprise-level application systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118556232A
    Figure CN118556232A
Patent Text Reader

Abstract

Embodiments of the invention provide a data model generation method and apparatus, which can generate a data model closely related to a target service with relatively high accuracy and efficiency, so that an enterprise can perform independent research and development based on the generated data model. The data model generation method comprises the steps of obtaining a data access statement sent to a database by a user side, wherein the data access statement is used for accessing data of a target service in the database; according to the data access statement, obtaining an identifier of each target table in at least one target table in the database called by the target service and an identifier of a target column in the target table; determining the data type of the target column according to the identifier of the target table and the organization and structure of the table in the database; and determining a data model of the database according to the identifier of the target table, the identifier of the target column and the data type.
Need to check novelty before this filing date? Find Prior Art

Description

Method and device for generating data model Technical Field

[0001] The present application relates to the field of database technology, and more specifically, to a method and device for generating a data model. Background Art

[0002] Currently, large and medium-sized enterprises may have numerous application systems, and the distribution and structure of database tables within these application systems are relatively complex. Because these application systems are often implemented or developed by third-party companies, enterprises often lack knowledge of which tables and columns in the underlying databases are used by the business modules within these application systems. This creates significant challenges for future independent R&D.

[0003] Summary of the Invention

[0004] This application provides a method and device for generating a data model, which can generate a data model closely related to the target business with high accuracy and efficiency, allowing enterprises to conduct independent research and development based on the generated data model.

[0005] In a first aspect, a method for generating a data model is provided, comprising: obtaining a data access statement sent by a user terminal to a database, the data access statement being used to access data of a target business in the database; obtaining, according to the data access statement, an identifier of each target table in at least one target table in the database called by the target business and an identifier of a target column in the target table; determining, according to the identifier of the target table and the organization and structure of the tables in the database, a data type of the target column; and determining a data model of the database according to the identifier of the target table, the identifier of the target column and the data type.

[0006] When a user operates an application system (e.g., accessing data for a target business), data access statements related to the user's operation are sent from the user end to the database. Therefore, the data access statements obtained by the above technical solution are closely related to the target business accessed by the user, and the data model generated based on these data access statements is also closely related to the target business accessed by the user, effectively avoiding the problem of generating a large number of invalid data models. Furthermore, the above technical solution does not rely on manual experience, effectively improving the efficiency and accuracy of data model generation.

[0007] In some possible implementations, obtaining the data access statement sent by the user terminal to the database includes filtering multiple information generated based on the target business to obtain the data access statement, wherein the multiple information includes the data access statement.

[0008] Based on the target business, multiple pieces of information may be generated, including other information in addition to data access statements. The above technical solution filters the multiple pieces of information to remove information other than the data access statements. In this way, the remaining information is data access statements closely related to the target business, thereby further avoiding the problem of generating a large number of invalid data models.

[0009] In some possible implementations, obtaining the identifier of each target table and the identifier of the target column in at least one target table in the database called by the target business based on the data access statement includes: when the data access statement is a query statement, extracting a first character string between the from keyword and the condition keyword in the query statement, the first character string being the identifier of the target table; extracting a second character string between the select keyword and the from keyword in the query statement, the second character string being the identifier of the target column.

[0010] In some possible implementations, when the query statement is a join query statement and the at least one target table includes multiple target tables, the method further includes: obtaining the relationship between the multiple target tables on the target business according to the join query statement; determining the data model of the database based on the identifier of the target table, the identifier of the target column and the data type, includes: determining the data model based on the identifier of the target table, the identifier of the target column, the relationship between the multiple target tables on the target business and the data type.

[0011] This technical solution leverages the structural information in data access statements to analyze the potential relationships between tables and generates a data model based on these relationships. Because it doesn't rely on reference foreign keys in the database schema, it avoids the drawback of inaccurate or even impossible data model generation due to the absence of reference foreign keys in the database schema, further improving the accuracy of the generated data model.

[0012] In some possible implementations, obtaining the relationship between the multiple target tables on the target business based on the connection query statement includes: obtaining the relationship between the multiple target tables on the target business from a third character string following the condition keyword in the connection query statement.

[0013] In some possible implementations, obtaining the identifier of each target table and the identifier of the target column in at least one target table in the database called by the target business based on the data access statement includes: when the data access statement is an insert statement, extracting the fourth character string between the insert keyword and the value keyword in the insert statement, the fourth character string being the identifier of the target table; extracting the fifth character string in the brackets after the value keyword in the insert statement, the fifth character string being the identifier of the target column.

[0014] In some possible implementations, the method further includes: aggregating the identifier of the target table and the identifier of the target column; determining the data model of the database based on the identifier of the target table, the identifier of the target column and the data type, including: determining the data model based on the aggregated identifier of the target table and the identifier of the target column, and based on the data type.

[0015] The above technical solution aggregates the identifiers of the target table and the target column before generating the data model. Compared with the identifiers of the target table and the target column being in a discrete state, it facilitates subsequent operations and helps to improve the efficiency of data model generation.

[0016] In a second aspect, a device for generating a data model is provided, comprising: a memory for storing programs; a processor for executing the programs stored in the memory, wherein when the programs stored in the memory are executed, the processor is used to execute the method in the above-mentioned first aspect or its various implementations.

[0017] In a third aspect, a computer-readable storage medium is provided, storing program code for execution by a device, wherein the program code includes instructions for executing the steps in the method in the above-mentioned first aspect or its various implementations.

[0018] In a fourth aspect, a device for generating a data model is provided, comprising: a preprocessor for obtaining a data access statement sent by a user terminal to a database, wherein the data access statement is used to access the data of a target business in the database; an analyzer for obtaining, according to the data access statement, an identifier of each target table and an identifier of a target column in at least one target table in the database called by the target business; a model generator for determining the data type of the target column according to the identifier of the target table and the organization and structure of the table in the database; the model generator is also used to determine the data model of the database according to the identifier of the target table, the identifier of the target column and the data type.

[0019] In a fifth aspect, a device for generating a data model is provided, comprising units for executing the method in the above-mentioned first aspect or its various implementations. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] FIG1 is a schematic diagram of a system architecture according to an embodiment of the present application.

[0021] FIG2 is a schematic diagram of a method for generating a data model according to an embodiment of the present application.

[0022] FIG3 is a flow chart of a method for generating a data model according to an embodiment of the present application.

[0023] FIG4 is a flowchart of another method for generating a data model according to an embodiment of the present application.

[0024] FIG5 is a schematic block diagram of a device for generating a data model according to an embodiment of the present application.

[0025] FIG6 is a schematic block diagram of another apparatus for generating a data model according to an embodiment of the present application.

[0026] FIG7 is a schematic block diagram of another apparatus for generating a data model according to an embodiment of the present application.

[0027] List of reference numerals:

[0028] 110, user end;

[0029] 120, database;

[0030] 130, third-party equipment;

[0031] 200, a method for generating a data model according to an embodiment of the present application;

[0032] 210, obtaining the data access statement sent by the user end to the database;

[0033] 220. Obtain, according to the data access statement, an identifier of each target table and an identifier of a target column in at least one target table in the database called by the target business;

[0034] 230, determining the data type of the target column according to the identifier of the target table and the organization and structure of the table in the database;

[0035] 240, determining a data model based on the identifier of the target table, the identifier of the target column, and the data type;

[0036] Pr, preprocessor;

[0037] An, analyzer;

[0038] Bu, model generator;

[0039] Re, parse multiple lines of information line by line;

[0040] Fi, filter;

[0041] Di, sends the SQL statement to the corresponding analyzer;

[0042] Tn, get the table name of the target table;

[0043] Cn, get the column name of the target column;

[0044] Dt, gets the data type of the target column;

[0045] Ge, generative data model;

[0046] Second, obtain the relationship;

[0047] As, aggregate;

[0048] 500, a device for generating a data model;

[0049] 510, preprocessor;

[0050] 520, analyzer;

[0051] 530, Model Generator;

[0052] 600, a device generated according to the model;

[0053] 610, acquisition unit;

[0054] 620, determine the unit;

[0055] 700, a device for generating a data model;

[0056] 701, memory;

[0057] 702, processor;

[0058] 703, communication interface;

[0059] 704, bus. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present application are described below in conjunction with the accompanying drawings. It should be understood that the specific examples in this specification are only intended to help those skilled in the art better understand the embodiments of the present application, and are not intended to limit the scope of the embodiments of the present application.

[0061] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0062] It should also be understood that the various implementation methods described in this specification can be implemented individually or in combination, and the embodiments of the present application are not limited to this.

[0063] Unless otherwise specified, all technical and scientific terms used in the embodiments of the present application have the same meaning as those commonly understood by those skilled in the art in the art of the present application. The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit the scope of this application.

[0064] Typically, large and medium-sized enterprises may have a large number of application systems, and the distribution and structure of the database tables in these application systems are relatively complex. Since these application systems are usually implemented or developed by third-party companies, even if the third-party company provides the enterprise with design documents for the application system, sometimes the design documents are incomplete or the specifications in the design documents are inconsistent with the actual application system. Therefore, the enterprise does not know which tables and columns in the underlying database are used by the business modules on these application systems, which greatly complicates the enterprise's future independent research and development. For example, an enterprise needs to upgrade and transform the application system based on the data of the existing application system or expand its business.

[0065] Currently, two methods are commonly used in the industry to solve the above problem. The first is a method based on manual analysis. Specifically, this method mainly involves manually sorting the columns (or fields) and data on the interactive forms used by various application systems when processing various business operations, and finding the columns and data in the database tables that match these columns and data. This information is then summarized and organized, and ultimately the database tables and corresponding columns that the application system may call are analyzed. For example, if the application system is a financial system and a user needs to query the sales figures for each quarter of the year, after the user's query, the financial system outputs the data "A", "B", "C", and "D". The user can then reversely search for "A", "B", "C", and "D" in the database. Alternatively, the user can identify several data points with characteristics among "A", "B", "C", and "D", and then search for "C" and "D" in the database, ultimately analyzing the database tables and corresponding columns that the financial system may call.

[0066] This method relies heavily on manual experience, resulting in relatively low efficiency and accuracy, especially when dealing with databases containing large numbers of tables. Furthermore, since the computational logic behind form submissions in an application system may involve aggregate queries and processing across numerous tables or intermediate table structures, these queries and processing cannot be visually visualized through the user interface (UI). Therefore, manual parsing methods may overlook many underlying data models, resulting in inaccurate data models.

[0067] The second method is based on the analysis of the organization and structure (Schema) of the tables in the database. Specifically, this method calls the relevant interfaces of the application system's corresponding database to obtain the table structure and relationships of all databases in the current application system, and finally generates a data model in reverse.

[0068] Since this method cannot dynamically detect which tables in a business database have been accessed, it cannot help users effectively sort out the data models currently used by the application system. For example, there are 1,000 tables in the database. When a user accesses the data of a certain business, the application system may only use 100 of them. However, since this method cannot know which 100 of the 1,000 tables are used, it can only generate reverse data models for all 1,000 tables, which takes a long time and is inefficient. In addition, since the database may contain data generated by non-human-computer interaction or data unrelated to the business currently accessed by the user, the generated data model may be out of touch with the business and unrelated to the business currently accessed by the user.

[0069] Furthermore, the relationships in the data model generated by this method are highly dependent on the reference foreign keys in the database tables. If this information is not present in the tables, the data model relationships cannot be generated. Numerous real-world production environments have shown that larger enterprise systems are less likely to contain such strong reference foreign key relationships. Therefore, this method is not very feasible in real-world production environments.

[0070] In view of this, an embodiment of the present application proposes a method for generating a data model, which can generate a data model closely related to the target business with high accuracy and efficiency, so that enterprises can conduct independent research and development based on the generated data model.

[0071] FIG1 is a schematic diagram of a system architecture according to an embodiment of the present application.

[0072] The system architecture shown in Figure 1 includes a user terminal 110, a database 120, and a third-party device 130. The user terminal 110 may be an interface for providing data query service management. The user terminal 110 may also be referred to as a client or other names.

[0073] Database 120 may be, for example, MySQL, Oracle, SQL Server, or SQLite. Information can be transmitted between client 110 and database 120. For example, when a user needs to query data, such as sales figures for each quarter of a year, they can enter query information into client 110. After receiving the query information, client 110 converts the query information into a database language, such as structured query language (SQL), and sends the database language to database 120. Database 120 then queries for sales figures for each quarter of the year based on the received database language and sends the query results to client 110. Client 110 can then output the query results to the user, allowing the user to obtain sales figures for each quarter of the year.

[0074] The third-party device 130 can be connected to the user terminal 110 and the database 120 in communication to obtain information transmitted between the user terminal 110 and the database 120, and perform some operations based on the information, such as generating a data model of the database 120. Specifically, the third party 130 may include a communication interface to achieve a communication connection with other devices (such as the user terminal 110). The communication connection can be wired or wireless. The third-party device 130 can obtain the information during the information transmission process; or, if the user terminal 110 sends information to the database 120, the third-party device 130 can obtain the information from the database 120 after the information is sent to the database 120.

[0075] For example, the third-party device 130 may be a server. A server is a device that provides computing services and includes a processor, hard disk, memory, and system bus. While similar to general computer architecture, servers must provide highly reliable services and therefore have higher requirements for processing power, stability, reliability, security, scalability, and manageability.

[0076] It should be understood that FIG1 is merely a schematic diagram of a system architecture provided in an embodiment of the present application, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation.

[0077] The main process of the method for generating a data model according to an embodiment of the present application will be introduced below in conjunction with FIG2 .

[0078] Figure 2 shows a schematic flow chart of a method 200 for generating a data model according to an embodiment of the present application. Method 200 may be performed by a third-party device other than the user terminal and the database, such as the third-party device 130 shown in Figure 1. As shown in Figure 2, method 200 may include at least some of the following contents.

[0079] Step 210: Acquire a data access statement sent by the user end to the database, where the data access statement is used to access the data of the target business in the database.

[0080] Step 220: According to the data access statement, obtain the identifier of each target table and the identifier of the target column in each target table in at least one target table in the database called by the target business.

[0081] Step 230: Determine the data type of the target column based on the identifier of the target table and the schema of the database.

[0082] Step 240: Determine the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type.

[0083] When a user operates an application system (such as accessing data for a target business), data access statements related to the user's operation will be sent from the user end to the database. Therefore, the data access statements obtained by the embodiment of the present application are closely related to the target business accessed by the user, and the data model generated based on the data access statements is also closely related to the target business accessed by the user, which can effectively avoid the problem of generating a large number of invalid data models. Furthermore, the above technical solution does not rely on manual experience, and effectively improves the efficiency and accuracy of data model generation.

[0084] In an embodiment of the present application, the third-party device may include a preprocessor, an analyzer, and a model generator. For example, step 210 may be performed by the preprocessor, step 220 may be performed by the analyzer, and steps 230 and 240 may be performed by the model generator. Of course, the third-party device may also include other devices, such as a data type processor. In this case, step 210 may be performed by the preprocessor, step 220 may be performed by the analyzer, step 230 may be performed by the data type processor, and step 240 may be performed by the model generator. For the convenience of description, the following will describe the method of the embodiment of the present application by taking step 210 being performed by the preprocessor, step 220 being performed by the analyzer, and steps 230 and 240 being performed by the model generator as an example.

[0085] As an example, the preprocessor may obtain data access statements through a plug-in provided by the database, such as a command line tool.

[0086] As another example, the preprocessor may enable a certain option and then monitor the data access statement sent by the user end to the database, thereby obtaining the data access statement.

[0087] Optionally, the preprocessor may obtain the data access statement from the database, or may obtain the data access statement during the process of transmitting the data access statement from the user end to the database.

[0088] Optionally, data access statements may include but are not limited to SQL statements. The embodiments of the present application are illustrated using SQL statements as examples. SQL statements may include data definition language (DDL) and data manipulation language (DML), and the SQL statements of the embodiments of the present application are DML statements. DML statements may include insert statements, delete statements, update statements, and query (select) statements. Considering that the granularity of delete statements and update statements is too small, such as usually deleting a column or modifying a column, it may be impossible to analyze the data model based on the delete statement and update statement. Therefore, the SQL statement of the embodiments of the present application is a select statement or an insert statement.

[0089] If the SQL statements are obtained from the database by the preprocessor, the database can generate contextual information based on the SQL statements sent by the client, such as a timestamp, session ID, or process ID. In other words, the database can generate multiple pieces of information based on the target business, including not only multiple SQL statements but also other information. Furthermore, even SQL statements may include both delete and update statements.

[0090] Alternatively, if the SQL statement is obtained during transmission from the user end to the database, then in addition to the SQL statement, the user end may also transmit other information to the database.

[0091] Therefore, step 210 may specifically include: the preprocessor filters multiple information generated based on the target business, filters out other information except SQL statements in the multiple information, and filters out delete statements and update statements in the SQL statements to obtain select statements or insert statements.

[0092] This technical solution filters the multiple information to remove information other than data access statements. In this way, the remaining information is data access statements closely related to the target business, thereby further avoiding the problem of generating a large number of invalid data models.

[0093] The preprocessor may receive multiple lines of information at the same time. Therefore, optionally, as shown in FIG3 and FIG4 , the preprocessor may also parse the received multiple lines of information line by line, and then filter each line of information to obtain an SQL statement.

[0094] Alternatively, in an embodiment of the present application, the identifier of the target table may be the target table name, the target table ID, or the target table number among all tables in the database. Similar to the identifier of the target table, the identifier of the target column may be the target column name, the target column ID, or the target column number within the target table. The following description will take the target table identifier as the table name and the target column identifier as the column name as an example.

[0095] For select statements and insert statements, the analyzer obtains the target table name and target column name in different ways.

[0096] Specifically, for select statements, the analyzer can extract the first string between the from keyword and the condition keyword in the select statement. This first string is the table name of the target table. For example, if the select statement is select col1,col2,col3 from table_1where…, and the string between the from keyword and the condition keyword in this select statement is table_1, the extracted table name is table_1. For another example, if the select statement is select col1,col2,col3 from table_1 left join table_2 on…, and the strings between the from keyword and the condition keyword in this select statement are table_1 and table_2, the extracted table names are table_1 and table_2.

[0097] If the analyzer extracts multiple first character strings, the multiple first character strings can be separated by commas to obtain a set of table names, such as [table_1, table_2] in the above text.

[0098] Additionally, the analyzer can extract the second string between the select keyword and the from keyword in a select statement. This second string is the target column name. If there are multiple column names, they can also be separated by commas. For example, if the select statement is select col1,col2,col3 from table_1 where ..., and the string between the select keyword and the from keyword is col1,col2,col3, then the target column name is [col1,col2,col3].

[0099] For an INSERT statement, specifically, the analyzer may extract the fourth string between the INSERT INTO keyword and the VALUES keyword in the INSERT statement, which is the name of the target table. Furthermore, the analyzer may extract the fifth string within parentheses following the VALUES keyword in the INSERT statement, which is the name of the target column.

[0100] Furthermore, if the select statement is a join query statement, such as the select col1, col2, col3 from table_1 left join table_2 on ... statement described above, and the target table includes multiple target tables, then as shown in FIG4 , method 200 may further include: the analyzer obtaining, based on the join query statement, the relationships between the multiple target tables in the target business. In other words, the analyzer may obtain, based on the join query statement, the columns by which the multiple target tables are related in the target business.

[0101] Specifically, the analyzer can extract the relationships between multiple target tables in the target business from the third string following the condition keyword in a join query. For example, if the join query is select col1,col2,col3 from table_1 left join table_2 on table_1.col1 = table_2.col2, it can be seen that there is a relationship between table_1 and table_2, and that they are linked together by the columns named col1 and col2. That is, the value of the column named col1 in table_1 and the value of the column named col2 in table_2 reference each other, and the value of the column named col2 in table_2 is derived from the value of the column named col1 in table_1.

[0102] After determining the relationship between table_1 and table_2, you can concatenate table1, col1, table2, and col2 to form a four-tuple [table1, col1, table2, col2]. This four-tuple indicates that table_1 and table_2 are associated through the column named col1 in table_1 and the column named col2 in table_2.

[0103] If the join query statement includes multiple joins, you can extract the third string after the condition keyword to obtain a multi-dimensional four-element array. For example:

[0104] [[table1,col1,table2,col2],

[0105] [table2,col2,table3,col3],

[0106] […,…,…,…],

[0107] [tableN-1,colN-1,tableN,colN]]

[0108] In this case, in addition to determining the data model based on the table name of the target table, the column name and data type of the target column, the analyzer can also determine the data model based on the relationship between multiple tables in the target business.

[0109] This technical solution leverages the structural information in data access statements to analyze the potential relationships between tables and generates a data model based on these relationships. Because it doesn't rely on reference foreign keys in the database schema, it avoids the drawback of inaccurate or even impossible data model generation due to the absence of reference foreign keys in the database schema, further improving the accuracy of the generated data model.

[0110] It should be understood that in the embodiments of the present application, "first", "second", "third" and "fourth" are only used to distinguish different objects, but do not limit the scope of the embodiments of the present application.

[0111] It should also be understood that the specific examples in the embodiments of the present application are only intended to help those skilled in the art better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application.

[0112] As can be seen from the above description, the analyzer obtains the target table name and target column name in different ways for select statements and insert statements. Therefore, in one implementation, there can be two analyzers, one of which (for ease of description, referred to as the first analyzer) can obtain the target table name, target column name, and the relationship between multiple target tables in the target business in the select statement, and the other analyzer (referred to as the second analyzer) can obtain the target table name and target column name in the insert statement.

[0113] For example, as shown in Figures 3 and 4, the analyzer in Figure 3 is the second analyzer, which can obtain table names and column names; the analyzer in Figure 4 is the first analyzer, which can obtain table names, column names and relationships between tables.

[0114] In this implementation, before step 220, the preprocessor can determine the type of the SQL statement and then send the SQL statement to the corresponding analyzer, that is, send the select statement to the first analyzer in Figure 4 and send the insert statement to the second analyzer in Figure 3.

[0115] In another implementation, there can be three analyzers, one of which can obtain the table name and column name of the join query statement, another analyzer can obtain the table name and column name of other statements in the select statement except the join query statement, and the remaining analyzer can obtain the table name and column name of the insert statement.

[0116] In another implementation, the analyzer can be one, for example, the analyzer shown in FIG4 . The analyzer can execute three steps: obtaining the table name of the target table in the SQL statement, obtaining the column name of the target column, and obtaining the relationship between multiple target tables in the target business. If the SQL statement is a join query, the analyzer can execute these three steps in sequence. If the SQL statement is another statement (such as an insert statement), the analyzer can skip the step of obtaining the relationship between multiple target tables in the target business and execute only the first two steps.

[0117] To facilitate subsequent model generator processing, optionally, as shown in Figure 4, method 200 may also include: aggregating the table name of the target table and the column name of the target column, or aggregating the table name of the target table, the column name of the target column and the relationship between multiple target tables in the target business.

[0118] Aggregated table and column names can be called a structured result set, or, alternatively, aggregated table names, column names, and relationships can be called a structured result set. A structured result set can be understood as describing an object in a non-discrete manner. For example, when describing what's available in a supermarket, you could describe it as fruits like apples and bananas, daily necessities like laundry detergent and towels, and vegetables like potatoes and tomatoes, rather than describing it as bananas, laundry detergent, potatoes, etc.

[0119] For example, assume there are two target tables, named table_X and table_Y. The target columns in table_X are named col1, col2, and colN, respectively, and the target columns in table_Y are named col1, col2, and colN, respectively. Furthermore, table_X and table_Y are linked together by col1 in table_X and col2 in table_Y. By aggregating the target table names, target column names, and the relationship between the two target tables, we can obtain the following JSON composite structure:

[0120]

[0121]

[0122] The above technical solution aggregates the identifiers of the target table and the target column before generating the data model. Compared with the identifiers of the target table and the target column being in a discrete state, it facilitates subsequent operations and helps to improve the efficiency of data model generation.

[0123] After the analyzer determines the target column name, the model builder also needs to determine the target column's data type. For example, is the target column's data type an integer or a string? Specifically, the model builder extracts the target column's data type from the database schema based on the target table's name, resulting in a list of triples, such as [[table_1,col1,datatype],[table_1,col2,datatype],[table_N,colN,datatype]]. Datatype represents the data type.

[0124] After obtaining the data type of the target column, the model generator can determine the data model of the database based on the table name of the target table, the column name and data type of the target column, or based on the table name of the target table, the column name of the target column, the relationship between multiple target tables in the target business, and the data type.

[0125] Optionally, the table name of the target table can be used as the entity name of the data model, the column name of the target column can be used as the attribute name of the corresponding entity, and the data type of the target column can be used as the data type of the corresponding entity attribute.

[0126] Assume that the target business calls four target tables, named Table_X, Table_Y, Table_Z, and Table_N. The target column in Table_X is named Col_X and has a datatype of Datatype_X; the target column in Table_Y is named Col_Y and has a datatype of Datatype_Y; the target column in Table_Z is named Col_Z and has a datatype of Datatype_Z; and the target column in Table_N is named Col_N and has a datatype of Datatype_N. The generated data model can be shown in Table 1.

[0127] Table 1

[0128]

[0129] Furthermore, if multiple target tables have a relationship in the target business, the table names of the multiple related target tables can be used as the entity names of the multiple related entities, and the column names of the multiple related target columns can be used as the association attributes of the multiple related entities.

[0130] Table 1 is used as an example. Assume that Table_X and Table_Y are related through the column named Col_X in Table_X and the column named Col_Y in Table_Y, and Table_Z and TableN are related through the column named Col_Z in Table_Z and the column named Col_Z in Table_N. The relationships between the multiple entities can be shown in Table 2.

[0131] Table 2

[0132] From_EntityFrom_Attribute_NameTo_EntityTo_Attribute_NameTable_XCol_XTable_YCol_YTable_N-1Col_N-1Table_NCol_N

[0133] The values ​​of from_tab and to_tab are the entity names of the two related entities. From_col and to_col are the associated attributes of the two related entities.

[0134] The data model finally generated based on the INSERT statement and the non-JOIN query statement in the SELECT statement is shown in Table 1. The data model finally generated based on the JOIN query statement is shown in Tables 1 and 2.

[0135] It should be noted that if there are entities with the same name, the analyzer can also expand the attributes of the entities with the same name.

[0136] Optionally, the method 200 may further include: persisting the data model to store the data model in an underlying database.

[0137] The above describes in detail the method embodiments of the embodiments of the present application. The following describes the device embodiments of the embodiments of the present application. The device embodiments and the method embodiments correspond to each other. Therefore, for the parts that are not described in detail, please refer to the previous method embodiments. The device can implement any possible implementation method of the above methods.

[0138] Figure 5 shows a schematic block diagram of a data model generation apparatus 500 according to an embodiment of the present application. The data model generation apparatus 500 can execute the data model generation method 200 according to the embodiment of the present application, and the data model generation apparatus 500 can be a third-party device in the aforementioned method.

[0139] As shown in FIG5 , the data model generating apparatus 500 may include:

[0140] The preprocessor 510 is configured to obtain a data access statement sent by a user terminal to a database, where the data access statement is used to access data of a target business in the database.

[0141] The analyzer 520 is configured to obtain, according to the data access statement, an identifier of each target table and an identifier of a target column in at least one target table in the database called by the target business.

[0142] The model generator 530 is configured to determine the data type of the target column according to the identifier of the target table and the organization and structure of the table in the database.

[0143] The model generator 530 is further configured to determine the data model of the database according to the identifier of the target table, the identifier of the target column, and the data type.

[0144] Optionally, in one embodiment of the present application, the preprocessor 510 is specifically configured to filter a plurality of information generated based on the target business to obtain the data access statement, wherein the plurality of information includes the data access statement.

[0145] Optionally, in one embodiment of the present application, the analyzer 520 is specifically used to: when the data access statement is a query statement, extract a first string between the from keyword and the condition keyword in the query statement, the first string being the identifier of the target table; extract a second string between the select keyword and the from keyword in the query access statement, the second string being the identifier of the target column.

[0146] Optionally, in one embodiment of the present application, when the query statement is a join query statement and the at least one target table includes multiple target tables, the analyzer 520 is specifically used to: obtain the relationship between the multiple target tables on the target business according to the join query statement; determine the data model according to the identifier of the target table, the identifier of the target column, the relationship between the multiple target tables on the target business, and the data type.

[0147] Optionally, in one embodiment of the present application, the analyzer 520 is specifically configured to: obtain the relationship between the multiple target tables on the target business from a third character string following the condition keyword in the connection query statement.

[0148] Optionally, in one embodiment of the present application, the analyzer 520 is specifically used to: when the data access statement is an insert statement, extract the fourth string between the insert keyword and the value keyword in the insert statement, and the fourth string is the identifier of the target table; extract the fifth string in the brackets after the value keyword in the insert statement, and the fifth string is the identifier of the target column.

[0149] Optionally, in one embodiment of the present application, the analyzer 520 is further used to aggregate the identifier of the target table and the identifier of the target column; the model generator 530 is specifically used to determine the data model based on the aggregated identifier of the target table and the identifier of the target column, and based on the data type.

[0150] It should be understood that the preprocessor 510, the analyzer 520 and the model generator 530 can respectively implement the corresponding operations of the preprocessor, the analyzer and the model generator in the method 200. For the sake of brevity, they are not described here in detail.

[0151] Figure 6 shows a schematic block diagram of a data model generation apparatus 600 according to another embodiment of the present application. The data model generation apparatus 600 can execute the data model generation method 200 of the embodiment of the present application, and the data model generation apparatus 600 can be a third-party device in the aforementioned method.

[0152] As shown in FIG6 , the data model generating apparatus 600 may include:

[0153] The acquiring unit 610 is configured to acquire a data access statement sent by a user terminal to a database, where the data access statement is used to access data of a target business in the database.

[0154] The acquisition unit 610 is further configured to acquire, according to the data access statement, an identifier of each target table and an identifier of a target column in at least one target table in the database called by the target service.

[0155] The determining unit 620 is configured to determine the data type of the target column according to the identifier of the target table and the organization and structure of the table in the database.

[0156] The determining unit 620 is further configured to determine the data model of the database according to the identifier of the target table, the identifier of the target column, and the data type.

[0157] Optionally, in an embodiment of the present application, the acquisition unit 610 is specifically configured to filter a plurality of information generated based on the target business to obtain the data access statement, wherein the plurality of information includes the data access statement.

[0158] Optionally, in one embodiment of the present application, the acquisition unit 610 is specifically used to: when the data access statement is a query statement, extract a first string between the from keyword and the condition keyword in the query statement, the first string being the identifier of the target table; extract a second string between the select keyword and the from keyword in the query statement, the second string being the identifier of the target column.

[0159] Optionally, in one embodiment of the present application, when the query statement is a join query statement and the at least one target table includes multiple target tables, the acquisition unit 610 is specifically used to: obtain the relationship between the multiple target tables on the target business according to the join query statement; determine the data model according to the identifier of the target table, the identifier of the target column, the relationship between the multiple target tables on the target business, and the data type.

[0160] Optionally, in an embodiment of the present application, the acquiring unit 610 is specifically configured to acquire the relationship between the multiple target tables on the target business from a third character string following the condition keyword in the connection query statement.

[0161] Optionally, in one embodiment of the present application, the acquisition unit 610 is specifically used to: when the data access statement is an insert statement, extract the fourth string between the insert keyword and the value keyword in the insert statement, and the fourth string is the identifier of the target table; extract the fifth string within the value keyword query brackets in the insert statement, and the fifth string is the identifier of the target column.

[0162] Optionally, in one embodiment of the present application, the data model generation device 600 also includes an aggregation unit for aggregating the identifier of the target table and the identifier of the target column; the determination unit 620 is specifically used to: determine the data model based on the identifier of the target table and the identifier of the target column after aggregation, and based on the data type.

[0163] Figure 7 is a schematic diagram of the hardware structure of an apparatus 700 for generating a data model according to an embodiment of the present application. The apparatus 700 for generating a data model shown in Figure 7 can be a third-party device and includes a memory 701, a processor 702, a communication interface 703, and a bus 704. The memory 701, processor 702, and communication interface 703 are connected to each other via a bus 704.

[0164] The memory 701 may be a read-only memory (ROM), a static storage device, or a random access memory (RAM). The memory 701 may store programs. When the program stored in the memory 701 is executed by the processor 702, the processor 702 and the communication interface 703 are used to perform the various steps of the method for generating a data model according to the embodiment of the present application.

[0165] The processor 702 can adopt a general-purpose CPU, a microprocessor, an application specific integrated circuit (ASIC), a graphics processing unit (GPU) or one or more integrated circuits to execute relevant programs to implement the functional functions required to be performed by the units in the device of the embodiment of the present application, or to execute the method for generating a data model of the embodiment of the present application.

[0166] The processor 702 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the method for generating a data model in the embodiment of the present application may be completed by hardware integrated logic circuits in the processor 702 or software instructions.

[0167] The processor 702 may also be a general-purpose processor, a digital signal processor (DSP), an ASIC, a field programmable gate array (FPGA), or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. The various methods, steps, and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the methods disclosed in the embodiments of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, or the like. The storage medium is located in the memory 701, and the processor 702 reads the information in the memory 701 and, in combination with its hardware, completes the functional functions required to be executed by the units included in the apparatus of the embodiments of the present application, or executes the method for generating a data model of the embodiments of the present application.

[0168] The communication interface 703 uses a transceiver device such as, but not limited to, a transceiver to implement communication between the data model generating apparatus 700 and other devices or a communication network.

[0169] The bus 704 may include a path for transmitting information between various components of the apparatus 700 for data model generation (eg, the memory 701 , the processor 702 , and the communication interface 703 ).

[0170] It should be noted that although the above-mentioned device 700 for generating a data model only shows a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 700 for generating a data model may also include other devices necessary for normal operation. At the same time, according to specific needs, those skilled in the art should understand that the device 700 for generating a data model may also include hardware devices for implementing other additional functional functions. In addition, those skilled in the art should understand that the device 700 for generating a data model may also include only the devices necessary to implement the embodiments of the present application, and does not necessarily include all the devices shown in Figure 7.

[0171] An embodiment of the present application also provides a computer-readable storage medium that stores program code for execution by a device, wherein the program code includes instructions for executing the steps in the above-mentioned method for generating a data model.

[0172] An embodiment of the present application also provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the above-mentioned data model generation method.

[0173] The aforementioned computer-readable storage medium may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.

[0174] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0175] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0176] The terms used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms "a" and "the" are intended to also include plural forms. Similarly, the terms "and / or" as used in this application refer to any and all possible combinations of one or more associated listings. In addition, when used in this application, the term "comprising" refers to the existence of stated features, wholes, steps, operations, elements, and / or components, but does not exclude the existence or addition of one or more other features, wholes, steps, operations, elements, components and / or these groups.

[0177] The various aspects, implementations, implementations, or features of the described embodiments can be used individually or in any combination. The various aspects of the described embodiments can be implemented by software, hardware, or a combination of software and hardware. The described embodiments can also be embodied by a computer-readable medium storing computer-readable code, the computer-readable code comprising instructions executable by at least one computing device. The computer-readable medium can be associated with any data storage device capable of storing data that can be read by a computer system. Exemplary computer-readable media can include read-only memory, random access memory, compact disc read-only memory (CD-ROM), hard disk drive (HDD), digital video disc (DVD), magnetic tape, and optical data storage devices. The computer-readable medium can also be distributed among computer systems connected via a network so that the computer-readable code can be stored and executed in a distributed manner.

[0178] The above technical description may refer to the accompanying drawings, which form part of this application and illustrate implementation methods in accordance with the described embodiments in the drawings. Although these embodiments are described in sufficient detail to enable those skilled in the art to implement these embodiments, these embodiments are non-limiting; other embodiments can be used and changes can be made without departing from the scope of the described embodiments. For example, the order of operations described in the flowchart is non-limiting, so the order of two or more operations illustrated in the flowchart and described according to the flowchart can be changed according to several embodiments. As another example, in several embodiments, one or more operations illustrated in the flowchart and described according to the flowchart are optional or deletable. In addition, certain steps or functions can be added to the disclosed embodiments, or the order of two or more steps can be replaced. All these changes are considered to be included in the disclosed embodiments and claims.

[0179] The above description is merely a specific implementation of the embodiments of the present application, but the scope of protection of the embodiments of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the embodiments of the present application should be included in the scope of protection of the embodiments of the present application. Therefore, the scope of protection of the embodiments of the present application should be based on the scope of protection of the claims.

Claims

1. A method for generating a data model, characterized in that, The method includes: Obtain (210) the data access statement sent by the user terminal to the database, the data access statement being used to access the target business data in the database; According to the data access statement, obtain (220) the identifier of each target table in at least one target table in the database called by the target service and the identifier of the target column in the target table; Based on the identifier of the target table and the organization and structure of the tables in the database, determine (230) the data type of the target column; The data model of the database is determined based on the identifier of the target table, the identifier of the target column, and the data type. (240) 2. The method according to claim 1, characterized in that, The step of obtaining (210) the data access statement sent by the user terminal to the database includes: Multiple pieces of information generated based on the target service are filtered to obtain the data access statement, wherein the multiple pieces of information include the data access statement.

3. The method according to claim 1 or 2, characterized in that, The step of obtaining (220) the identifier of each target table and the identifier of the target column in at least one target table in the database called by the target service according to the data access statement includes: When the data access statement is a query statement, extract the first string between the subkey and the condition key in the query statement, where the first string is the identifier of the target table; Extract the second string between the select keyword and the subkeyword in the query statement, where the second string is the identifier of the target column.

4. The method according to claim 3, characterized in that, When the query statement is a join query statement and the at least one target table includes multiple target tables, the method further includes: Based on the join query statement, obtain the relationship between the multiple target tables in the target business; Determining (240) the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type includes: The data model is determined based on the identifier of the target table, the identifier of the target column, the relationship between the multiple target tables in the target business, and the data type.

5. The method according to claim 4, characterized in that, The step of obtaining the relationship between the multiple target tables in the target business according to the join query statement includes: The relationship between the multiple target tables and the target business is obtained from the third string following the condition keyword in the join query statement.

6. The method according to claim 1 or 2, characterized in that, The step of obtaining (220) the identifier of each target table and the identifier of the target column in at least one target table in the database called by the target service according to the data access statement includes: When the data access statement is an insert statement, extract the fourth string between the insert key and the value key in the insert statement, and the fourth string is the identifier of the target table; Extract the fifth string within the parentheses following the value keyword in the insert statement; the fifth string is the identifier of the target column.

7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Aggregate the identifiers of the target table and the identifiers of the target columns; Determining (240) the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type includes: The data model is determined based on the identifiers of the aggregated target table and the target columns, and based on the data type.

8. A data model generation apparatus (700), characterized in that, include: Memory (701) for storing programs; The processor (702) is used to execute the program stored in the memory. When the program stored in the memory is executed, the processor is used to obtain a data access statement sent by the user terminal to the database. The data access statement is used to access the data of the target business in the database. The processor (702) is further configured to, based on the data access statement, obtain the identifier of each target table in at least one target table in the database called by the target service and the identifier of the target column in the target table; The processor (702) is further configured to determine the data type of the target column based on the identifier of the target table and the organization and structure of the tables in the database; The processor (702) is further configured to determine the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type.

9. A computer-readable storage medium, characterized in that, The computer-readable medium stores program code for execution by the device, the program code including instructions for performing the steps in the method for generating a data model according to any one of claims 1 to 7.

10. A data model generation apparatus (500), characterized in that, include: The preprocessor (510) is used to obtain the data access statement sent by the user terminal to the database, the data access statement being used to access the target business data in the database; The analyzer (520) is used to obtain the identifier of each target table and the identifier of the target column in the database called by the target service, based on the data access statement. A model generator (530) is used to determine the data type of the target column based on the identifier of the target table and the organization and structure of the tables in the database; The model generator (530) is further configured to determine the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type.

11. A data model generation apparatus (600), characterized in that, include: The acquisition unit (610) is used to acquire the data access statement sent by the user terminal to the database, the data access statement being used to access the target business data in the database; The acquisition unit (610) is further configured to, according to the data access statement, acquire the identifier of each target table in at least one target table in the database called by the target service and the identifier of the target column in the target table; The determining unit (620) is used to determine the data type of the target column based on the identifier of the target table and the organization and structure of the tables in the database; The determining unit (620) is further configured to determine the data model of the database based on the identifier of the target table, the identifier of the target column, and the data type.