CN116501757A - ER diagram-based simulation data construction method and device - Google Patents
ER diagram-based simulation data construction method and device Download PDFInfo
- Publication number
- CN116501757A CN116501757A CN202310733667.1A CN202310733667A CN116501757A CN 116501757 A CN116501757 A CN 116501757A CN 202310733667 A CN202310733667 A CN 202310733667A CN 116501757 A CN116501757 A CN 116501757A
- Authority
- CN
- China
- Prior art keywords
- data
- diagram
- rule
- sql
- generation
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/22—Indexing; Data structures therefor; Storage structures
- G06F16/2282—Tablespace storage structures; Management thereof
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/26—Visual data mining; Browsing structured data
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Computational Linguistics (AREA)
- Mathematical Physics (AREA)
- Human Computer Interaction (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域technical field
本发明涉及系统测试及相关信息技术处理领域,尤其涉及的是一种基于ER图的模拟数据构造方法及装置。The invention relates to the field of system testing and related information technology processing, in particular to a method and device for constructing simulated data based on ER diagrams.
背景技术Background technique
信息系统在试验、试用、演练中需要数据支持,但常常不宜使用真实数据。典型原因如下:一、出于安全性考虑,不允许使用真实数据。为了解决这一问题,在某些场合常采用一些简单变换对真实数据伪装,但伪装数据通过逆变换可以复原为真实数据,仍然存在安全隐患。同时,有些伪装数据会降低数据的合理性,影响应用效果。二、出于时间或成本要求,难以使用真实数据。真实数据需要按照一定的流程获取,需有相应人员支持、有装备保障,有最低限度的时间保证。在有时间限制或投入受限的情况下,难以获取满足要求的真实数据。三、不同任务有具体的数据需求,真实数据不能满足应用。信息系统的试验、试用、演练任务目标明确,需有与目标相适应的数据支持。通常,已有的真实数据并不一定立足于本次任务的数据需求所得,在完整性、及时性、可用性、相关性、效用性等方面与实际数据需求存在偏差。鉴于以上原因,本领域人员对于快速生成模拟数据以满足实际应用场景的需求日益迫切,急需解决。应采用合理模型与算法,用计算机模拟的方式快速生成模拟数据,以满足信息系试验、试用、演练的实际需要。Information systems need data support in experiments, trials, and drills, but it is often not appropriate to use real data. Typical reasons are as follows: 1. For security reasons, real data is not allowed. In order to solve this problem, some simple transformations are often used to disguise the real data in some occasions, but the disguised data can be restored to real data through inverse transformation, which still has potential safety hazards. At the same time, some disguised data will reduce the rationality of the data and affect the application effect. Second, due to time or cost requirements, it is difficult to use real data. Real data needs to be obtained according to a certain process, with the support of corresponding personnel, equipment guarantee, and minimum time guarantee. In the case of time constraints or limited investment, it is difficult to obtain real data that meets the requirements. 3. Different tasks have specific data requirements, and real data cannot meet the application. The test, trial, and drill tasks of the information system have clear objectives and need to be supported by data suitable for the objectives. Usually, the existing real data is not necessarily based on the data requirements of this task, and there are deviations from the actual data requirements in terms of completeness, timeliness, usability, relevance, and utility. In view of the above reasons, there is an increasingly urgent need for those skilled in the art to quickly generate simulated data to meet actual application scenarios, and urgently need to be solved. Reasonable models and algorithms should be used to quickly generate simulated data by means of computer simulation to meet the actual needs of information system experiments, trials, and drills.
现有的快速生成模拟数据的技术中,根据用户数据库设计的ER图,配置相关的业务规则,直接在数据库中插入相关数据是较为普遍的做法。但此方法中业务规则都是手工配置,配置过程较为繁琐,无法快速修改,降低了生成模拟数据的效率。In the existing technologies for quickly generating simulated data, it is common practice to configure relevant business rules and directly insert relevant data into the database according to the ER diagram designed by the user database. However, in this method, the business rules are manually configured, and the configuration process is cumbersome and cannot be modified quickly, which reduces the efficiency of generating simulation data.
因此,现有技术存在缺陷,有待改进与发展。Therefore, there are defects in the prior art and need to be improved and developed.
发明内容Contents of the invention
本发明要解决的技术问题在于,针对现有技术的上述缺陷,提供一种基于ER图的测试场景数据构造方法及装置,旨在解决现有技术中根据用户数据库设计的ER图手工配置业务规则,配置过程较为繁琐,无法快速修改,降低了生成模拟数据的效率的情况。The technical problem to be solved by the present invention is to provide a method and device for constructing test scene data based on ER diagrams in view of the above-mentioned defects of the prior art, aiming at solving the problem of manually configuring business rules based on the ER diagrams designed by the user database in the prior art , the configuration process is cumbersome and cannot be modified quickly, which reduces the efficiency of generating simulation data.
本发明解决技术问题所采用的技术方案如下:The technical solution adopted by the present invention to solve technical problems is as follows:
一种基于ER图的模拟数据构造方法,其中,包括:A method for constructing simulation data based on ER diagrams, including:
获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息;Obtaining an ER diagram, analyzing the ER diagram, and generating SQL table information corresponding to the ER diagram;
根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面;performing visual rendering on the ER diagram according to the SQL table information, to obtain a visual interface corresponding to the ER diagram;
接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则;receiving a rule configuration instruction, and configuring data generation rules on the visual interface according to the rule configuration instruction;
根据所述数据生成规则生成模拟数据。Simulation data is generated according to the data generation rules.
在一种实现方式中,所述获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息,包括:In an implementation manner, the acquisition of the ER diagram, parsing the ER diagram, and generating SQL table information corresponding to the ER diagram include:
获取ER图,利用DDL插件对所述ER图进行解析,生成所述ER图对应的SQL表信息;Obtaining the ER diagram, using the DDL plug-in to analyze the ER diagram, and generating SQL table information corresponding to the ER diagram;
其中,所述SQL表信息为原始实体信息;或者,所述SQL表信息包括:原始实体信息和原始实体父实体的外键;或者,所述SQL表信息包括:关系所涉及的所有实体的外键及关系的属性信息。Wherein, the SQL table information is the original entity information; or, the SQL table information includes: the original entity information and the foreign key of the parent entity of the original entity; or, the SQL table information includes: the foreign keys of all entities involved in the relationship Attribute information for keys and relationships.
在一种实现方式中,根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面,包括:In an implementation manner, the ER diagram is visually rendered according to the SQL table information to obtain a visual interface corresponding to the ER diagram, including:
根据所述SQL表信息对所述ER图中的实体表结构和实体表之间的关系进行可视化渲染,得到所述ER图对应的可视化界面;Visually rendering the entity table structure in the ER diagram and the relationship between the entity tables according to the SQL table information to obtain a visual interface corresponding to the ER diagram;
其中,所述可视化界面包括:场景列表区、操作区以及参数配置区;所述场景列表区用于创建各个业务场景;所述操作区包括:操作按钮列表、操作画布和运行日志列表,所述操作按钮列表上设置有功能按钮,所述操作画布用于对所述ER图进行数据生成规则的配置和查看,所述日志列表用于对所述ER图对应的模拟数据的生成日志进行查看;所述参数配置区用于配置所述ER图对应的实体属性生成规则和关系属性生成规则。Wherein, the visual interface includes: a scene list area, an operation area, and a parameter configuration area; the scene list area is used to create various business scenarios; the operation area includes: an operation button list, an operation canvas and a running log list, and the Function buttons are set on the operation button list, the operation canvas is used to configure and view the data generation rules of the ER diagram, and the log list is used to view the generation log of the simulation data corresponding to the ER diagram; The parameter configuration area is used to configure entity attribute generation rules and relationship attribute generation rules corresponding to the ER diagram.
在一种实现方式中,所述接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则之前,还包括:In an implementation manner, the receiving rule configuration instruction, before configuring the data generation rules on the visual interface according to the rule configuration instruction, further includes:
预先存储元数据信息,所述元数据信息根据当前场景业务对应的数据标准得到,所述数据标准包括元数据标准和/或字典表标准。Metadata information is stored in advance, and the metadata information is obtained according to the data standard corresponding to the current scene service, and the data standard includes metadata standard and/or dictionary table standard.
在一种实现方式中,所述接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则,包括:In an implementation manner, the receiving a rule configuration instruction, and configuring a data generation rule on the visual interface according to the rule configuration instruction includes:
接收规则配置指令,根据所述元数据信息和所述规则配置指令在所述可视化界面上配置数据生成规则;receiving a rule configuration instruction, and configuring data generation rules on the visual interface according to the metadata information and the rule configuration instruction;
其中,所述数据生成规则包括:所述ER图对应的实体属性规则、实体与实体之间的关联度参数以及目标数据类型。Wherein, the data generation rules include: entity attribute rules corresponding to the ER diagram, correlation degree parameters between entities, and target data types.
在一种实现方式中,所述实体属性规则包括:模拟数据生成规则、正常数据设置和异常数据设置;所述模拟数据生成规则包括:固定值、随机值、正则表达式、递增、词库生成以及自定义函数。In one implementation, the entity attribute rules include: simulated data generation rules, normal data settings, and abnormal data settings; the simulated data generation rules include: fixed values, random values, regular expressions, incremental, and lexicon generation and custom functions.
具体地,用户可以在本发明的配置列表页面自定义函数以满足具体的规则需求,使得应用范围更广,更具针对性。Specifically, users can customize functions on the configuration list page of the present invention to meet specific rule requirements, making the application scope wider and more targeted.
在一种实现方式中,实体与实体之间的关联度参数的配置步骤包括:In an implementation manner, the steps of configuring the parameters of the degree of association between entities include:
获取所述ER图对应的数据库表,所述数据库表包括关系数据库SQL表和非关系型数据库SQL表;Obtain the database table corresponding to the ER diagram, the database table includes a relational database SQL table and a non-relational database SQL table;
对所述数据库表中的SQL语句进行分析,根据所述SQL语句中关联字段的类型确定数据库表之间的关联关系,所述数据库表的关联关系包括外键关系、同维关系和主子关系;Analyzing the SQL statement in the database table, determining the association relationship between the database tables according to the type of the associated field in the SQL statement, the association relationship of the database table includes a foreign key relationship, a same-dimensional relationship and a master-child relationship;
接收用户设置指令,在所述可视化界面对所述关联关系进行设置;receiving a user setting instruction, and setting the association relationship on the visual interface;
根据所述关联关系排定各个数据库表生成模拟数据的生成次序。According to the association relationship, the generation order of the simulation data generated by each database table is arranged.
在一种实现方式中,根据所述关联关系排定各个数据库表生成模拟数据的生成次序,包括:In an implementation manner, arranging the generation order of the simulation data generated by each database table according to the association relationship includes:
将同维关系中的数据库表作为同维表,将主子关系中的数据库表作为主子表,所述主子表中的子表依附于主表进行隐藏,并将子表的外键表作为主表的外键表;The database table in the same-dimensional relationship is used as the same-dimensional table, the database table in the master-sub-relationship is used as the main-subtable, the sub-table in the main-subtable is attached to the main table to hide, and the foreign key table of the sub-table is used as the main table the foreign key table;
对每个数据库表赋予相同的初始标号,并根据所述数据库表的所有外键表的数量对所述初始标号进行更新,得到最终标号;Assigning the same initial label to each database table, and updating the initial label according to the quantity of all foreign key tables of the database table, to obtain the final label;
将最终标号由小到大的次序作为各个数据库表生成模拟数据的生成次序。The order of the final labels from small to large is used as the generation order of the simulated data for each database table.
在一种实现方式中,所述目标数据类型的配置包括:设置数据生成速率、设置正常数据、设置异常数据以及设置数据格式。In an implementation manner, the configuration of the target data type includes: setting a data generation rate, setting normal data, setting abnormal data, and setting a data format.
在一种实现方式中,根据所述数据生成规则生成模拟数据,包括:In an implementation manner, generating simulation data according to the data generation rules includes:
根据所述生成次序依次为各个所述数据库表生成模拟数据;Generating simulated data for each of the database tables sequentially according to the generation sequence;
当主表的模拟数据生成后,在所述主表的主键中随机取得外键值。After the simulation data of the main table is generated, the foreign key value is randomly obtained from the primary key of the main table.
本发明还提供一种基于ER图的模拟数据构造装置,其中,包括:The present invention also provides a device for constructing simulation data based on ER diagrams, including:
解析模块,用于获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息;An analysis module, configured to obtain an ER diagram, analyze the ER diagram, and generate SQL table information corresponding to the ER diagram;
渲染模块,用于根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面;A rendering module, configured to visually render the ER diagram according to the SQL table information, to obtain a visual interface corresponding to the ER diagram;
配置模块,用于接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则;A configuration module, configured to receive a rule configuration instruction, and configure data generation rules on the visual interface according to the rule configuration instruction;
生成模块,用于根据所述数据生成规则生成模拟数据。A generation module, configured to generate simulation data according to the data generation rules.
本发明还提供一种终端,其中,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的基于ER图的模拟数据构造程序,所述基于ER图的模拟数据构造程序被所述处理器执行时实现如上所述的基于ER图的模拟数据构造方法的步骤。The present invention also provides a terminal, which includes: a memory, a processor, and an ER diagram-based simulation data construction program that is stored on the memory and can run on the processor, and the ER diagram-based simulation data When the construction program is executed by the processor, the steps of the above-mentioned ER diagram-based simulation data construction method are realized.
本发明还提供一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序能够被执行以用于实现如上所述的基于ER图的模拟数据构造方法的步骤。The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program can be executed to implement the method for constructing simulation data based on an ER diagram as described above. step.
本发明所提供的一种基于ER图的模拟数据构造方法及装置,所述方法包括:获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息;根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面;接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则;根据所述数据生成规则生成模拟数据。本发明通过在线配置ER图中实体的数据生成规则,生成模拟数据,实现了数据生成规则在操作界面上可视化配置,方便调整,通过简单的界面操作即可生成符合对应业务场景的模拟数据,提高了生成模拟数据的效率。A method and device for constructing simulated data based on an ER diagram provided by the present invention, the method includes: obtaining an ER diagram, analyzing the ER diagram, and generating SQL table information corresponding to the ER diagram; according to the SQL Performing visual rendering of the ER diagram based on table information to obtain a visual interface corresponding to the ER diagram; receiving a rule configuration instruction, configuring a data generation rule on the visualization interface according to the rule configuration instruction; generating a data generation rule according to the data generation rule mock data. The present invention generates simulated data by configuring the data generation rules of the entities in the ER diagram online, realizes the visual configuration of the data generation rules on the operation interface, facilitates adjustment, and can generate simulated data conforming to corresponding business scenarios through simple interface operations, improving to improve the efficiency of generating simulated data.
附图说明Description of drawings
图1是本发明中基于ER图构造模拟数据的整体流程图。Fig. 1 is an overall flow chart of constructing simulation data based on ER diagram in the present invention.
图2是本发明中基于ER图的模拟数据构造方法较佳实施例的流程图。Fig. 2 is a flow chart of a preferred embodiment of the simulation data construction method based on the ER diagram in the present invention.
图3是本发明中可视化操作界面布局图。Fig. 3 is a layout diagram of a visual operation interface in the present invention.
图4是本发明中可视化操作界面具体操作示意图。Fig. 4 is a schematic diagram of the specific operation of the visualized operation interface in the present invention.
图5是本发明中基于ER图的模拟数据构造装置较佳实施例的功能原理框图。Fig. 5 is a function principle block diagram of a preferred embodiment of the device for constructing analog data based on ER diagram in the present invention.
图6是本发明中终端的功能原理框图。Fig. 6 is a functional block diagram of the terminal in the present invention.
具体实施方式Detailed ways
为使本发明的目的、技术方案及优点更加清楚、明确,以下参照附图并举实施例对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。In order to make the object, technical solution and advantages of the present invention more clear and definite, the present invention will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
信息系统在试验、试用、演练中需要数据支持,但常常不宜使用真实数据。典型原因如下:一、出于安全性考虑,不允许使用真实数据。为了解决这一问题,在某些场合常采用一些简单变换对真实数据伪装,但伪装数据通过逆变换可以复原为真实数据,仍然存在安全隐患。同时,有些伪装数据会降低数据的合理性,影响应用效果。二、出于时间或成本要求,难以使用真实数据。真实数据需要按照一定的流程获取,需有相应人员支持、有装备保障,有最低限度的时间保证。在有时间限制或投入受限的情况下,难以获取满足要求的真实数据。三、不同任务有具体的数据需求,真实数据不能满足应用。信息系统的试验、试用、演练任务目标明确,需有与目标相适应的数据支持。通常,已有的真实数据并不一定立足于本次任务的数据需求所得,在完整性、及时性、可用性、相关性、效用性等方面与实际数据需求存在偏差。鉴于以上原因,本领域人员对于快速生成模拟数据以满足实际应用场景的需求日益迫切,急需解决。应采用合理模型与算法,用计算机模拟的方式快速生成模拟数据,以满足信息系试验、试用、演练的实际需要。Information systems need data support in experiments, trials, and drills, but it is often not appropriate to use real data. Typical reasons are as follows: 1. For security reasons, real data is not allowed. In order to solve this problem, some simple transformations are often used to disguise the real data in some occasions, but the disguised data can be restored to real data through inverse transformation, which still has potential safety hazards. At the same time, some disguised data will reduce the rationality of the data and affect the application effect. Second, due to time or cost requirements, it is difficult to use real data. Real data needs to be obtained according to a certain process, with the support of corresponding personnel, equipment guarantee, and minimum time guarantee. In the case of time constraints or limited investment, it is difficult to obtain real data that meets the requirements. 3. Different tasks have specific data requirements, and real data cannot meet the application. The test, trial, and drill tasks of the information system have clear objectives and need to be supported by data suitable for the objectives. Usually, the existing real data is not necessarily based on the data requirements of this task, and there are deviations from the actual data requirements in terms of completeness, timeliness, usability, relevance, and utility. In view of the above reasons, there is an increasingly urgent need for those skilled in the art to quickly generate simulated data to meet actual application scenarios, and urgently need to be solved. Reasonable models and algorithms should be used to quickly generate simulated data by means of computer simulation to meet the actual needs of information system experiments, trials, and drills.
现有的快速生成大量模拟数据的技术中,一种较为普遍的做法是通过开发人员编写的接口来模拟真实用户场景来产生数据,这种方式在某些方面来讲是比较合适的,因为编写代码模拟用户场景,业务数据完整,数据传递过程不会丢失数据。但因其需编写代码处理业务流程的每一个步骤、接口定义、签名、加密等,工作量较大且繁琐。另其扩展性也较差,一个业务场景要编写一套代码。Among the existing technologies for quickly generating a large amount of simulated data, a common method is to generate data by simulating real user scenarios through interfaces written by developers. This method is more appropriate in some respects, because writing The code simulates the user scenario, the business data is complete, and the data will not be lost during the data transfer process. However, because it needs to write codes to process each step of the business process, interface definition, signature, encryption, etc., the workload is heavy and cumbersome. In addition, its scalability is poor, and a set of code needs to be written for a business scenario.
另外一种较为普遍的做法是根据用户数据库设计的ER图,配置相关的业务规则,直接在数据库中插入相关数据。但此方法中业务规则都是手工配置,配置过程较为繁琐,无法根据业务规则的变化及时调整,无法快速生成符合测试场景的大量测试数据。Another common method is to configure relevant business rules based on the ER diagram designed by the user database, and directly insert relevant data into the database. However, in this method, business rules are manually configured, and the configuration process is cumbersome. It cannot be adjusted in time according to changes in business rules, and a large amount of test data that meets the test scenario cannot be quickly generated.
本发明提供了一种基于ER图的模拟数据构造方法,用于解决以下需求:The present invention provides a method for constructing simulation data based on ER diagrams, which is used to solve the following requirements:
(1)提供ER图上传。用户上传不同类型数据库ER图,配置目标数据类型、生成规则,系统动态适配目标数据源类型,自动生成业务模拟数据。(1) Provide ER diagram upload. Users upload ER diagrams of different types of databases, configure target data types and generation rules, and the system dynamically adapts to target data source types to automatically generate business simulation data.
(2)支持函数插件。支持多种生成模拟数据的规则,比如固定值、随机值、正则表达式、递增值;支持选择词库来生成特定范围内的随机值;支持词库、表设计、字段信息共享;支持直接使用现成的词库来建立字典表;支持生成多种格式的模拟数据,如json、xml、sql、cvs。(2) Support function plug-ins. Supports a variety of rules for generating simulated data, such as fixed values, random values, regular expressions, and incremental values; supports selection of thesaurus to generate random values within a specific range; supports thesaurus, table design, and field information sharing; supports direct use Ready-made lexicons to build dictionary tables; support to generate simulated data in various formats, such as json, xml, sql, cvs.
同时本发明提供了一种基于ER图的模拟数据构造方法,支持以下三种应用场景:At the same time, the present invention provides a method for constructing simulated data based on ER diagrams, which supports the following three application scenarios:
(1)测试场景。测试过程中,需要验证数据后端的功能或性能,此时,需要降低与数据产生端的耦合,采用该方法,来持续的不间断的产生正确的数据,和特殊情况下的异常数据。(1) Test scene. During the test, it is necessary to verify the function or performance of the data backend. At this time, it is necessary to reduce the coupling with the data generator. This method is used to continuously and uninterruptedly generate correct data and abnormal data under special circumstances.
(2)持续集成场景。在持续集成场景中,一个或多个模块组成一个平台,需要有源源不断的数据进入持续集成环境,用以自动化地完成测试和迭代工作。(2) Continuous integration scenarios. In the continuous integration scenario, one or more modules form a platform, which requires a steady stream of data to enter the continuous integration environment to automate testing and iteration work.
(3)生产场景。在一个项目完成测试和迭代,发布到生产环境之后,通常也需要进行持续的功能或可用性监测,则需要有各种正常或异常数据按照某种规则和定义,持续稳定地生产并送回平台,根据持续集成场景中的业务需求,只需通过一定规则配置,就可以进行生产的验证,以满足这个需求。(3) Production scenarios. After a project is tested and iterated and released to the production environment, continuous function or usability monitoring is usually required. Various normal or abnormal data need to be produced continuously and stably according to certain rules and definitions and sent back to the platform. According to the business requirements in the continuous integration scenario, production verification can be carried out only through certain rule configurations to meet this requirement.
如图1所示,本发明中基于ER图构造模拟数据的流程主要包括解析ER图12、渲染ER图13、梳理元数据14、配置规则15、模拟数据16。As shown in FIG. 1 , the process of constructing simulation data based on ER diagrams in the present invention mainly includes parsing ER diagrams 12 , rendering ER diagrams 13 , combing metadata 14 , configuration rules 15 , and simulation data 16 .
本发明提供了一种基于ER图的模拟数据构造方法,通过解析ER图元数据生成SQL,结合G6、Vue3框架,对ER图进行可视化渲染;在线配置ER图中实体的数据规则及实体与实体之间关系的关联规则、配置输出数据源类型、构建模拟数据的业务规则,最终根据业务规则,动态适配、完成数据格式转换并生成模拟数据,实现了业务规则可界面配置,方便调整,通过简单的界面操作即可生成符合测试场景的大量测试数据,可快速生成测试数据的目的。The present invention provides a method for constructing simulated data based on ER diagrams. SQL is generated by parsing ER diagram metadata, and combined with G6 and Vue3 frameworks, the ER diagrams are visualized and rendered; data rules and entities and entities in ER diagrams are configured online Association rules for relationships, configuration of output data source types, and business rules for constructing simulated data. Finally, according to the business rules, dynamically adapt, complete data format conversion, and generate simulated data. The interface configuration of business rules is realized, which is convenient for adjustment. Through Simple interface operations can generate a large amount of test data that conforms to the test scenario, and the purpose of quickly generating test data can be achieved.
请参见图2,图2是本发明中基于ER图的模拟数据构造方法的流程图。如图2所示,本发明实施例所述的基于ER图的模拟数据构造方法包括如下步骤:Please refer to FIG. 2 . FIG. 2 is a flow chart of the ER diagram-based simulation data construction method in the present invention. As shown in Figure 2, the ER diagram-based simulation data construction method described in the embodiment of the present invention includes the following steps:
步骤S100、获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息。Step S100, acquiring an ER diagram, analyzing the ER diagram, and generating SQL table information corresponding to the ER diagram.
具体地,ER图是数据库的设计,用图形之间的关系,反映各个表之间的关系。所述对所述ER图进行解析,生成所述ER图对应的SQL表信息,是利用DDL插件完成的。本发明利用DDL插件完成对ER图转换为SQL表信息,可快速完成转换,支持解析不同数据库类型所需客户端设计的ER图,实现ER图元数据标准化,具有良好的兼容性。Specifically, the ER diagram is the design of the database, using the relationship between the graphs to reflect the relationship between various tables. The parsing of the ER diagram to generate the SQL table information corresponding to the ER diagram is completed by using a DDL plug-in. The invention utilizes the DDL plug-in to complete the conversion of ER diagrams into SQL table information, can quickly complete the conversion, supports the analysis of ER diagrams designed by clients required by different database types, realizes the standardization of ER diagram metadata, and has good compatibility.
在一种实现方式中,所述步骤S100具体包括:In an implementation manner, the step S100 specifically includes:
获取ER图,利用DDL插件对所述ER图进行解析,生成所述ER图对应的SQL表信息;Obtaining the ER diagram, using the DDL plug-in to analyze the ER diagram, and generating SQL table information corresponding to the ER diagram;
其中,所述SQL表信息为原始实体信息;或者,所述SQL表信息包括:原始实体信息和原始实体父实体的外键;或者,所述SQL表信息包括:关系所涉及的所有实体的外键及关系的属性信息。Wherein, the SQL table information is the original entity information; or, the SQL table information includes: the original entity information and the foreign key of the parent entity of the original entity; or, the SQL table information includes: the foreign keys of all entities involved in the relationship Attribute information for keys and relationships.
具体地,从ER图转化得到关系数据库中的SQL,一般可分为三类:Specifically, SQL in relational databases obtained from ER diagrams can generally be divided into three categories:
(1)转化得到的SQL表与原始实体包含相同信息内容。该类转化一般适用于:(1) The converted SQL table contains the same information content as the original entity. This type of transformation is generally applicable to:
二元“多对多”关系中,任何一端的实体;Entities at either end of a binary "many-to-many" relationship;
二元“一对多”关系中,“一”一端的实体;In the binary "one-to-many" relationship, the entity at the "one" end;
二元“一对一”关系中,某一端的实体;In a binary "one-to-one" relationship, an entity at one end;
二元“多对多”回归关系中,任何一端的实体(注:关系两端都指向同一个实体);In the binary "many-to-many" regression relationship, entities at either end (note: both ends of the relationship point to the same entity);
三元或n元关系中,任何一端的实体;Entities at either end of a ternary or n-ary relationship;
层次泛化关系中,超类实体。In a hierarchical generalization relationship, the superclass entity.
(2)转化得到的SQL表除了包含原始实体的信息内容之外,还包含原始实体父实体的外键。该类转化一般适用于:(2) The converted SQL table not only contains the information content of the original entity, but also contains the foreign key of the parent entity of the original entity. This type of transformation is generally applicable to:
二元“一对多”关系中,“多”一端的实体;In the binary "one-to-many" relationship, the entity at the "many" end;
二元“一对一”关系中,某一端的实体;In a binary "one-to-one" relationship, an entity at one end;
二元“一对一”或“一对多”回归关系中,任何一端的实体。Entities at either end of a binary "one-to-one" or "one-to-many" regression relationship.
该转化是处理关系的常用方法之一,即在子表中增加指向父表中主键的外键信息。This conversion is one of the common methods for processing relationships, that is, adding foreign key information pointing to the primary key in the parent table in the child table.
(3)由“关系”转化得到的SQL表,该表包含“关系”所涉及的所有实体的外键,以及该“关系”自身的属性信息。该类转化一般适用于:(3) The SQL table converted from the "relationship", which contains the foreign keys of all entities involved in the "relationship" and the attribute information of the "relationship" itself. This type of transformation is generally applicable to:
二元“多对多”关系;Binary "many-to-many" relationship;
二元“多对多”回归关系;Binary "many-to-many" regression relationship;
三元或n元关系;ternary or n-ary relations;
该转化是另一种常用的关系处理方法。对于“多对多”关系需要定义为一张包含两个相关实体主键的独立表,该表还能包含关系的属性信息。This transformation is another commonly used relational approach. For the "many-to-many" relationship, it needs to be defined as an independent table containing the primary keys of two related entities, and the table can also contain the attribute information of the relationship.
本发明支持上述三类转化,生成所述ER图对应的SQL表信息。其中,从ER图到SQL表的基本转化步骤如下:The present invention supports the above three types of transformations, and generates SQL table information corresponding to the ER diagram. Among them, the basic conversion steps from ER diagram to SQL table are as follows:
(1)把每一个实体转化为一张表,其中包含键和非键属性。(1) Convert each entity into a table, which contains key and non-key attributes.
在实体转化中,若两个实体之间是“一对多”关系,把“一”端实体的主键加入到“多”端实体表中作为外键。若两实体间是“一对一”关系,把某个“一”端实体的主键放入另一实体表中作为外键,加入外键的实体理论上可以任选,但一般会遵循如下原则:按照实体间最为自然的父子关系,把父实体的键放入子实体中;另一种策略是基于效率,把外键加入到具有较少行的表中。In entity conversion, if there is a "one-to-many" relationship between two entities, add the primary key of the "one" end entity to the "many" end entity table as a foreign key. If there is a "one-to-one" relationship between two entities, put the primary key of a "one" entity into the other entity table as a foreign key, and the entity that adds the foreign key can theoretically be optional, but generally follow the following principles : According to the most natural parent-child relationship between entities, put the key of the parent entity into the child entity; another strategy is based on efficiency, adding foreign keys to tables with fewer rows.
把泛化层次中的每一个实体转化为一张表。每张表都会包含超类实体的键。事实上子类实体的主键同时也是外键。超类表中还包含所有相关实体的公共非键属性,其他表包含每一子类实体特有的非键属性。Convert each entity in the generalization hierarchy into a table. Each table will contain the keys of the superclass entities. In fact, the primary key of the subclass entity is also a foreign key. The superclass table also contains non-key attributes common to all related entities, and the other tables contain nonkey attributes specific to each subclass entity.
转化得到的SQL表可能会包含not null, unique, foreign key等约束。每一张表必须有一个主键(primary key),主键隐含着not null和unique约束。The converted SQL table may contain not null, unique, foreign key and other constraints. Each table must have a primary key (primary key), the primary key implies not null and unique constraints.
(2)把每一个“多对多”二元或二元回归关系转化为一张表,其中包含实体的键和关系的属性。(2) Convert each "many-to-many" binary or binary regression relationship into a table, which contains the key of the entity and the attribute of the relationship.
在“多对多”二元关系转化中,每一个“多对多”二元关系能转化为In the "many-to-many" binary relationship transformation, each "many-to-many" binary relationship can be transformed into
一张表,包含两个实体的键和关系的属性。A table that contains the keys of the two entities and the attributes of the relationship.
转化得到的SQL表可能包含not null约束。在这里没有使用unique约束的原因是关系表的主键是由各实体的外键复合组成的,unique约束已隐含。The converted SQL table may contain not null constraints. The reason why the unique constraint is not used here is that the primary key of the relational table is composed of the foreign keys of each entity, and the unique constraint is already implied.
(3)把三元及更高元(n元)关系转化为一张表。(3) Convert ternary and higher (n-ary) relationships into a table.
在三元关系转化中,每一个三元(或n元)关系转化为一张表,包含相关实体的n个主键以及该关系的属性。In ternary relationship conversion, each ternary (or n-ary) relationship is transformed into a table, which contains n primary keys of related entities and attributes of the relationship.
转化得到的表必须包含not null约束。关系表的主键由各实体的外键复合组成。n元关系表具有n个外键。除主键约束外,其他候选键(candidate key)也应加上unique约束。The converted table must contain not null constraints. The primary key of a relational table is composed of the foreign keys of each entity. An n-ary relational table has n foreign keys. In addition to primary key constraints, other candidate keys (candidate keys) should also be added with unique constraints.
同时,在转化过程中对于NULL值的处理规则如下:At the same time, the processing rules for NULL values in the conversion process are as follows:
(1)当实体之间的关系是可选的,SQL表中的外键列允许为NULL;(1) When the relationship between entities is optional, the foreign key column in the SQL table is allowed to be NULL;
(2)当实体之间的关系是强制的,SQL表中的外键列不允许为NULL;(2) When the relationship between entities is mandatory, the foreign key column in the SQL table is not allowed to be NULL;
(3)由“多对多”关系转化得到的SQL表,其中的任意外键列都不允许为NULL。(3) In the SQL table converted from the "many-to-many" relationship, any foreign key column in it is not allowed to be NULL.
本发明通过上述的规则和步骤完成了生成所述ER图对应的SQL表信息,支持多种关系处理方法,适用场景广,可满足复杂业务需求。The present invention completes the generation of SQL table information corresponding to the ER diagram through the above rules and steps, supports multiple relationship processing methods, has a wide range of applicable scenarios, and can meet complex business requirements.
如图2所示,所述基于ER图的模拟数据构造方法还包括如下步骤:As shown in Figure 2, the described ER diagram-based simulation data construction method also includes the following steps:
步骤S200、根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面。Step S200, performing visual rendering on the ER diagram according to the SQL table information, to obtain a visual interface corresponding to the ER diagram.
具体地,本发明通过G6、X6、Vuedraggble、jsplumb的组合使用,进行ER图可视化渲染,支持不同类型数据库ER图上传,具备高兼容性。Specifically, the present invention uses the combination of G6, X6, Vuedraggble, and jsplumb to perform visual rendering of ER diagrams, supports uploading of ER diagrams of different types of databases, and has high compatibility.
在一种实施例中,所述步骤S200具体包括:In one embodiment, the step S200 specifically includes:
根据所述SQL表信息对所述ER图中的实体表结构和实体表之间的关系进行可视化渲染,得到所述ER图对应的可视化界面;Visually rendering the entity table structure in the ER diagram and the relationship between the entity tables according to the SQL table information to obtain a visual interface corresponding to the ER diagram;
所述可视化界面包括:场景列表区、操作区以及参数配置区;所述场景列表区用于创建各个业务场景;所述操作区包括:操作按钮列表、操作画布和运行日志列表,所述操作按钮列表上设置有功能按钮,所述操作画布用于对所述ER图进行数据生成规则的配置和查看,所述日志列表用于对所述ER图对应的模拟数据的生成日志进行查看;所述参数配置区用于配置所述ER图对应的实体属性生成规则和关系属性生成规则。The visual interface includes: a scene list area, an operation area, and a parameter configuration area; the scene list area is used to create various business scenarios; the operation area includes: an operation button list, an operation canvas and a running log list, and the operation button Function buttons are set on the list, the operation canvas is used to configure and view the data generation rules of the ER diagram, and the log list is used to view the generation log of the simulation data corresponding to the ER diagram; the The parameter configuration area is used to configure the entity attribute generation rules and relationship attribute generation rules corresponding to the ER diagram.
具体地,如图3所示,ER图可视化IDE由三部分组成,分别是左边的场景列表区、中间的操作区、右边的参数配置区。Specifically, as shown in Figure 3, the ER diagram visualization IDE consists of three parts, namely the scene list area on the left, the operation area in the middle, and the parameter configuration area on the right.
如图4所示,各部分的具体功能如下:As shown in Figure 4, the specific functions of each part are as follows:
(1)场景区。场景区包含场景列表,其功能是维护不同场景功能,如创建交通场景、医保场景。(1) Scene area. The scene area contains a scene list, and its function is to maintain different scene functions, such as creating traffic scenes and medical insurance scenes.
(2)操作区。操作区由操作按钮列表、操作画布、运行日志列表组成。操作按钮列表主要包含放大、缩小、运行、选择等功能按钮,用于对操作的控制;操作画布用于ER图中实体/关系属性生成规则的配置、查看;日志列表用于查看ER图模拟数据的日志。(2) Operating area. The operation area consists of a list of operation buttons, an operation canvas, and a list of running logs. The operation button list mainly includes function buttons such as zoom in, zoom out, run, and select, which are used to control the operation; the operation canvas is used to configure and view the generation rules of entity/relationship attributes in the ER diagram; the log list is used to view the simulated data of the ER diagram log.
(3)参数配置区。主要实现ER图各个实体、关系不同属性生成规则配置,参数配置是由数据库后端配置渲染、用户只需要填写相关的参数值。(3) Parameter configuration area. It mainly realizes the configuration of the generation rules of different attributes of each entity and relationship in the ER diagram. The parameter configuration is rendered by the database backend configuration, and the user only needs to fill in the relevant parameter values.
本发明通过对ER图的可视化渲染,得到了所述ER图对应的可视化界面。本发明支持实体表结构渲染,可根据不同的数据库的类型显示表结构、字段类型、主键、默认值、索引、备注信息等,同时支持实体表之前关系渲染,操作简便。The present invention obtains the visual interface corresponding to the ER diagram through visual rendering of the ER diagram. The invention supports entity table structure rendering, can display table structure, field type, primary key, default value, index, remark information, etc. according to different database types, and supports entity table relationship rendering at the same time, and is easy to operate.
所述接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则之前,还包括:The receiving rule configuration instruction, before configuring data generation rules on the visual interface according to the rule configuration instruction, further includes:
预先存储元数据信息,所述元数据信息根据当前场景业务对应的数据标准得到,所述数据标准包括元数据标准和/或字典表标准。Metadata information is stored in advance, and the metadata information is obtained according to the data standard corresponding to the current scene service, and the data standard includes metadata standard and/or dictionary table standard.
具体地,元数据是信息的概念和信息之间的连接,要模拟接近业务的数据,依据用户实际场景下业务数据的各类标准,如元数据标准,字典表标准等,需对ER图中实体及实体之间关系进行元数据梳理。Specifically, metadata is the concept of information and the connection between information. To simulate the data close to the business, according to various standards of business data in the user's actual scene, such as metadata standards, dictionary table standards, etc., it is necessary to Metadata combing of entities and relationships between entities.
如ER图中实体学生表,属性含student_id,sex,student_name,city等。这些信息就是描述一个学生表的元数据。按照用户的元数据标准,梳理各个属性代表的真实的业务含义,比如city代表城市字段,梳理其实际业务中的取值范围、业务规则等。Such as the entity student table in the ER diagram, the attributes include student_id, sex, student_name, city, etc. This information is the metadata describing a student table. According to the user's metadata standard, sort out the real business meaning represented by each attribute, such as city represents the city field, sort out the value range and business rules in the actual business.
通过对元数据的梳理,满足对业务和数据理解的需求,能够快速了解数据的上下游关系及本身的含义,减少数据研究的时间成本,提高效率;能够清晰地了解ER图中数据流的来龙去脉、业务处理规则、转换情况等。Through the sorting of metadata, it can meet the needs of business and data understanding, quickly understand the upstream and downstream relationship of data and its own meaning, reduce the time cost of data research, and improve efficiency; can clearly understand the ins and outs of data flow in ER diagram , business processing rules, conversion status, etc.
本发明预先存储元数据信息,所述元数据由人工和代码相结合梳理完成,准确可靠,方便后面对于元数据信息的使用。The present invention pre-stores metadata information, and the metadata information is combed manually and coded, which is accurate and reliable, and facilitates the use of the metadata information later.
如图1所示,所述基于ER图的模拟数据构造方法还包括如下步骤:As shown in Figure 1, the described ER diagram-based simulation data construction method also includes the following steps:
步骤S300、接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则。Step S300, receiving a rule configuration instruction, and configuring data generation rules on the visual interface according to the rule configuration instruction.
具体地,规则配置指令由用户在可视化界面的配置区操作生成。Specifically, the rule configuration instruction is generated by the user operating in the configuration area of the visual interface.
在一种实现方式中,所述步骤S300具体包括:In an implementation manner, the step S300 specifically includes:
接收规则配置指令,根据所述元数据信息和所述规则配置指令在所述可视化界面上配置数据生成规则;receiving a rule configuration instruction, and configuring data generation rules on the visual interface according to the metadata information and the rule configuration instruction;
其中,所述数据生成规则包括:所述ER图对应的实体属性规则、实体与实体之间的关联度参数以及目标数据类型。Wherein, the data generation rules include: entity attribute rules corresponding to the ER diagram, correlation degree parameters between entities, and target data types.
具体地,依据梳理出的元数据信息和规则配置指令,在可视化界面的配置区配置各个实体/关系的数据生成规则。本发明通过在可视化界面配置区配置数据生成规则,无需人工进行规则配置,使得配置过程简洁方便,可根据业务规则的变化及时调整。Specifically, according to the sorted out metadata information and rule configuration instructions, configure the data generation rules of each entity/relationship in the configuration area of the visual interface. The present invention configures the data generation rules in the configuration area of the visual interface without manually configuring the rules, so that the configuration process is simple and convenient, and can be adjusted in time according to changes in business rules.
在一种实现方式中,所述实体属性规则包括:模拟数据生成规则、正常数据设置和异常数据设置;所述模拟数据生成规则包括:固定值、随机值、正则表达式、递增、词库生成以及自定义函数。In one implementation, the entity attribute rules include: simulated data generation rules, normal data settings, and abnormal data settings; the simulated data generation rules include: fixed values, random values, regular expressions, incremental, and lexicon generation and custom functions.
具体地,在可视化界面的配置列表页面设置模拟数据生成规则,如指定地区身份证号生成规则,指定性别的用户等。操作直观,流程简便,可满足不同场景的业务测试。模拟数据生成规则中包含固定值、随机值、正则表达式、递增、词库生成以及自定义函数。支持函数插件,具体包括:支持选择词库来生成特定范围内的随机值;支持词库、表设计、字段信息共享;支持直接使用现成的词库来建立字典表;支持生成多种格式的模拟数据,如json、xml、sql、cvs;支持选择支持字段字典自定义,支持用户上传自定义函数。通过在界面配置业务规则以及支持函数插件,方便用户选择使用,方便扩展,提高数据的适用性。Specifically, the simulated data generation rules are set on the configuration list page of the visual interface, such as the generation rules for ID numbers of specified regions, users of specified genders, and so on. The operation is intuitive and the process is simple, which can meet the business tests of different scenarios. The simulated data generation rules include fixed value, random value, regular expression, increment, lexicon generation and custom function. Supports function plug-ins, including: support for selecting thesaurus to generate random values within a specific range; support for thesaurus, table design, and field information sharing; support for directly using ready-made thesaurus to create dictionary tables; support for generating simulations in multiple formats Data, such as json, xml, sql, cvs; support selection, field dictionary customization, and user uploading of custom functions. By configuring business rules on the interface and supporting function plug-ins, it is convenient for users to choose to use, easy to expand, and improve the applicability of data.
对正常数据和异常数据均进行了设置,正常数据满足业务流程的正常使用场景,异常数据满足业务流程的异常使用场景。通过对正常数据和异常数据分别进行设置和生成,可以全面的覆盖测试场景。Both normal data and abnormal data are set. The normal data meets the normal usage scenarios of the business process, and the abnormal data meets the abnormal usage scenarios of the business process. By setting and generating normal data and abnormal data respectively, test scenarios can be fully covered.
在一种实现方式中,实体与实体之间的关联度参数的配置步骤包括:In an implementation manner, the steps of configuring the parameters of the degree of association between entities include:
A1、获取所述ER图对应的数据库表,所述数据库表包括关系数据库SQL表和非关系型数据库SQL表;A1. Obtain the database table corresponding to the ER diagram, and the database table includes a relational database SQL table and a non-relational database SQL table;
A2、对所述数据库表中的SQL语句进行分析,根据所述SQL语句中关联字段的类型确定数据库表之间的关联关系,所述数据库表的关联关系包括外键关系、同维关系和主子关系;A2. The SQL statement in the database table is analyzed, and the association relationship between the database tables is determined according to the type of the associated field in the SQL statement, and the association relationship of the database table includes a foreign key relationship, a same-dimensional relationship and a master-child relationship relation;
A3、接收用户设置指令,在所述可视化界面对所述关联关系进行设置;A3. Receive a user setting instruction, and set the association relationship on the visual interface;
A4、根据所述关联关系排定各个数据库表生成模拟数据的生成次序。A4. Arranging the generation sequence of the simulated data generated by each database table according to the association relationship.
其中,数据库表的关联关系可以分成外键关系、同维关系、主子关系三种情况。所述关联关系可根据关联字段是否是表的主键(或部分主键)区分。其中关联字段是从ER图上实体与实体的关系解析得到。Among them, the relationship between database tables can be divided into three types: foreign key relationship, same-dimensional relationship, and master-child relationship. The association relationship can be distinguished according to whether the associated field is the primary key (or part of the primary key) of the table. The associated fields are obtained from the analysis of the relationship between entities on the ER diagram.
具体地,根据SQL语句,从其中的JOIN子句来分析,根据JOIN字段是否是表的主键或部分主键判断是哪种关联。若JOIN字段是表的主键,则是全连接,取得共同的数据;若JOIN字段不是表的主键,则是左连接或右连接。当同一个表同时是两个表的子表时,把这两个主表看成子表的外键表,而不作为主子表处理,这样能保证无子表有多个主表的情况。Specifically, analyze the JOIN clause according to the SQL statement, and determine what kind of association it is based on whether the JOIN field is the primary key or part of the primary key of the table. If the JOIN field is the primary key of the table, it is a full connection to obtain common data; if the JOIN field is not the primary key of the table, it is a left connection or a right connection. When the same table is a subtable of two tables at the same time, the two main tables are regarded as the foreign key tables of the subtables instead of being treated as the main subtable, so as to ensure that there are no subtables with multiple main tables.
需注意,有些外键是隐含的关系,比如身份证号中有日期和地区码,如果运算中有从身份证号提供这些部分信息的动作,那需要人工在可视化界面操作,把这些隐含的关联关系找出来,相当于把身证份号这样的字段拆成几段。It should be noted that some foreign keys are implicit relationships, such as the date and area code in the ID number. If there is an action to provide these parts of information from the ID number in the calculation, it needs to be manually operated on the visual interface to make these implicit Finding out the association relationship is equivalent to splitting a field such as an ID number into several sections.
本发明通过在可视化界面进行实体与实体之间的关联度参数的配置,使得各个数据库表自动生成模拟数据的生成次序,可及时响应配置的修改。本发明根据实际业务ER关系图进行模拟数据,生成业务模拟数据,可较好的体现实体属性的关联以及实体之间的关联,业务数据关联性强。The invention configures the correlation degree parameters between entities on the visual interface, so that each database table automatically generates the generation sequence of the simulated data, and can respond to configuration modification in time. The present invention simulates data according to the actual business ER relationship diagram to generate business simulation data, which can better reflect the association of entity attributes and the association between entities, and the business data has strong association.
在一种实现方式中,根据所述关联关系排定各个数据库表生成模拟数据的生成次序,包括:In an implementation manner, arranging the generation order of the simulation data generated by each database table according to the association relationship includes:
B1、将同维关系中的数据库表作为同维表,将主子关系中的数据库表作为主子表,所述主子表中的子表依附于主表进行隐藏,并将子表的外键表作为主表的外键表;B1. Using the database table in the same-dimensional relationship as the same-dimensional table, using the database table in the master-sub-relationship as the main sub-table, the sub-table in the main-sub-table is attached to the main table to hide, and the foreign key table of the sub-table is used as The foreign key table of the main table;
B2、对每个数据库表赋予相同的初始标号,并根据所述数据库表的所有外键表的数量对所述初始标号进行更新,得到最终标号;B2. Assign the same initial label to each database table, and update the initial label according to the quantity of all foreign key tables of the database table to obtain the final label;
B3、将最终标号由小到大的次序作为各个数据库表生成模拟数据的生成次序。B3. The order of the final labels from small to large is used as the generation order of the simulated data generated by each database table.
具体地,设置关联关系后,可排定生成数据的次序。把同维表看成一个逻辑表一起处理,主子表中的子表则依附于主表先隐藏起来,子表的其它外键表也被视为主表的外键表,等主表处理完再处理子表。给每个表标上数字1。对于每个表,如果它有的所有外键表的标号最大值为n,则把它本身的标号改成n+1,反复执行此动作直到所有标号不再变动为止。本发明通过设置关联关系后自动排定生成数据的次序,使得数据可在设置规则后快速生成,且可根据配置规则的变化及时变化。Specifically, after the association relationship is set, the order of generating data can be arranged. Treat the same-dimension table as a logical table together, and the sub-tables in the main and sub-tables are attached to the main table and hidden first, and the other foreign key tables of the sub-tables are also regarded as the foreign key tables of the main table, and wait for the main table to be processed. Then process the child table. Label each table with the number 1. For each table, if the maximum number of labels of all foreign key tables it has is n, change its own label to n+1, and repeat this action until all labels do not change. The present invention automatically arranges the order of generating data by setting the association relationship, so that the data can be quickly generated after setting the rules, and can be changed in time according to the change of the configuration rules.
在一种实现方式中,所述目标数据类型的配置包括:设置数据生成速率、设置正常数据、设置异常数据以及设置数据格式。In an implementation manner, the configuration of the target data type includes: setting a data generation rate, setting normal data, setting abnormal data, and setting a data format.
具体地,在可视化界面的配置列表中设置数据生成速率,可按照实际需求设置速率生成数据,避免因生成数据而影响操作系统性能。设置正常数据和异常数据,使其更全面的满足测试场景。在可视化界面的配置列表中设置数据格式,可支持json、xml、sql、cvs等,方便了后续测试数据和其他测试系统及测试环境的对接。Specifically, by setting the data generation rate in the configuration list of the visual interface, the rate of data generation can be set according to actual needs, so as to avoid affecting the performance of the operating system due to the generated data. Set normal data and abnormal data to make it more comprehensive to meet the test scenario. Set the data format in the configuration list of the visual interface, which can support json, xml, sql, cvs, etc., which facilitates the connection of subsequent test data with other test systems and test environments.
如图1所示,所述基于ER图的模拟数据构造方法还包括如下步骤:As shown in Figure 1, the described ER diagram-based simulation data construction method also includes the following steps:
步骤S400、根据所述数据生成规则生成模拟数据。Step S400, generating simulation data according to the data generation rule.
具体地,在可视化界面的配置列表页面完成规则配置后,可立即响应,生成模拟数据。当配置规则修改后,可及时生成修改后的模拟数据。当用户上传不同类型数据库ER图后,配置生成规则后,可动态适配目标数据源类型,自动生成业务模拟数据。如提供Mysql的ER图、可动态转换为Opengauss数据源的数据,满足多种应用场景。同时,本发明提供在线ER图可视化,可在可视化界面的组件运行日志列表界面实时观测数据生成状态,如表的生成流量、错误信息等。通过对数据生成状态的实时观测,可以及时判断生成数据的状态,方便下一步操作。若生成速度较慢或较快,可根据实际情况及时调整。若生成数据有报错信息,可及时停止并查询错误原因。避免因不能实时观测数据生成状态导致的资源浪费或数据不达预期的情况,方便了用户的使用。Specifically, after the rule configuration is completed on the configuration list page of the visual interface, it can respond immediately and generate simulation data. When the configuration rules are modified, the modified simulation data can be generated in time. After the user uploads ER diagrams of different types of databases and configures the generation rules, the target data source type can be dynamically adapted to automatically generate business simulation data. For example, it provides Mysql ER diagrams and data that can be dynamically converted to Opengauss data sources to meet various application scenarios. At the same time, the present invention provides online ER diagram visualization, and can observe the data generation status in real time on the component operation log list interface of the visualization interface, such as table generation traffic, error information, and the like. Through the real-time observation of the data generation status, the status of the generated data can be judged in time to facilitate the next operation. If the generation speed is slow or fast, it can be adjusted in time according to the actual situation. If there is an error message in the generated data, you can stop in time and check the cause of the error. It avoids the waste of resources or the situation that the data is not up to expectations due to the inability to observe the data generation status in real time, which facilitates the use of users.
在一种实现方式中,所述根据所述数据生成规则生成模拟数据,包括:In an implementation manner, the generating simulation data according to the data generation rules includes:
C1、根据所述生成次序依次为各个所述数据库表生成模拟数据;C1. Generating simulated data for each of the database tables sequentially according to the generation sequence;
C2、当主表的模拟数据生成后,在所述主表的主键中随机取得外键值。C2. After the simulation data of the main table is generated, randomly obtain the foreign key value from the primary key of the main table.
具体地,根据表的标号从小到大的次序生成数据。在为标号为n+1的表生成数据时,它引用的外键表的标号都不超过n。若已经被生成了,则它的外键值从这些已经生成的主表的主键中随机取;同维表可以一起生成,子表则等待主表完成后再生成。本发明根据实际业务ER关系图进行模拟数据,生成业务模拟数据,业务数据关联性强,操作简单。Specifically, the data is generated in ascending order of table labels. When generating data for a table labeled n+1, the labels of the foreign key tables it references do not exceed n. If it has already been generated, its foreign key value is randomly selected from the primary keys of the generated main tables; the same dimension table can be generated together, and the sub-table will wait for the completion of the main table before generating. The present invention simulates data according to the actual business ER relationship diagram to generate business simulation data, the business data has strong correlation and the operation is simple.
进一步地,如图5所示,基于上述基于ER图的模拟数据构造方法,本发明还相应提供了一种基于ER图的模拟数据构造装置,包括:Further, as shown in Figure 5, based on the above-mentioned ER diagram-based simulation data construction method, the present invention also provides a corresponding ER diagram-based simulation data construction device, including:
解析模块100,用于获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息;The parsing module 100 is configured to obtain an ER diagram, analyze the ER diagram, and generate SQL table information corresponding to the ER diagram;
渲染模块200,用于根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面;The rendering module 200 is configured to visually render the ER diagram according to the SQL table information, to obtain a visual interface corresponding to the ER diagram;
配置模块300,用于接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则;The configuration module 300 is configured to receive a rule configuration instruction, and configure data generation rules on the visual interface according to the rule configuration instruction;
生成模块400,用于根据所述数据生成规则生成模拟数据。A generation module 400, configured to generate simulation data according to the data generation rules.
如图6所示,本发明还提供一种终端,包括:存储器20、处理器10及存储在所述存储器20上并可在所述处理器10上运行的基于ER图的模拟数据构造程序30,所述基于ER图的模拟数据构造程序30被所述处理器10执行时实现如上所述的基于ER图的模拟数据构造方法的步骤。As shown in Figure 6, the present invention also provides a terminal, including: a memory 20, a processor 10, and an ER diagram-based simulation data construction program 30 stored on the memory 20 and operable on the processor 10 , when the ER diagram-based simulation data construction program 30 is executed by the processor 10, the steps of the above-mentioned ER diagram-based simulation data construction method are realized.
本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序能够被执行以用于实现如上所述的基于ER图的模拟数据构造方法的步骤。The present invention also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and the computer program can be executed to realize the steps of the method for constructing simulation data based on an ER diagram as described above.
综上所述,本发明所提供的一种基于ER图的模拟数据构造方法及装置,所述方法包括:获取ER图,对所述ER图进行解析,生成所述ER图对应的SQL表信息;根据所述SQL表信息对所述ER图进行可视化渲染,得到所述ER图对应的可视化界面;接收规则配置指令,根据所述规则配置指令在所述可视化界面上配置数据生成规则;根据所述数据生成规则生成模拟数据。本发明通过在线配置ER图中实体的数据规则、实体与实体之间关系的关联规则、配置输出数据源类型、构建模拟数据的业务规则,最终根据业务规则生成模拟数据,实现了业务规则在操作界面上可视化配置,方便调整,通过简单的界面操作即可生成符合业务场景的大量模拟数据,可快速生成模拟数据。本发明业务数据关联性强,支持不同数据库类型的ER图解析,ER图动态适配不同的数据源,支持函数插件化,数据可观测,使用方便,直观,兼容性强,应用范围广。In summary, the present invention provides a method and device for constructing simulated data based on ER diagrams. The method includes: obtaining ER diagrams, analyzing the ER diagrams, and generating SQL table information corresponding to the ER diagrams. Perform visual rendering on the ER diagram according to the SQL table information to obtain a visual interface corresponding to the ER diagram; receive a rule configuration instruction, configure data generation rules on the visualization interface according to the rule configuration instruction; Generate simulation data using the above data generation rules. The present invention configures the data rules of the entities in the ER diagram online, the association rules of the relationship between entities, configures the output data source type, and constructs the business rules of the simulated data, and finally generates the simulated data according to the business rules, realizing the operation of the business rules Visual configuration on the interface is convenient for adjustment, and a large amount of simulated data in line with business scenarios can be generated through simple interface operations, and simulated data can be quickly generated. The invention has strong business data correlation, supports ER diagram analysis of different database types, ER diagram dynamically adapts to different data sources, supports function plug-in, data can be observed, is convenient to use, intuitive, strong compatibility, and has a wide range of applications.
应当理解的是,本发明的应用不限于上述的举例,对本领域普通技术人员来说,可以根据上述说明加以改进或变换,所有这些改进和变换都应属于本发明所附权利要求的保护范围。It should be understood that the application of the present invention is not limited to the above examples, and those skilled in the art can make improvements or changes according to the above descriptions, and all these improvements and changes should belong to the scope of protection of the appended claims of the present invention.
Claims (13)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310733667.1A CN116501757B (en) | 2023-06-20 | 2023-06-20 | ER diagram-based simulation data construction method and device |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202310733667.1A CN116501757B (en) | 2023-06-20 | 2023-06-20 | ER diagram-based simulation data construction method and device |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN116501757A true CN116501757A (en) | 2023-07-28 |
| CN116501757B CN116501757B (en) | 2023-10-03 |
Family
ID=87316806
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202310733667.1A Active CN116501757B (en) | 2023-06-20 | 2023-06-20 | ER diagram-based simulation data construction method and device |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN116501757B (en) |
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120013666A (en) * | 2025-01-06 | 2025-05-16 | 复旦大学 | Financial data generation method for illegal fundraising transaction risk scenarios |
| CN120255875A (en) * | 2025-04-02 | 2025-07-04 | 北京统御至诚科技有限公司 | A method, device, electronic device and storage medium based on database |
Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130187926A1 (en) * | 2011-07-08 | 2013-07-25 | Steamfunk Labs, Inc. | Automated presentation of information using infographics |
| CN111736813A (en) * | 2020-06-24 | 2020-10-02 | 深圳前海微众银行股份有限公司 | Method, device, terminal device and storage medium for generating JPA code |
| CN112597171A (en) * | 2020-12-31 | 2021-04-02 | 平安银行股份有限公司 | Table relation visualization method and device, electronic equipment and storage medium |
| CN114637811A (en) * | 2022-03-15 | 2022-06-17 | 平安国际智慧城市科技股份有限公司 | Data table entity relation graph generation method, device, equipment and storage medium |
| CN115543428A (en) * | 2022-10-31 | 2022-12-30 | 中国人民解放军31007部队 | Simulated data generation method and device based on strategy template |
| CN115617776A (en) * | 2022-09-30 | 2023-01-17 | 国家石油天然气管网集团有限公司 | A data management system and method |
| CN115858513A (en) * | 2022-12-07 | 2023-03-28 | 腾讯医疗健康(深圳)有限公司 | Data governance method, data governance device, computer equipment and storage medium |
| CN116028653A (en) * | 2023-03-29 | 2023-04-28 | 鹏城实验室 | A method and system for visually configuring multi-source heterogeneous data to construct graphs |
-
2023
- 2023-06-20 CN CN202310733667.1A patent/CN116501757B/en active Active
Patent Citations (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20130187926A1 (en) * | 2011-07-08 | 2013-07-25 | Steamfunk Labs, Inc. | Automated presentation of information using infographics |
| CN111736813A (en) * | 2020-06-24 | 2020-10-02 | 深圳前海微众银行股份有限公司 | Method, device, terminal device and storage medium for generating JPA code |
| CN112597171A (en) * | 2020-12-31 | 2021-04-02 | 平安银行股份有限公司 | Table relation visualization method and device, electronic equipment and storage medium |
| CN114637811A (en) * | 2022-03-15 | 2022-06-17 | 平安国际智慧城市科技股份有限公司 | Data table entity relation graph generation method, device, equipment and storage medium |
| CN115617776A (en) * | 2022-09-30 | 2023-01-17 | 国家石油天然气管网集团有限公司 | A data management system and method |
| CN115543428A (en) * | 2022-10-31 | 2022-12-30 | 中国人民解放军31007部队 | Simulated data generation method and device based on strategy template |
| CN115858513A (en) * | 2022-12-07 | 2023-03-28 | 腾讯医疗健康(深圳)有限公司 | Data governance method, data governance device, computer equipment and storage medium |
| CN116028653A (en) * | 2023-03-29 | 2023-04-28 | 鹏城实验室 | A method and system for visually configuring multi-source heterogeneous data to construct graphs |
Cited By (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120013666A (en) * | 2025-01-06 | 2025-05-16 | 复旦大学 | Financial data generation method for illegal fundraising transaction risk scenarios |
| CN120255875A (en) * | 2025-04-02 | 2025-07-04 | 北京统御至诚科技有限公司 | A method, device, electronic device and storage medium based on database |
| CN120255875B (en) * | 2025-04-02 | 2025-11-25 | 北京统御至诚科技有限公司 | Database-based thinking method and device, electronic equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN116501757B (en) | 2023-10-03 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11561772B2 (en) | Low-code development platform | |
| Liu et al. | SOFL: A formal engineering methodology for industrial applications | |
| US7328428B2 (en) | System and method for generating data validation rules | |
| US8856726B2 (en) | Verification of computer-executable code generated from a slice of a model | |
| Kapos et al. | Model-based system engineering using SysML: Deriving executable simulation models with QVT | |
| Kiviluoma et al. | Spine Toolbox: A flexible open-source workflow management system with scenario and data management | |
| US20250077204A1 (en) | Software library usage optimization | |
| CN116501757B (en) | ER diagram-based simulation data construction method and device | |
| CN110221858A (en) | Analogue data generation method, device, equipment and computer readable storage medium | |
| CN104731588B (en) | Page layout document generating method and page layout file creating apparatus | |
| CN109063362B (en) | Avionics software interface control file design management system | |
| US20190042207A1 (en) | Configuration model parsing for constraint-based systems | |
| CN111026670B (en) | Test case generation method, test case generation device and storage medium | |
| CN113919158B (en) | Simulation method and device for flight control panel and storage medium | |
| US20100275183A1 (en) | Source code auditor with a customized rules builder | |
| CA3215254A1 (en) | Service design coordination among developers | |
| CN115525261A (en) | An Antlr-based On-line Design and Realization Method of Calculation Formula | |
| Bakken | maplib: Interactive, literal RDF model mapping for industry | |
| Raţiu et al. | Using reactive links to propagate changes across engineering models | |
| CN120409302B (en) | Architectural design automation modeling method and system combining LLM and MCP | |
| Anjorin | Synchronization of models on different abstraction levels using triple graph grammars | |
| CN114968809A (en) | Software quality prediction continuous integration method | |
| Kogut et al. | Features of architecture representation languages | |
| CN117555553B (en) | A method and system for generating a general software protocol interface based on AUTOSAR modeling | |
| Barashev | Translating semantic networks to UML class diagrams |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |