[go: up one dir, main page]

CN114637811A - Method, device, device and storage medium for generating entity relationship diagram of data table - Google Patents

Method, device, device and storage medium for generating entity relationship diagram of data table Download PDF

Info

Publication number
CN114637811A
CN114637811A CN202210255798.9A CN202210255798A CN114637811A CN 114637811 A CN114637811 A CN 114637811A CN 202210255798 A CN202210255798 A CN 202210255798A CN 114637811 A CN114637811 A CN 114637811A
Authority
CN
China
Prior art keywords
index
data table
entity
relationship
data
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.)
Pending
Application number
CN202210255798.9A
Other languages
Chinese (zh)
Inventor
李生波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An International Smart City Technology Co Ltd
Original Assignee
Ping An International Smart City Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Ping An International Smart City Technology Co Ltd filed Critical Ping An International Smart City Technology Co Ltd
Priority to CN202210255798.9A priority Critical patent/CN114637811A/en
Publication of CN114637811A publication Critical patent/CN114637811A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/288Entity relationship models
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24558Binary matching operations
    • G06F16/2456Join operations
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • G06F16/285Clustering or classification

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention relates to an artificial intelligence technology, and discloses a data table entity relation graph generation method, which comprises the following steps: acquiring indexes and index types of all data tables in a preset database, and inquiring the data tables according to the indexes to obtain inquiry results; when the data tables are judged to have correlation according to the query result, analyzing the data tables with correlation according to the index and the index type to obtain a main table and a sub table and a corresponding relation between the main table and the sub table; and generating an entity relation graph by using a preset drawing tool according to the corresponding relation. In addition, the invention also relates to a block chain technology, and the data table can be stored in the node of the block chain. The invention also provides a data table entity relation graph generating device, electronic equipment and a storage medium. The invention can improve the efficiency of obtaining the data table relation.

Description

数据表实体关系图生成方法、装置、设备及存储介质Method, device, device and storage medium for generating entity relationship diagram of data table

技术领域technical field

本发明涉及人工智能技术领域,尤其涉及一种数据表实体关系图生成方法、装置、电子设备及计算机可读存储介质。The present invention relates to the technical field of artificial intelligence, and in particular, to a method, apparatus, electronic device and computer-readable storage medium for generating an entity relationship diagram of a data table.

背景技术Background technique

随着互联网的发展,数据库中数据表越来越多,查看数据库的表关系越来越困难。With the development of the Internet, there are more and more data tables in the database, and it is more and more difficult to view the table relationships in the database.

历史上数据库中的表关系是由外键关系进行标识,了解一个项目的底层数据存储结构,可直接依据外键建立ER关系图,随着互联网用户增加,外键关系的大量使用会给使数据表结构牵扯太多,造成程序无法灵活的操作数据。Historically, the table relationships in the database were identified by foreign key relationships. To understand the underlying data storage structure of a project, ER relationship diagrams can be established directly based on foreign keys. With the increase of Internet users, the extensive use of foreign key relationships will make data The table structure involves too much, making the program unable to manipulate data flexibly.

现有数据库中外键基本已被废弃,表与表直接的关系也不再由数据库强关联,而是由代码控制数据之间的关系,开发者需要从页面逐层进入,找出接口,利用接口找到数据落地方式和位置,利用数据关系设计图及相关业务人员协助,才能得到一个项目的数据关系。The foreign key in the existing database has basically been abandoned, and the direct relationship between the table and the table is no longer strongly related by the database, but the relationship between the data is controlled by the code. The developer needs to enter from the page layer by layer, find the interface, and use the interface. Find the way and location of data landing, and use the data relationship design diagram and the assistance of related business personnel to obtain the data relationship of a project.

综上所述,当前获取数据表关系的方法效率低。To sum up, the current method of obtaining the relationship of the data table is inefficient.

发明内容SUMMARY OF THE INVENTION

本发明提供一种数据表实体关系图生成方法、装置及计算机可读存储介质,其主要目的在于解决获取数据表关系的方法效率低的问题。The present invention provides a method, a device and a computer-readable storage medium for generating an entity relationship diagram of a data table, the main purpose of which is to solve the problem of low efficiency of the method for obtaining the relationship of the data table.

为实现上述目的,本发明提供的一种数据表实体关系图生成方法,包括:To achieve the above purpose, a method for generating a data table entity relationship diagram provided by the present invention includes:

获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;Obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results;

根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;When judging that there is an association between the data tables according to the query result, analyze the associated data table according to the index and the index type to obtain the main table and the sub-table, and the main table and the sub-table Correspondence between;

根据所述对应关系,利用预设画图工具生成实体关系图。According to the corresponding relationship, an entity relationship diagram is generated by using a preset drawing tool.

可选地,所述根据所述索引查询所述数据表,得到查询结果,包括:Optionally, the querying the data table according to the index to obtain a query result includes:

选取所述数据库中任意一数据表的所述索引中的主键索引;Select the primary key index in the index of any data table in the database;

选取所述数据库中其他数据表的所述索引中的非主键索引;Select non-primary key indexes in the indexes of other data tables in the database;

将所述主键索引与所述非主键索引进行匹配,得到查询结果。Matching the primary key index with the non-primary key index to obtain a query result.

可选地,所述根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系,包括:Optionally, according to the index and the index type, analyzing the associated data tables to obtain the main table and the sub-table and the corresponding relationship between the main table and the sub-table, including:

根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果及数据表关系类型;According to the index and the index type, analyze the associated data table to obtain an equijoin calculation result and a data table relationship type;

根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表;Classify the associated data tables according to the calculation result of the equi-join to obtain a main table and a sub-table;

提取所述主表及子表中对应的字段信息,利用所述字段信息、所述索引、所述数据表关系类型得到所述主表与所述子表之间的对应关系。The corresponding field information in the main table and the sub-table is extracted, and the corresponding relationship between the main table and the sub-table is obtained by using the field information, the index, and the relationship type of the data table.

可选地,所述根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果,包括:Optionally, according to the index and the index type, analyze the associated data table to obtain an equijoin calculation result, including:

选取所述数据库中任意一存在关联的所述数据表的所述索引中的主键索引;Select the primary key index in the index of the associated data table in the database;

选取所述数据库中其他存在关联的所述数据表的所述索引中的非主键索引;Selecting non-primary key indexes in the indexes of other associated data tables in the database;

利用预设SQL脚本,根据所述主键索引及所述非主键索引对所述数据表进行等值连接计算,得到等值连接计算结果。Using a preset SQL script, perform an equijoin calculation on the data table according to the primary key index and the non-primary key index, and obtain an equijoin calculation result.

可选地,所述根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表,包括:Optionally, classifying the associated data tables according to the equi-join calculation results, to obtain a main table and a sub-table, including:

选取所述等值连接计算结果中次数多的数据表做为子表;Select the data table with many times in the calculation result of the equi-join as the sub-table;

选取所述等值连接计算结果中次数少的数据表做为主表。The data table with the few times in the calculation result of the equijoin is selected as the main table.

可选地,所述根据所述对应关系,利用预设画图工具生成实体关系图,包括:Optionally, according to the corresponding relationship, using a preset drawing tool to generate an entity relationship diagram, including:

从所述对应关系中提取具有预设规则的字段信息做为实体;Extract field information with preset rules from the corresponding relationship as an entity;

从所述对应关系中提取所述实体对应的特征做为属性;Extract the feature corresponding to the entity from the corresponding relationship as an attribute;

从所述对应关系中提取所述实体间的映射关系及映射基数;Extract the mapping relationship and mapping cardinality between the entities from the corresponding relationship;

根据所述实体、所述属性、所述映射关系及所述映射基数,利用预设的实体关系图生成工具,生成实体关系图。According to the entity, the attribute, the mapping relationship and the mapping cardinality, an entity relationship diagram is generated by using a preset entity relationship diagram generating tool.

可选地,所述根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图之后,所述方法还包括:Optionally, after the entity relationship diagram is generated by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes:

根据预设的映射规则,将所述实体关系图映射为关系表。The entity relationship diagram is mapped into a relationship table according to a preset mapping rule.

为了解决上述问题,本发明还提供一种数据表实体关系图生成装置,所述装置包括:In order to solve the above problems, the present invention also provides a data table entity relationship diagram generating device, the device includes:

查询模块,用于获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;a query module, configured to obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results;

分析模块,用于根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;An analysis module, configured to analyze the associated data tables according to the index and the index type when judging that there is an association between the data tables according to the query result to obtain the main table, the sub-table and the main table the corresponding relationship with the sub-table;

画图模块,用于根据所述对应关系,利用预设画图工具生成实体关系图。A drawing module, configured to generate an entity relationship diagram by using a preset drawing tool according to the corresponding relationship.

为了解决上述问题,本发明还提供一种电子设备,所述电子设备包括:In order to solve the above problems, the present invention also provides an electronic device, the electronic device includes:

至少一个处理器;以及,at least one processor; and,

与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,

所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行上述所述的数据表实体关系图生成方法。The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the data table entity relationship diagram described above Generate method.

为了解决上述问题,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质中存储有至少一个计算机程序,所述至少一个计算机程序被电子设备中的处理器执行以实现上述所述的数据表实体关系图生成方法。In order to solve the above problems, the present invention also provides a computer-readable storage medium, where at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is executed by a processor in an electronic device to realize the above-mentioned The method for generating the entity relationship diagram of the data table described above.

本发明实施例通过获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图,直接从所述数据表的索引中提取所述数据表之间的关系,无需通过外键或开发人员从页面入手反推数据关系,提升了数据表关系的获取效率。因此本发明提出的数据表实体关系图生成方法、装置、电子设备及计算机可读存储介质,可以解决获取数据表关系方法效率较低的问题。In the embodiment of the present invention, the indexes and index types of all data tables in the preset database are obtained, and the data tables are queried according to the indexes to obtain the query result; For the index and the index type, analyze the associated data tables to obtain the main table and the sub-table and the corresponding relationship between the main table and the sub-table; according to the corresponding relationship and the field information, Use the preset drawing tool to generate an entity relationship diagram, and directly extract the relationship between the data tables from the index of the data table, without using foreign keys or developers to reverse the data relationship from the page, which improves the data table relationship. Get efficiency. Therefore, the method, device, electronic device and computer-readable storage medium for generating a data table entity relationship diagram proposed by the present invention can solve the problem of low efficiency of the method for obtaining data table relationship.

附图说明Description of drawings

图1为本发明一实施例提供的数据表实体关系图生成方法的流程示意图;1 is a schematic flowchart of a method for generating an entity relationship diagram of a data table according to an embodiment of the present invention;

图2为图1所示数据表实体关系图生成方法中其中一个步骤的详细实施流程示意图;Fig. 2 is a detailed implementation flow diagram of one of the steps in the data table entity relationship diagram generation method shown in Fig. 1;

图3为图1所示数据表实体关系图生成方法中其中另一个步骤的详细实施流程示意图;Fig. 3 is a detailed implementation flowchart of another step in the method for generating an entity relationship diagram of a data table shown in Fig. 1;

图4为本发明一实施例提供的数据表实体关系图生成装置的功能模块图;4 is a functional block diagram of an apparatus for generating an entity relationship diagram of a data table provided by an embodiment of the present invention;

图5为本发明一实施例提供的实现所述数据表实体关系图生成方法的电子设备的结构示意图。FIG. 5 is a schematic structural diagram of an electronic device implementing the method for generating an entity relationship diagram of a data table according to an embodiment of the present invention.

本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.

具体实施方式Detailed ways

应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.

本申请实施例提供一种数据表实体关系图生成方法。所述数据表实体关系图生成方法的执行主体包括但不限于服务端、终端等能够被配置为执行本申请实施例提供的该方法的电子设备中的至少一种。换言之,所述数据表实体关系图生成方法可以由安装在终端设备或服务端设备的软件或硬件来执行,所述软件可以是区块链平台。所述服务端包括但不限于:单台服务器、服务器集群、云端服务器或云端服务器集群等。所述服务器可以是独立的服务器,也可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(ContentDelivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。The embodiment of the present application provides a method for generating an entity relationship diagram of a data table. The execution body of the method for generating an entity relationship diagram of a data table includes, but is not limited to, at least one of electronic devices that can be configured to execute the method provided by the embodiments of the present application, such as a server and a terminal. In other words, the method for generating the entity relationship diagram of the data table may be executed by software or hardware installed in a terminal device or a server device, and the software may be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, and the like. The server can be an independent server, or can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery network (Content Delivery Network) , CDN), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.

参照图1所示,为本发明一实施例提供的数据表实体关系图生成方法的流程示意图。在本实施例中,所述数据表实体关系图生成方法包括:Referring to FIG. 1 , it is a schematic flowchart of a method for generating an entity relationship diagram of a data table according to an embodiment of the present invention. In this embodiment, the method for generating an entity relationship diagram of a data table includes:

S1、获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果。S1. Obtain indexes and index types of all data tables in a preset database, and query the data tables according to the indexes to obtain query results.

本发明实施例中,所述预设数据库为关系数据库,所述关系数据库是建立在关系数据库模型基础上的数据库,在一个给定的应用领域中,由所有实体及实体之间联系的集合构成。所述关系数据库中表格每列表示的一个或更多的数据种类,每行包含一个唯一的数据实体。In the embodiment of the present invention, the preset database is a relational database, and the relational database is a database established on the basis of a relational database model, and in a given application field, is composed of all entities and a set of connections between entities . One or more data types represented by each column of the table in the relational database, and each row contains a unique data entity.

本发明实施例中,所述索引是对数据库的数据表中一列或多列的值进行排序的一种结构,使用所述索引可快速访问所述数据表中的特定信息。In this embodiment of the present invention, the index is a structure for sorting the values of one or more columns in a data table of a database, and specific information in the data table can be quickly accessed by using the index.

本发明实施例中,所述索引类型包括:普通索引(normal)、唯一索引(unique)、全文搜索索引(full text)。其中,所述普通索引没有限制;其中,所述唯一索引表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为唯一索引;其中,所述全文搜索索引表示全文搜索的索引,例如在进行长文搜索时,可使用所述全文搜索索引。In this embodiment of the present invention, the index types include: a normal index (normal), a unique index (unique), and a full text search index (full text). Wherein, the ordinary index is not limited; wherein, the unique index represents a unique index that does not allow repetition, and if the field information is guaranteed not to be repeated, for example, when an ID card number is used as an index, it can be set as a unique index; wherein, The full-text search index represents an index for full-text search. For example, when long-text search is performed, the full-text search index can be used.

本发明实施例中,所述索引的算法常用BTree和Hash,本发明实施例可采用BTree。In the embodiment of the present invention, BTree and Hash are commonly used in the algorithm of the index, and the embodiment of the present invention may adopt BTree.

详细地,S1中所述根据所述索引查询所述数据表,得到查询结果,包括:Specifically, in S1, the data table is queried according to the index, and the query result is obtained, including:

选取所述数据库中任意一数据表的所述索引中的主键索引;Select the primary key index in the index of any data table in the database;

选取所述数据库中其他数据表的所述索引中的非主键索引;Select non-primary key indexes in the indexes of other data tables in the database;

将所述主键索引与所述非主键索引进行匹配,得到查询结果。Matching the primary key index with the non-primary key index to obtain a query result.

本发明实施例中,所述主键索引是所述数据表中的一个或多个字段,它的值用于唯一标识所述数据表中的某一条记录。所述主键索引可以由多个关键字共同组成,并且主键索引的值不能为空也不能重复。In this embodiment of the present invention, the primary key index is one or more fields in the data table, and its value is used to uniquely identify a certain record in the data table. The primary key index may be composed of multiple keywords, and the value of the primary key index cannot be empty or repeated.

本发明实施例中,所述非主键索引为二级索引,所述非主键索引的叶子节点中保存所述主键索引的值,所述非主键索引与所述主键索引机构相同,但是所述非主键索引的值可以重复。In the embodiment of the present invention, the non-primary key index is a secondary index, the value of the primary key index is stored in the leaf nodes of the non-primary key index, and the non-primary key index is the same as the primary key index mechanism, but the non-primary key index The value of the primary key index can be repeated.

本发明实施,将所述主键索引与所述非主键索引进行匹配,得到查询结果,所述查询结果分为能从所述主键索引中查询到所述非主键索引相同的值及不能从所述主键索引中查询到所述非主键索引相同的值。In the implementation of the present invention, the primary key index and the non-primary key index are matched to obtain a query result. The same value of the non-primary key index is queried in the primary key index.

S2、根据所述查询结果判断所述数据表之间是否存在关联。S2. Determine whether there is a relationship between the data tables according to the query result.

本发明实施例,当所述查询结果为能从所述主键索引中查询到所述非主键索引相同的值时,表明所述数据表之间存在关联。In this embodiment of the present invention, when the query result is that the same value of the non-primary key index can be queried from the primary key index, it indicates that there is an association between the data tables.

本发明实施例,当所述查询结果为不能从所述主键索引中查询到所述非主键索引相同的值时,表明所述数据表之间不存在关联。In this embodiment of the present invention, when the query result is that the same value of the non-primary key index cannot be queried from the primary key index, it indicates that there is no association between the data tables.

当所述数据表与其他数据表之间不存在关联时,S3、将不存在关联的所述数据表做为基础数据表,不做处理。When there is no association between the data table and other data tables, in S3, the data table that does not have an association is used as a basic data table, and no processing is performed.

本发明实施例,所述基础数据表不涉及业务数据,主要存储事例数据及表结构注释等。In the embodiment of the present invention, the basic data table does not involve business data, and mainly stores case data and table structure annotations.

本发明实施例中,当所述数据表与其他数据表之间不存在关联关系时,将所述数据表做为基础数据表,存储在预设数据库中,不做进一步处理。In the embodiment of the present invention, when there is no association relationship between the data table and other data tables, the data table is used as a basic data table and stored in a preset database without further processing.

当根据所述查询结果判断所述数据表之间存在关联时,S4、根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系。When it is determined according to the query result that there is an association between the data tables, S4, according to the index and the index type, analyze the associated data table to obtain a main table and a sub-table, as well as the main table and the data table. Correspondence between the sub-tables.

详细地,参阅图2所示,所述S4包括:In detail, referring to Fig. 2, the S4 includes:

S41、根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果及数据表关系类型;S41, according to the index and the index type, analyze the associated data table to obtain an equi-join calculation result and a data table relationship type;

S42、根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表;S42, classify the associated data tables according to the equivalent connection calculation result to obtain a main table and a sub-table;

S43、提取所述主表及子表中对应的字段信息,利用所述字段信息、所述索引、所述数据表关系类型得到所述主表与所述子表之间的对应关系。S43. Extract the corresponding field information in the main table and the sub-table, and obtain the corresponding relationship between the main table and the sub-table by using the field information, the index, and the relationship type of the data table.

本发明实施例中,所述数据表关系类型包括:1:1,1:N,M:1,M:N,其中所述N、M分别为自然数;表示数据表之间的映射关系为1对1,1对多,多对1,多对多。In the embodiment of the present invention, the data table relationship types include: 1:1, 1:N, M:1, M:N, wherein N and M are natural numbers respectively; it means that the mapping relationship between the data tables is 1 Pair 1, 1 to many, many to 1, many to many.

其中,所述1对1(1:1),例如:对于数据表A与数据表B,所述数据表A中的每一个实体至多与所述数据表B中一个实体有关系;反之,在所述数据表B中的每个实体至多与数据表A中一个实体有关系。Wherein, the 1-to-1 (1:1), for example: for data table A and data table B, each entity in the data table A has a relationship with at most one entity in the data table B; Each entity in the data table B has a relationship with at most one entity in the data table A.

其中,所述1对多(1:N),例如:对于数据表A中的实体与数据表B中至少有N个实体有关系;并且数据表B中每一个实体至多与数据表A中一个实体有关系。Wherein, the 1-to-many (1:N), for example: for the entity in the data table A and the data table B at least N entities have a relationship; and each entity in the data table B and at most one in the data table A Entities have relationships.

其中,所述多对1(M:1),例如:数据表B中的实体与数据表A中至少有M个实体有关系;并且数据表A中每一个实体至多与数据表B中一个实体有关系。Wherein, the many-to-1 (M:1), for example: the entity in the data table B has a relationship with at least M entities in the data table A; and each entity in the data table A is at most one entity in the data table B There are relationships.

其中,所述多对多(M:N),例如:数据表A中的每一个实体与数据表B中至少有M个实体有关系,并且所述数据表B中的每一个实体与实体集A中的至少N个实体有关系。Wherein, the many-to-many (M:N), for example: each entity in the data table A has a relationship with at least M entities in the data table B, and each entity in the data table B is related to the entity set At least N entities in A have relationships.

本发明实施例中,所述实体(Entity)是客观存在并可相互区别的事物指某类事物的集合,将每一类数据对象的个体称为实体。In the embodiment of the present invention, the entity is an objectively existing and mutually distinguishable thing, which refers to a collection of certain types of things, and an individual of each type of data object is called an entity.

详细地,参阅图3所示,S41中所述根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果,包括:In detail, referring to FIG. 3 , in S41, according to the index and the index type, the associated data table is analyzed to obtain an equijoin calculation result, including:

S411、选取所述数据库中任意一存在关联的所述数据表的所述索引中的主键索引;S411, select the primary key index in the index of the data table associated with any one in the database;

S412、选取所述数据库中其他存在关联的所述数据表的所述索引中的非主键索引;S412, select a non-primary key index in the index of other associated data tables in the database;

S413、利用预设SQL脚本,根据所述主键索引及所述非主键索引对所述数据表进行等值连接计算,得到等值连接计算结果。S413. Using a preset SQL script, perform an equijoin calculation on the data table according to the primary key index and the non-primary key index, and obtain an equijoin calculation result.

本发明实施例中,所述预设SQL脚本为统计两个表中联结字段相等的ID数量。例如:SELECT count(DISTINCT t.id),count(DISTINCT m.id)FROM t_s_user_ext01 tinner join t_s_user01 m on m.id=t.user_id,其中DISTINCT t.id子为非主键值去重后的数值;(DISTINCT m.id)主为主键去重后的数据值;t_s_user_ext01为其中一数据表的表名;t_s_user01为另一数据表的表名;id为所述数据表t_s_user01的主键值;t.user_id为所述数据表t_s_user_ext01的非主键值。In the embodiment of the present invention, the preset SQL script is to count the number of IDs of the join fields in the two tables that are equal. For example: SELECT count(DISTINCT t.id), count(DISTINCT m.id) FROM t_s_user_ext01 tinner join t_s_user01 m on m.id=t.user_id, where DISTINCT t.id is the non-primary key value after deduplication; (DISTINCT m.id) The data value of the primary key after deduplication; t_s_user_ext01 is the table name of one of the data tables; t_s_user01 is the table name of another data table; id is the primary key value of the data table t_s_user01; t. user_id is the non-primary key value of the data table t_s_user_ext01.

其中,所述等值连接计算利用等值连接(inner join)运算语句实现,所述等值连接为组合两个表中的主键索引及非主键索引,当存在至少一个匹配时,返回两个表中联结字段相等的行。Wherein, the equi-join calculation is implemented by using an inner join operation statement, the equi-join is a combination of the primary key index and the non-primary key index in the two tables, and when there is at least one match, the two tables are returned. Join the rows where the fields are equal.

进一步地,所述根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表,包括:Further, classifying the associated data tables according to the equi-join calculation results to obtain a main table and a sub-table, including:

选取所述等值连接计算结果中次数多的数据表做为子表;Select the data table with many times in the calculation result of the equi-join as the sub-table;

选取所述等值连接计算结果中次数少的数据表做为主表。The data table with the few times in the calculation result of the equijoin is selected as the main table.

本发明实施例中,例如所述等值连接计算结果为所述数据表t_s_user_ext01为3,所述数据表t.user_id为2,则所述数据表t.user_id为主表,所述数据表t_s_user_ext01为子表。In the embodiment of the present invention, for example, the calculation result of the equal value connection is that the data table t_s_user_ext01 is 3 and the data table t.user_id is 2, then the data table t.user_id is the main table, and the data table t_s_user_ext01 for the subtable.

本发明实施例中,所述对应关系,包含所述数据表的关联的所有字段信息及字段之间的关联关系。In the embodiment of the present invention, the corresponding relationship includes all field information associated with the data table and the associated relationship between the fields.

本发明实施例中,通过所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系,直接从所述数据表的索引中提取所述数据表之间的关系,无需通过外键或开发人员从页面入手反推数据关系,提升了数据表关系的获取效率。In this embodiment of the present invention, through the index and the index type, the associated data tables are analyzed to obtain the main table and the sub-table and the corresponding relationship between the main table and the sub-table, and the corresponding relationship between the main table and the sub-table is obtained directly from the The relationship between the data tables is extracted from the index of the data table, and there is no need to infer the data relationship from the page through foreign keys or developers, which improves the acquisition efficiency of the data table relationship.

S5、根据所述对应关系,利用预设画图工具生成实体关系图。S5. According to the corresponding relationship, use a preset drawing tool to generate an entity relationship diagram.

本发明实施例中,所述预设画图工具可选用DbSchema、PowerDesigner、ERStudio等工具。In the embodiment of the present invention, the preset drawing tool can be selected from tools such as DbSchema, PowerDesigner, and ERStudio.

本发明实施例中,所述实体关系图为ER图(Entity Relationship Diagram),由实体、属性、映射关系、连线组成。其中,所述实体为相互区分的事物就是实体,实体可以是具体的人或物,用矩形框表示;其中所述属性实体所具有的某一特性,一个实体可由若干个属性来表征,用椭圆形表示;其中所述映射关系反映实体内部或实体之间的关联,用菱形表示。In the embodiment of the present invention, the entity relationship diagram is an ER diagram (Entity Relationship Diagram), which is composed of entities, attributes, mapping relationships, and connections. Among them, the entity is an entity that is distinguished from each other, and the entity can be a specific person or thing, which is represented by a rectangular frame; a certain characteristic of the attribute entity, an entity can be represented by several attributes, which are represented by an ellipse It is represented by a shape; wherein the mapping relationship reflects the relationship within or between entities, and is represented by a diamond.

详细地,所述S5包括:In detail, the S5 includes:

从所述对应关系中提取具有预设规则的字段信息做为实体;Extract field information with preset rules from the corresponding relationship as an entity;

从所述对应关系中提取所述实体对应的特征做为属性;Extract the feature corresponding to the entity from the corresponding relationship as an attribute;

从所述对应关系中提取所述实体间的映射关系及映射基数;Extract the mapping relationship and mapping cardinality between the entities from the corresponding relationship;

根据所述实体、所述属性、所述映射关系及所述映射基数,利用预设的实体关系图生成工具,生成实体关系图。According to the entity, the attribute, the mapping relationship and the mapping cardinality, an entity relationship diagram is generated by using a preset entity relationship diagram generating tool.

本发明实施例中,所述具有预设规则的字段信息主要为根据业务需求确认的客观存在并可以相互区别的事物。例如学生学课系统中,学生、老师、课程均为实体。In the embodiment of the present invention, the field information with preset rules is mainly objects that exist objectively and can be distinguished from each other confirmed according to business requirements. For example, in the student course system, students, teachers, and courses are all entities.

本发明实施例中,所述映射基数为所述映射关系的个数,例如实体A与实体B之间可以存在一对一联系、一对多联系、多对多联系等。In this embodiment of the present invention, the mapping cardinality is the number of the mapping relationships. For example, there may be a one-to-one relationship, a one-to-many relationship, a many-to-many relationship, and the like between entity A and entity B.

进一步地,当生成所述实体关系图之后,各个实体关系图发生属性冲突、命名冲突、结构冲突、冗余数据及冗余的实体间联系时,需修改或重构实体关系图,除此之外还可以用规范化理论消除所述冗余数据及冗余的所述实体间联系。Further, after the entity relationship diagram is generated, when attribute conflicts, naming conflicts, structural conflicts, redundant data and redundant inter-entity relationships occur in each entity relationship diagram, the entity relationship diagram needs to be modified or reconstructed. In addition, normalization theory can be used to eliminate the redundant data and redundant relationships between the entities.

本发明实施例中,所述根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图之后,所述方法还包括:根据预设的映射规则,将所述实体关系图映射为关系表。所述关系表包含行(不能重复)、列(属性)、主键、外键;所述外键为表示了两个关系表之间的相关联系。所述关系表更能直观、详细地展示所述数据表之间的关联关系,能让开发人员清晰的看到所述数据库中各个数据表之间的关联关系。In the embodiment of the present invention, after the entity relationship diagram is generated by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes: mapping the entity relationship diagram according to a preset mapping rule for the relational table. The relational table includes rows (which cannot be repeated), columns (attributes), primary keys, and foreign keys; the foreign keys represent the correlation between the two relational tables. The relationship table can display the relationship between the data tables more intuitively and in detail, so that the developer can clearly see the relationship between the various data tables in the database.

本发明实施例通过获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图,直接从所述数据表的索引中提取所述数据表之间的关系,无需通过外键或开发人员从页面入手反推数据关系,提升了数据表关系的获取效率。因此本发明提出的数据表实体关系图生成方法,可以解决获取数据表关系方法效率较低的问题。In the embodiment of the present invention, the indexes and index types of all data tables in the preset database are obtained, and the data tables are queried according to the indexes to obtain the query result; For the index and the index type, analyze the associated data tables to obtain the main table and the sub-table and the corresponding relationship between the main table and the sub-table; according to the corresponding relationship and the field information, Use the preset drawing tool to generate an entity relationship diagram, and directly extract the relationship between the data tables from the index of the data table, without using foreign keys or developers to reverse the data relationship from the page, which improves the data table relationship. Get efficiency. Therefore, the method for generating the entity relationship diagram of the data table proposed by the present invention can solve the problem of low efficiency of the method for obtaining the relationship of the data table.

如图4所示,是本发明一实施例提供的数据表实体关系图生成装置的功能模块图。As shown in FIG. 4 , it is a functional module diagram of an apparatus for generating an entity relationship diagram of a data table provided by an embodiment of the present invention.

本发明所述数据表实体关系图生成装置100可以安装于电子设备中。根据实现的功能,所述数据表实体关系图生成装置100可以包括查询模块101、分析模块102、画图模块103。本发明所述模块也可以称之为单元,是指一种能够被电子设备处理器所执行,并且能够完成固定功能的一系列计算机程序段,其存储在电子设备的存储器中。The data table entity relationship diagram generating apparatus 100 of the present invention can be installed in an electronic device. According to the implemented functions, the data table entity relationship diagram generating apparatus 100 may include a query module 101 , an analysis module 102 , and a drawing module 103 . The modules in the present invention can also be called units, which refer to a series of computer program segments that can be executed by the electronic device processor and can perform fixed functions, and are stored in the memory of the electronic device.

在本实施例中,关于各模块/单元的功能如下:In this embodiment, the functions of each module/unit are as follows:

所述查询模块101,用于获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果。The query module 101 is configured to acquire indexes and index types of all data tables in the preset database, and query the data tables according to the indexes to obtain query results.

本发明实施例中,所述预设数据库为关系数据库,所述关系数据库是建立在关系数据库模型基础上的数据库,在一个给定的应用领域中,由所有实体及实体之间联系的集合构成。所述关系数据库中表格每列表示的一个或更多的数据种类,每行包含一个唯一的数据实体。In the embodiment of the present invention, the preset database is a relational database, and the relational database is a database established on the basis of a relational database model, and in a given application field, is composed of all entities and a set of connections between entities . One or more data types represented by each column of the table in the relational database, and each row contains a unique data entity.

本发明实施例中,所述索引是对数据库的数据表中一列或多列的值进行排序的一种结构,使用所述索引可快速访问所述数据表中的特定信息。In this embodiment of the present invention, the index is a structure for sorting the values of one or more columns in a data table of a database, and specific information in the data table can be quickly accessed by using the index.

本发明实施例中,所述索引类型包括:普通索引(normal)、唯一索引(unique)、全文搜索索引(full text)。其中,所述普通索引没有限制;其中,所述唯一索引表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为唯一索引;其中,所述全文搜索索引表示全文搜索的索引,例如在进行长文搜索时,可使用所述全文搜索索引。In this embodiment of the present invention, the index types include: a normal index (normal), a unique index (unique), and a full text search index (full text). Wherein, the ordinary index is not limited; wherein, the unique index represents a unique index that does not allow repetition, and if the field information is guaranteed not to be repeated, for example, when an ID card number is used as an index, it can be set as a unique index; wherein, The full-text search index represents an index for full-text search. For example, when long-text search is performed, the full-text search index can be used.

本发明实施例中,所述索引的算法常用BTree和Hash,本发明实施例可采用BTree。In the embodiment of the present invention, BTree and Hash are commonly used in the algorithm of the index, and the embodiment of the present invention may adopt BTree.

详细地,所述查询模块101中所述根据所述索引查询所述数据表,得到查询结果,用于:Specifically, the query module 101 queries the data table according to the index to obtain query results, which are used for:

选取所述数据库中任意一数据表的所述索引中的主键索引;Select the primary key index in the index of any data table in the database;

选取所述数据库中其他数据表的所述索引中的非主键索引;Selecting non-primary key indexes in the indexes of other data tables in the database;

将所述主键索引与所述非主键索引进行匹配,得到查询结果。Matching the primary key index with the non-primary key index to obtain a query result.

本发明实施例中,所述主键索引是所述数据表中的一个或多个字段,它的值用于唯一标识所述数据表中的某一条记录。所述主键索引可以由多个关键字共同组成,并且主键索引的值不能为空也不能重复。In this embodiment of the present invention, the primary key index is one or more fields in the data table, and its value is used to uniquely identify a certain record in the data table. The primary key index may be composed of multiple keywords, and the value of the primary key index cannot be empty or repeated.

本发明实施例中,所述非主键索引为二级索引,所述非主键索引的叶子节点中保存所述主键索引的值,所述非主键索引与所述主键索引机构相同,但是所述非主键索引的值可以重复。In the embodiment of the present invention, the non-primary key index is a secondary index, the value of the primary key index is stored in the leaf nodes of the non-primary key index, and the non-primary key index is the same as the primary key index mechanism, but the non-primary key index The value of the primary key index can be repeated.

本发明实施,将所述主键索引与所述非主键索引进行匹配,得到查询结果,所述查询结果分为能从所述主键索引中查询到所述非主键索引相同的值及不能从所述主键索引中查询到所述非主键索引相同的值。In the implementation of the present invention, the primary key index and the non-primary key index are matched to obtain a query result. The same value of the non-primary key index is queried in the primary key index.

所述分析模块102,用于根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系。The analysis module 102 is configured to analyze the associated data tables according to the index and the index type when judging that there is an association between the data tables according to the query result to obtain the main table, the sub-table and all the data tables. The corresponding relationship between the main table and the sub-table.

本发明实施例,根据所述查询结果判断所述数据表之间是否存在关联。In this embodiment of the present invention, it is determined whether there is an association between the data tables according to the query result.

本发明实施例,当所述查询结果为能从所述主键索引中查询到所述非主键索引相同的值时,表明所述数据表之间存在关联。In this embodiment of the present invention, when the query result is that the same value of the non-primary key index can be queried from the primary key index, it indicates that there is an association between the data tables.

本发明实施例,当所述查询结果为不能从所述主键索引中查询到所述非主键索引相同的值时,表明所述数据表之间不存在关联。In this embodiment of the present invention, when the query result is that the same value of the non-primary key index cannot be queried from the primary key index, it indicates that there is no association between the data tables.

当所述数据表与其他数据表之间不存在关联时,将不存在关联的所述数据表做为基础数据表,不做处理。When there is no relationship between the data table and other data tables, the data table without the relationship is regarded as the basic data table, and no processing is performed.

本发明实施例,所述基础数据表不涉及业务数据,主要存储事例数据及表结构注释等。In the embodiment of the present invention, the basic data table does not involve business data, and mainly stores case data and table structure annotations.

本发明实施例中,当所述数据表与其他数据表之间不存在关联关系时,将所述数据表做为基础数据表,存储在预设数据库中,不做进一步处理。In the embodiment of the present invention, when there is no association relationship between the data table and other data tables, the data table is used as a basic data table and stored in a preset database without further processing.

当根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系。When it is determined according to the query result that there is an association between the data tables, according to the index and the index type, analyze the associated data tables to obtain a main table and a sub-table, as well as the main table and the sub-table Correspondence between tables.

详细地,参阅图2所示,所述所述分析模块102,用于:In detail, as shown in FIG. 2 , the analysis module 102 is used for:

根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果及数据表关系类型;According to the index and the index type, analyze the associated data table to obtain an equijoin calculation result and a data table relationship type;

根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表;Classify the associated data tables according to the calculation result of the equi-join to obtain a main table and a sub-table;

提取所述主表及子表中对应的字段信息,利用所述字段信息、所述索引、所述数据表关系类型得到所述主表与所述子表之间的对应关系。The corresponding field information in the main table and the sub-table is extracted, and the corresponding relationship between the main table and the sub-table is obtained by using the field information, the index, and the relationship type of the data table.

本发明实施例中,所述数据表关系类型包括:1:1,1:N,M:1,M:N,其中所述N、M分别为自然数;表示数据表之间的映射关系为1对1,1对多,多对1,多对多。In the embodiment of the present invention, the data table relationship types include: 1:1, 1:N, M:1, M:N, wherein N and M are natural numbers respectively; it means that the mapping relationship between the data tables is 1 Pair 1, 1 to many, many to 1, many to many.

其中,所述1对1(1:1),例如:对于数据表A与数据表B,所述数据表A中的每一个实体至多与所述数据表B中一个实体有关系;反之,在所述数据表B中的每个实体至多与数据表A中一个实体有关系。Wherein, the 1-to-1 (1:1), for example: for data table A and data table B, each entity in the data table A has a relationship with at most one entity in the data table B; Each entity in the data table B has a relationship with at most one entity in the data table A.

其中,所述1对多(1:N),例如:对于数据表A中的实体与数据表B中至少有N个实体有关系;并且数据表B中每一个实体至多与数据表A中一个实体有关系。Wherein, the 1-to-many (1:N), for example: for the entity in the data table A and the data table B at least N entities have a relationship; and each entity in the data table B and at most one in the data table A Entities have relationships.

其中,所述多对1(M:1),例如:数据表B中的实体与数据表A中至少有M个实体有关系;并且数据表A中每一个实体至多与数据表B中一个实体有关系。Wherein, the many-to-1 (M:1), for example: the entity in the data table B has a relationship with at least M entities in the data table A; and each entity in the data table A is at most one entity in the data table B There are relationships.

其中,所述多对多(M:N),例如:数据表A中的每一个实体与数据表B中至少有M个实体有关系,并且所述数据表B中的每一个实体与实体集A中的至少N个实体有关系。Wherein, the many-to-many (M:N), for example: each entity in the data table A has a relationship with at least M entities in the data table B, and each entity in the data table B is related to the entity set At least N entities in A have relationships.

本发明实施例中,所述实体(Entity)是客观存在并可相互区别的事物指某类事物的集合,将每一类数据对象的个体称为实体。In the embodiment of the present invention, the entity is an objectively existing and mutually distinguishable thing, which refers to a collection of certain types of things, and an individual of each type of data object is called an entity.

详细地,参阅图3所示,所述根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果,用于:In detail, referring to FIG. 3 , according to the index and the index type, analyze the associated data table to obtain an equijoin calculation result, which is used for:

选取所述数据库中任意一存在关联的所述数据表的所述索引中的主键索引;Select the primary key index in the index of the associated data table in the database;

选取所述数据库中其他存在关联的所述数据表的所述索引中的非主键索引;Selecting non-primary key indexes in the indexes of other associated data tables in the database;

利用预设SQL脚本,根据所述主键索引及所述非主键索引对所述数据表进行等值连接计算,得到等值连接计算结果。Using a preset SQL script, perform an equijoin calculation on the data table according to the primary key index and the non-primary key index, and obtain an equijoin calculation result.

本发明实施例中,所述预设SQL脚本为统计两个表中联结字段相等的ID数量。例如:SELECT count(DISTINCT t.id),count(DISTINCT m.id)FROM t_s_user_ext01t innerjoin t_s_user01 m on m.id=t.user_id,其中DISTINCT t.id子为非主键值去重后的数值;(DISTINCT m.id)主为主键去重后的数据值;t_s_user_ext01为其中一数据表的表名;t_s_user01为另一数据表的表名;id为所述数据表t_s_user01的主键值;t.user_id为所述数据表t_s_user_ext01的非主键值。In the embodiment of the present invention, the preset SQL script is to count the number of IDs of the join fields in the two tables that are equal. For example: SELECT count(DISTINCT t.id), count(DISTINCT m.id) FROM t_s_user_ext01t innerjoin t_s_user01 m on m.id=t.user_id, where DISTINCT t.id is the value after deduplication of non-primary key values; ( DISTINCT m.id) The data value of the primary key after deduplication; t_s_user_ext01 is the table name of one of the data tables; t_s_user01 is the table name of another data table; id is the primary key value of the data table t_s_user01; t.user_id It is the non-primary key value of the data table t_s_user_ext01.

其中,所述等值连接计算利用等值连接(inner join)运算语句实现,所述等值连接为组合两个表中的主键索引及非主键索引,当存在至少一个匹配时,返回两个表中联结字段相等的行。Wherein, the equi-join calculation is implemented by using an inner join operation statement, the equi-join is a combination of the primary key index and the non-primary key index in the two tables, and when there is at least one match, the two tables are returned. Join the rows where the fields are equal.

进一步地,所述根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表,用于:Further, the described data table with association is classified according to the calculation result of the equi-value connection, and the main table and the sub-table are obtained, which are used for:

选取所述等值连接计算结果中次数多的数据表做为子表;Select the data table with many times in the calculation result of the equi-join as the sub-table;

选取所述等值连接计算结果中次数少的数据表做为主表。The data table with the few times in the calculation result of the equijoin is selected as the main table.

本发明实施例中,例如所述等值连接计算结果为所述数据表t_s_user_ext01为3,所述数据表t.user_id为2,则所述数据表t.user_id为主表,所述数据表t_s_user_ext01为子表。In the embodiment of the present invention, for example, the calculation result of the equal value connection is that the data table t_s_user_ext01 is 3 and the data table t.user_id is 2, then the data table t.user_id is the main table, and the data table t_s_user_ext01 for the subtable.

本发明实施例中,所述对应关系,包含所述数据表的关联的所有字段信息及字段之间的关联关系。In this embodiment of the present invention, the corresponding relationship includes all field information associated with the data table and the associated relationship between the fields.

本发明实施例中,通过所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系,直接从所述数据表的索引中提取所述数据表之间的关系,无需通过外键或开发人员从页面入手反推数据关系,提升了数据表关系的获取效率。In this embodiment of the present invention, through the index and the index type, the associated data tables are analyzed to obtain the main table and the sub-table and the corresponding relationship between the main table and the sub-table, and the corresponding relationship between the main table and the sub-table is obtained directly from the The relationship between the data tables is extracted from the index of the data table, and there is no need to infer the data relationship from the page through foreign keys or developers, which improves the acquisition efficiency of the data table relationship.

所述画图模块103,用于根据所述对应关系,利用预设画图工具生成实体关系图。The drawing module 103 is configured to use a preset drawing tool to generate an entity relationship diagram according to the corresponding relationship.

本发明实施例中,所述预设画图工具可选用DbSchema、PowerDesigner、ERStudio等工具。In the embodiment of the present invention, the preset drawing tool can be selected from tools such as DbSchema, PowerDesigner, and ERStudio.

本发明实施例中,所述实体关系图为ER图(Entity Relationship Diagram),由实体、属性、映射关系、连线组成。其中,所述实体为相互区分的事物就是实体,实体可以是具体的人或物,用矩形框表示;其中所述属性实体所具有的某一特性,一个实体可由若干个属性来表征,用椭圆形表示;其中所述映射关系反映实体内部或实体之间的关联,用菱形表示。In the embodiment of the present invention, the entity relationship diagram is an ER diagram (Entity Relationship Diagram), which is composed of entities, attributes, mapping relationships, and connections. Among them, the entity is an entity that is distinguished from each other, and the entity can be a specific person or thing, which is represented by a rectangular frame; a certain characteristic of the attribute entity, an entity can be represented by several attributes, which are represented by an ellipse It is represented by a shape; wherein the mapping relationship reflects the relationship within or between entities, and is represented by a diamond.

详细地,所述画图模块103,用于:In detail, the drawing module 103 is used for:

从所述对应关系中提取具有预设规则的字段信息做为实体;Extract field information with preset rules from the corresponding relationship as an entity;

从所述对应关系中提取所述实体对应的特征做为属性;Extract the feature corresponding to the entity from the corresponding relationship as an attribute;

从所述对应关系中提取所述实体间的映射关系及映射基数;Extract the mapping relationship and mapping cardinality between the entities from the corresponding relationship;

根据所述实体、所述属性、所述映射关系及所述映射基数,利用预设的实体关系图生成工具,生成实体关系图。According to the entity, the attribute, the mapping relationship and the mapping cardinality, an entity relationship diagram is generated by using a preset entity relationship diagram generating tool.

本发明实施例中,所述具有预设规则的字段信息主要为根据业务需求确认的客观存在并可以相互区别的事物。例如学生学课系统中,学生、老师、课程均为实体。In the embodiment of the present invention, the field information with preset rules is mainly objects that exist objectively and can be distinguished from each other confirmed according to business requirements. For example, in the student course system, students, teachers, and courses are all entities.

本发明实施例中,所述映射基数为所述映射关系的个数,例如实体A与实体B之间可以存在一对一联系、一对多联系、多对多联系等。In this embodiment of the present invention, the mapping cardinality is the number of the mapping relationships. For example, there may be a one-to-one relationship, a one-to-many relationship, a many-to-many relationship, and the like between entity A and entity B.

进一步地,当生成所述实体关系图之后,各个实体关系图发生属性冲突、命名冲突、结构冲突、冗余数据及冗余的实体间联系时,需修改或重构实体关系图,除此之外还可以用规范化理论消除所述冗余数据及冗余的所述实体间联系。Further, after the entity relationship diagram is generated, when attribute conflicts, naming conflicts, structural conflicts, redundant data and redundant inter-entity relationships occur in each entity relationship diagram, the entity relationship diagram needs to be modified or reconstructed. In addition, normalization theory can be used to eliminate the redundant data and redundant relationships between the entities.

本发明实施例中,所述根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图之后,所述方法还包括:根据预设的映射规则,将所述实体关系图映射为关系表。所述关系表包含行(不能重复)、列(属性)、主键、外键;所述外键为表示了两个关系表之间的相关联系。所述关系表更能直观、详细地展示所述数据表之间的关联关系,能让开发人员清晰的看到所述数据库中各个数据表之间的关联关系。In the embodiment of the present invention, after the entity relationship diagram is generated by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes: mapping the entity relationship diagram according to a preset mapping rule for the relational table. The relational table includes rows (which cannot be repeated), columns (attributes), primary keys, and foreign keys; the foreign keys represent the correlation between the two relational tables. The relationship table can display the relationship between the data tables more intuitively and in detail, so that the developer can clearly see the relationship between the various data tables in the database.

详细地,本发明实施例中所述数据表实体关系图生成装置100中所述的各模块在使用时采用与上述图1至图3中所述的数据表实体关系图生成方法一样的技术手段,并能够产生相同的技术效果,这里不再赘述。In detail, each module described in the data table entity relationship diagram generating apparatus 100 in the embodiment of the present invention adopts the same technical means as the data table entity relationship diagram generating method described in FIG. 1 to FIG. 3 when used. , and can produce the same technical effect, which will not be repeated here.

如图5所示,是本发明一实施例提供的实现数据表实体关系图生成方法的电子设备的结构示意图。As shown in FIG. 5 , it is a schematic structural diagram of an electronic device for implementing a method for generating an entity relationship diagram of a data table provided by an embodiment of the present invention.

所述电子设备1可以包括处理器10、存储器11、通信总线12以及通信接口13,还可以包括存储在所述存储器11中并可在所述处理器10上运行的计算机程序,如数据表实体关系图生成程序。The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a data table entity Relationship diagram generator.

其中,所述处理器10在一些实施例中可以由集成电路组成,例如可以由单个封装的集成电路所组成,也可以是由多个相同功能或不同功能封装的集成电路所组成,包括一个或者多个中央处理器(Central Processing unit,CPU)、微处理器、数字处理芯片、图形处理器及各种控制芯片的组合等。所述处理器10是所述电子设备的控制核心(ControlUnit),利用各种接口和线路连接整个电子设备的各个部件,通过运行或执行存储在所述存储器11内的程序或者模块(例如执行数据表实体关系图生成程序等),以及调用存储在所述存储器11内的数据,以执行电子设备的各种功能和处理数据。The processor 10 may be composed of integrated circuits in some embodiments, for example, may be composed of a single packaged integrated circuit, or may be composed of multiple integrated circuits packaged with the same function or different functions, including one or A combination of multiple central processing units (Central Processing Units, CPUs), microprocessors, digital processing chips, graphics processors, and various control chips, etc. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and by running or executing the programs or modules (such as execution data) stored in the memory 11. Table entity relationship diagram generating program, etc.), and call the data stored in the memory 11 to execute various functions of the electronic device and process data.

所述存储器11至少包括一种类型的可读存储介质,所述可读存储介质包括闪存、移动硬盘、多媒体卡、卡型存储器(例如:SD或DX存储器等)、磁性存储器、磁盘、光盘等。所述存储器11在一些实施例中可以是电子设备的内部存储单元,例如该电子设备的移动硬盘。所述存储器11在另一些实施例中也可以是电子设备的外部存储设备,例如电子设备上配备的插接式移动硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(Flash Card)等。进一步地,所述存储器11还可以既包括电子设备的内部存储单元也包括外部存储设备。所述存储器11不仅可以用于存储安装于电子设备的应用软件及各类数据,例如数据表实体关系图生成程序的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, mobile hard disk, multimedia card, card-type memory (for example: SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, etc. . In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of the electronic device, such as a pluggable mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) equipped on the electronic device. ) card, flash card (Flash Card) and so on. Further, the memory 11 may also include both an internal storage unit of an electronic device and an external storage device. The memory 11 can not only be used to store application software installed in the electronic device and various types of data, such as the code of a data table entity relationship diagram generating program, etc., but also can be used to temporarily store data that has been output or will be output.

所述通信总线12可以是外设部件互连标准(peripheral componentinterconnect,简称PCI)总线或扩展工业标准结构(extended industry standardarchitecture,简称EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。所述总线被设置为实现所述存储器11以及至少一个处理器10等之间的连接通信。The communication bus 12 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus or the like. The bus can be divided into address bus, data bus, control bus and so on. The bus is configured to implement connection communication between the memory 11 and at least one processor 10 and the like.

所述通信接口13用于上述电子设备与其他设备之间的通信,包括网络接口和用户接口。可选地,所述网络接口可以包括有线接口和/或无线接口(如WI-FI接口、蓝牙接口等),通常用于在该电子设备与其他电子设备之间建立通信连接。所述用户接口可以是显示器(Display)、输入单元(比如键盘(Keyboard)),可选地,用户接口还可以是标准的有线接口、无线接口。可选地,在一些实施例中,显示器可以是LED显示器、液晶显示器、触控式液晶显示器以及OLED(Organic Light-Emitting Diode,有机发光二极管)触摸器等。其中,显示器也可以适当的称为显示屏或显示单元,用于显示在电子设备中处理的信息以及用于显示可视化的用户界面。The communication interface 13 is used for communication between the above electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (eg, a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface or a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, and the like. The display may also be appropriately called a display screen or a display unit, which is used for displaying information processed in the electronic device and for displaying a visual user interface.

图5仅示出了具有部件的电子设备,本领域技术人员可以理解的是,图5示出的结构并不构成对所述电子设备1的限定,可以包括比图示更少或者更多的部件,或者组合某些部件,或者不同的部件布置。FIG. 5 only shows an electronic device with components. Those skilled in the art can understand that the structure shown in FIG. 5 does not constitute a limitation on the electronic device 1, and may include fewer or more components than those shown in the drawings. components, or a combination of certain components, or a different arrangement of components.

例如,尽管未示出,所述电子设备还可以包括给各个部件供电的电源(比如电池),优选地,电源可以通过电源管理装置与所述至少一个处理器10逻辑相连,从而通过电源管理装置实现充电管理、放电管理、以及功耗管理等功能。电源还可以包括一个或一个以上的直流或交流电源、再充电装置、电源故障检测电路、电源转换器或者逆变器、电源状态指示器等任意组件。所述电子设备还可以包括多种传感器、蓝牙模块、Wi-Fi模块等,在此不再赘述。For example, although not shown, the electronic device may also include a power source (such as a battery) for powering the various components, preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power source can be logically connected through the power management device. Implement functions such as charge management, discharge management, and power management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components. The electronic device may further include various sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.

应该了解,所述实施例仅为说明之用,在专利申请范围上并不受此结构的限制。It should be understood that the embodiments are only used for illustration, and are not limited by this structure in the scope of the patent application.

所述电子设备1中的所述存储器11存储的数据表实体关系图生成程序是多个指令的组合,在所述处理器10中运行时,可以实现:The data table entity relationship diagram generation program stored in the memory 11 in the electronic device 1 is a combination of multiple instructions, and when running in the processor 10, it can realize:

获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;Obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results;

根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;When judging that there is an association between the data tables according to the query result, analyze the associated data table according to the index and the index type to obtain the main table and the sub-table, and the main table and the sub-table Correspondence between;

根据所述对应关系,利用预设画图工具生成实体关系图。According to the corresponding relationship, an entity relationship diagram is generated by using a preset drawing tool.

具体地,所述处理器10对上述指令的具体实现方法可参考附图对应实施例中相关步骤的描述,在此不赘述。Specifically, for the specific implementation method of the above-mentioned instruction by the processor 10, reference may be made to the description of the relevant steps in the embodiment corresponding to the accompanying drawings, which will not be repeated here.

进一步地,所述电子设备1集成的模块/单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读存储介质中。所述计算机可读存储介质可以是易失性的,也可以是非易失性的。例如,所述计算机可读介质可以包括:能够携带所述计算机程序代码的任何实体或装置、记录介质、U盘、移动硬盘、磁碟、光盘、计算机存储器、只读存储器(ROM,Read-Only Memory)。Further, if the modules/units integrated in the electronic device 1 are implemented in the form of software functional units and sold or used as independent products, they may be stored in a computer-readable storage medium. The computer-readable storage medium may be volatile or non-volatile. For example, the computer-readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a removable hard disk, a magnetic disk, an optical disc, a computer memory, a read-only memory (ROM, Read-Only). Memory).

本发明还提供一种计算机可读存储介质,所述可读存储介质存储有计算机程序,所述计算机程序在被电子设备的处理器所执行时,可以实现:The present invention also provides a computer-readable storage medium, where the readable storage medium stores a computer program, and when executed by a processor of an electronic device, the computer program can realize:

获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;Obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results;

根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;When judging that there is an association between the data tables according to the query result, analyze the associated data table according to the index and the index type to obtain the main table and the sub-table, and the main table and the sub-table Correspondence between;

根据所述对应关系,利用预设画图工具生成实体关系图。According to the corresponding relationship, an entity relationship diagram is generated by using a preset drawing tool.

在本发明所提供的几个实施例中,应该理解到,所揭露的设备,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus, apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are only illustrative. For example, the division of the modules is only a logical function division, and there may be other division manners in actual implementation.

所述作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。The modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.

另外,在本发明各个实施例中的各功能模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能模块的形式实现。In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware, or can be implemented in the form of hardware plus software function modules.

对于本领域技术人员而言,显然本发明不限于上述示范性实施例的细节,而且在不背离本发明的精神或基本特征的情况下,能够以其他的具体形式实现本发明。It will be apparent to those skilled in the art that the present invention is not limited to the details of the above-described exemplary embodiments, but that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics of the invention.

因此,无论从哪一点来看,均应将实施例看作是示范性的,而且是非限制性的,本发明的范围由所附权利要求而不是上述说明限定,因此旨在将落在权利要求的等同要件的含义和范围内的所有变化涵括在本发明内。不应将权利要求中的任何附关联图标记视为限制所涉及的权利要求。Therefore, the embodiments are to be regarded in all respects as illustrative and not restrictive, and the scope of the invention is to be defined by the appended claims rather than the foregoing description, which are therefore intended to fall within the scope of the claims. All changes within the meaning and range of the equivalents of , are included in the present invention. Any reference signs in the claims shall not be construed as limiting the involved claim.

本发明所指区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链(Blockchain),本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链可以包括区块链底层平台、平台产品服务层以及应用服务层等。The blockchain referred to in the present invention is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain, essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block. The blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.

本申请实施例可以基于人工智能技术对相关的数据进行获取和处理。其中,人工智能(Artificial Intelligence,AI)是利用数字计算机或者数字计算机控制的机器模拟、延伸和扩展人的智能,感知环境、获取知识并使用知识获得最佳结果的理论、方法、技术及应用系统。The embodiments of the present application may acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (AI) is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. .

此外,显然“包括”一词不排除其他单元或步骤,单数不排除复数。系统权利要求中陈述的多个单元或装置也可以由一个单元或装置通过软件或者硬件来实现。第一、第二等词语用来表示名称,而并不表示任何特定的顺序。Furthermore, it is clear that the word "comprising" does not exclude other units or steps and the singular does not exclude the plural. Several units or means recited in the system claims can also be realized by one unit or means by means of software or hardware. The words first, second, etc. are used to denote names and do not denote any particular order.

最后应说明的是,以上实施例仅用以说明本发明的技术方案而非限制,尽管参照较佳实施例对本发明进行了详细说明,本领域的普通技术人员应当理解,可以对本发明的技术方案进行修改或等同替换,而不脱离本发明技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be Modifications or equivalent substitutions can be made without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1.一种数据表实体关系图生成方法,其特征在于,所述方法包括:1. a data table entity relationship diagram generating method, is characterized in that, described method comprises: 获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;Obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results; 根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;When judging that there is an association between the data tables according to the query result, analyze the associated data table according to the index and the index type to obtain the main table and the sub-table, and the main table and the sub-table Correspondence between; 根据所述对应关系,利用预设画图工具生成实体关系图。According to the corresponding relationship, an entity relationship diagram is generated by using a preset drawing tool. 2.如权利要求1所述的数据表实体关系图生成方法,其特征在于,所述根据所述索引查询所述数据表,得到查询结果,包括:2. The method for generating an entity relationship diagram of a data table according to claim 1, wherein the querying the data table according to the index to obtain a query result comprises: 选取所述数据库中任意一数据表的所述索引中的主键索引;Select the primary key index in the index of any data table in the database; 选取所述数据库中其他数据表的所述索引中的非主键索引;Select non-primary key indexes in the indexes of other data tables in the database; 将所述主键索引与所述非主键索引进行匹配,得到查询结果。Matching the primary key index with the non-primary key index to obtain a query result. 3.如权利要求1所述的数据表实体关系图生成方法,其特征在于,所述根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系,包括:3. The method for generating an entity relationship diagram of a data table according to claim 1, wherein, according to the index and the index type, analyzing the associated data table to obtain a main table and a sub-table and the The corresponding relationship between the main table and the sub-table includes: 根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果及数据表关系类型;According to the index and the index type, analyze the associated data table to obtain an equijoin calculation result and a data table relationship type; 根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表;Classify the associated data tables according to the calculation result of the equi-join to obtain a main table and a sub-table; 提取所述主表及子表中对应的字段信息,利用所述字段信息、所述索引、所述数据表关系类型得到所述主表与所述子表之间的对应关系。The corresponding field information in the main table and the sub-table is extracted, and the corresponding relationship between the main table and the sub-table is obtained by using the field information, the index, and the relationship type of the data table. 4.如权利要求3所述的数据表实体关系图生成方法,其特征在于,所述根据所述索引及所述索引类型,分析存在关联的所述数据表,得到等值连接计算结果,包括:4. The method for generating an entity-relationship diagram of a data table according to claim 3, wherein, according to the index and the index type, analyzing the associated data table to obtain an equi-join calculation result, comprising: : 选取所述数据库中任意一存在关联的所述数据表的所述索引中的主键索引;Select the primary key index in the index of the associated data table in the database; 选取所述数据库中其他存在关联的所述数据表的所述索引中的非主键索引;Selecting non-primary key indexes in the indexes of other associated data tables in the database; 利用预设SQL脚本,根据所述主键索引及所述非主键索引对所述数据表进行等值连接计算,得到等值连接计算结果。Using a preset SQL script, perform an equijoin calculation on the data table according to the primary key index and the non-primary key index, and obtain an equijoin calculation result. 5.如权利要求3所述的数据表实体关系图生成方法,其特征在于,所述根据所述等值连接计算结果对存在关联的所述数据表进行分类,得到主表及子表,包括:5. The method for generating an entity-relationship diagram of a data table according to claim 3, wherein the described data table that is associated is classified according to the calculation result of the equi-value connection, and a main table and a sub-table are obtained, including : 选取所述等值连接计算结果中次数多的数据表做为子表;Select the data table with many times in the calculation result of the equi-join as the sub-table; 选取所述等值连接计算结果中次数少的数据表做为主表。The data table with the few times in the calculation result of the equijoin is selected as the main table. 6.如权利要求1中所述的数据表实体关系图生成方法,其特征在于,所述根据所述对应关系,利用预设画图工具生成实体关系图,包括:6. The method for generating an entity-relationship diagram of a data table according to claim 1, wherein, according to the corresponding relationship, utilizing a preset drawing tool to generate an entity-relationship diagram, comprising: 从所述对应关系中提取具有预设规则的字段信息做为实体;Extract field information with preset rules from the corresponding relationship as an entity; 从所述对应关系中提取所述实体对应的特征做为属性;Extract the feature corresponding to the entity from the corresponding relationship as an attribute; 从所述对应关系中提取所述实体间的映射关系及映射基数;Extract the mapping relationship and mapping cardinality between the entities from the corresponding relationship; 根据所述实体、所述属性、所述映射关系及所述映射基数,利用预设的实体关系图生成工具,生成实体关系图。According to the entity, the attribute, the mapping relationship and the mapping cardinality, an entity relationship diagram is generated by using a preset entity relationship diagram generating tool. 7.如权利要求1-6中任一项所述的数据表实体关系图生成方法,其特征在于,所述根据所述对应关系及所述字段信息,利用预设画图工具生成实体关系图之后,所述方法还包括:7. The method for generating an entity-relationship diagram of a data table according to any one of claims 1-6, wherein, after the entity-relationship diagram is generated by using a preset drawing tool according to the corresponding relationship and the field information , the method also includes: 根据预设的映射规则,将所述实体关系图映射为关系表。The entity relationship diagram is mapped into a relationship table according to a preset mapping rule. 8.一种数据表实体关系图生成装置,其特征在于,所述装置包括:8. A device for generating an entity relationship diagram of a data table, wherein the device comprises: 查询模块,用于获取预设数据库中所有数据表的索引及索引类型,根据所述索引查询所述数据表,得到查询结果;a query module, configured to obtain indexes and index types of all data tables in the preset database, query the data tables according to the indexes, and obtain query results; 分析模块,用于根据所述查询结果判断所述数据表之间存在关联时,根据所述索引及所述索引类型,分析存在关联的所述数据表得到主表及子表以及所述主表与所述子表之间的对应关系;An analysis module, configured to analyze the associated data tables according to the index and the index type when judging that there is an association between the data tables according to the query result to obtain the main table, the sub-table and the main table the corresponding relationship with the sub-table; 画图模块,用于根据所述对应关系,利用预设画图工具生成实体关系图。A drawing module, configured to generate an entity relationship diagram by using a preset drawing tool according to the corresponding relationship. 9.一种电子设备,其特征在于,所述电子设备包括:9. An electronic device, characterized in that the electronic device comprises: 至少一个处理器;以及,at least one processor; and, 与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein, 所述存储器存储有可被所述至少一个处理器执行的计算机程序,所述计算机程序被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至7中任意一项所述的数据表实体关系图生成方法。The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform any one of claims 1 to 7 The method for generating the entity relationship diagram of the data table described in the item. 10.一种计算机可读存储介质,存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1至7中任意一项所述的数据表实体关系图生成方法。10 . A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the method for generating an entity-relationship diagram of a data table according to any one of claims 1 to 7 is implemented. 11 .
CN202210255798.9A 2022-03-15 2022-03-15 Method, device, device and storage medium for generating entity relationship diagram of data table Pending CN114637811A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255798.9A CN114637811A (en) 2022-03-15 2022-03-15 Method, device, device and storage medium for generating entity relationship diagram of data table

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255798.9A CN114637811A (en) 2022-03-15 2022-03-15 Method, device, device and storage medium for generating entity relationship diagram of data table

Publications (1)

Publication Number Publication Date
CN114637811A true CN114637811A (en) 2022-06-17

Family

ID=81948830

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210255798.9A Pending CN114637811A (en) 2022-03-15 2022-03-15 Method, device, device and storage medium for generating entity relationship diagram of data table

Country Status (1)

Country Link
CN (1) CN114637811A (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115017239A (en) * 2022-07-01 2022-09-06 杭州指令集智能科技有限公司 A Method of Generating ER Diagram Based on Table Fields
CN115495620A (en) * 2022-09-28 2022-12-20 平安科技(深圳)有限公司 Data management method and related equipment based on graph structure
CN115858569A (en) * 2022-10-26 2023-03-28 之江实验室 Data table association relation classification method and device based on graph search technology
CN116303342A (en) * 2023-02-01 2023-06-23 北京三维天地科技股份有限公司 Reverse model construction method and system
CN116346416A (en) * 2023-02-17 2023-06-27 奇安信网神信息技术(北京)股份有限公司 Index-based network security data processing method, device and electronic equipment
CN116366285A (en) * 2023-02-15 2023-06-30 奇安信网神信息技术(北京)股份有限公司 Multi-data flow safety analysis method and device with dynamic index
CN116501757A (en) * 2023-06-20 2023-07-28 鹏城实验室 ER diagram-based simulation data construction method and device
CN118821188A (en) * 2023-08-08 2024-10-22 中国移动通信集团设计院有限公司 Data desensitization method, data query method and its device, equipment, and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110795509A (en) * 2019-09-29 2020-02-14 北京淇瑀信息科技有限公司 Method and device for constructing index blood relationship graph of data warehouse and electronic equipment
CN111309721A (en) * 2018-12-11 2020-06-19 北京京东尚科信息技术有限公司 Method and device for determining association relation of data table
CN111984745A (en) * 2020-08-18 2020-11-24 平安国际智慧城市科技股份有限公司 Dynamic expansion method, device, equipment and storage medium for database field
CN112131214A (en) * 2019-06-25 2020-12-25 北京京东尚科信息技术有限公司 Method, system, device and storage medium for data writing and data query
CN113934722A (en) * 2020-06-29 2022-01-14 京东科技控股股份有限公司 Method and apparatus, computer system and storage medium for generating a data table relationship diagram

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111309721A (en) * 2018-12-11 2020-06-19 北京京东尚科信息技术有限公司 Method and device for determining association relation of data table
CN112131214A (en) * 2019-06-25 2020-12-25 北京京东尚科信息技术有限公司 Method, system, device and storage medium for data writing and data query
CN110795509A (en) * 2019-09-29 2020-02-14 北京淇瑀信息科技有限公司 Method and device for constructing index blood relationship graph of data warehouse and electronic equipment
CN113934722A (en) * 2020-06-29 2022-01-14 京东科技控股股份有限公司 Method and apparatus, computer system and storage medium for generating a data table relationship diagram
CN111984745A (en) * 2020-08-18 2020-11-24 平安国际智慧城市科技股份有限公司 Dynamic expansion method, device, equipment and storage medium for database field

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
迟浩: "数据库应用基础", 31 May 2017, 光明日报出版社, pages: 191 - 192 *

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115017239A (en) * 2022-07-01 2022-09-06 杭州指令集智能科技有限公司 A Method of Generating ER Diagram Based on Table Fields
CN115495620A (en) * 2022-09-28 2022-12-20 平安科技(深圳)有限公司 Data management method and related equipment based on graph structure
CN115495620B (en) * 2022-09-28 2025-06-24 平安科技(深圳)有限公司 Data management method and related equipment based on graph structure
CN115858569A (en) * 2022-10-26 2023-03-28 之江实验室 Data table association relation classification method and device based on graph search technology
CN115858569B (en) * 2022-10-26 2025-08-19 之江实验室 Data table association relation classification method and device based on graph search technology
CN116303342A (en) * 2023-02-01 2023-06-23 北京三维天地科技股份有限公司 Reverse model construction method and system
CN116303342B (en) * 2023-02-01 2023-09-12 北京三维天地科技股份有限公司 Reverse model construction method and system
CN116366285A (en) * 2023-02-15 2023-06-30 奇安信网神信息技术(北京)股份有限公司 Multi-data flow safety analysis method and device with dynamic index
CN116346416A (en) * 2023-02-17 2023-06-27 奇安信网神信息技术(北京)股份有限公司 Index-based network security data processing method, device and electronic equipment
CN116501757A (en) * 2023-06-20 2023-07-28 鹏城实验室 ER diagram-based simulation data construction method and device
CN116501757B (en) * 2023-06-20 2023-10-03 鹏城实验室 ER diagram-based simulation data construction method and device
CN118821188A (en) * 2023-08-08 2024-10-22 中国移动通信集团设计院有限公司 Data desensitization method, data query method and its device, equipment, and storage medium

Similar Documents

Publication Publication Date Title
CN114637811A (en) Method, device, device and storage medium for generating entity relationship diagram of data table
US20150269494A1 (en) Graph-based organization entity resolution
US8713041B2 (en) Peer to peer (P2P) missing fields and field valuation feedback
US8375046B2 (en) Peer to peer (P2P) federated concept queries
US20080250006A1 (en) Peer to peer (p2p) federated concept queries
CN109325078A (en) Data blood margin determination method and device based on structural data
CN113672781A (en) Data query method, device, electronic device and storage medium
CN113961584A (en) Method and device for analyzing field blood relationship, electronic equipment and storage medium
WO2022222943A1 (en) Department recommendation method and apparatus, electronic device and storage medium
WO2022100032A1 (en) System analysis visualization method and apparatus, electronic device, and computer readable storage medium
CN111984745A (en) Dynamic expansion method, device, equipment and storage medium for database field
US8086568B2 (en) Peer to peer (P2P) concept query notification of available query augmentation within query results
Daskalaki et al. Instance matching benchmarks in the era of linked data
CN115062023A (en) Wide table optimization method and device, electronic equipment and computer readable storage medium
CN115481145A (en) Data query method, device, equipment and medium based on search engine
TW202004526A (en) Method and device for establishing index based on mobile terminal NoSQL database
CN111985194A (en) Data storage method and device, electronic equipment and storage medium
US9069816B2 (en) Distributed multi-step abstract queries
US20080250003A1 (en) Peer to peer (p2p) concept query abstraction model augmentation with federated access only elements
CN114840531B (en) Data model reconstruction method, device, equipment and medium based on blood edge relation
Satti et al. Semantic bridge for resolving healthcare data interoperability
CN115510093A (en) Data query method, device, equipment and storage medium across heterogeneous data sources
CN115629978A (en) Automated testing method, device, electronic equipment and storage medium for buried point
US20100205197A1 (en) Two-valued logic database management system with support for missing information
CN114625755A (en) Script checking method and device, electronic equipment and storage medium

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