CN114637811A - Data table entity relation graph generation method, device, equipment and storage medium - Google Patents

Data table entity relation graph generation method, device, equipment and storage medium 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
data
entity
generating
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; CALCULATING OR 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; CALCULATING OR 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; CALCULATING OR 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; CALCULATING OR 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; CALCULATING OR 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; CALCULATING OR 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

Data table entity relation graph generation method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of artificial intelligence, in particular to a method and a device for generating a data table entity relationship diagram, electronic equipment and a computer readable storage medium.
Background
With the development of the internet, more and more data tables are available in the database, and the table relationship of the database is more and more difficult to view.
The table relations in the historical database are identified by foreign key relations, a bottom data storage structure of a project is known, an ER relation graph can be directly established according to the foreign keys, and as internet users increase, the large use of the foreign key relations can lead the data table structure to be too much involved, so that the program can not flexibly operate data.
The external keys in the existing database are basically abandoned, the direct relation between the table and the table is not strongly correlated by the database, but the relation between the data is controlled by the codes, a developer needs to enter from a page layer by layer, finds out an interface, finds out the landing mode and the landing position of the data by using the interface, and obtains the data relation of a project by using a data relation design drawing and the assistance of related business personnel.
In summary, the current method for obtaining the relationship of the data table is inefficient.
Disclosure of Invention
The invention provides a method and a device for generating a data table entity relationship diagram and a computer readable storage medium, and mainly aims to solve the problem of low efficiency of a method for acquiring a data table relationship.
In order to achieve the above object, the method for generating a data table entity relationship diagram provided by the present invention comprises:
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.
Optionally, the querying the data table according to the index to obtain a query result includes:
selecting a main 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;
and matching the primary key index with the non-primary key index to obtain a query result.
Optionally, the analyzing, according to the index and the index type, the data table with association to obtain a main table and a sub table and a corresponding relationship between the main table and the sub table includes:
analyzing the data table with the association according to the index and the index type to obtain an equivalent connection calculation result and a data table relation type;
classifying the data tables with the association according to the equivalent connection calculation result to obtain a main table and a sub table;
extracting corresponding field information in the main table and the sub table, and obtaining the corresponding relation between the main table and the sub table by utilizing the field information, the index and the data table relation type.
Optionally, the analyzing the data table with the association according to the index and the index type to obtain an isovalent connection calculation result includes:
selecting a main key index in the index of any data table with association in the database;
selecting non-primary key indexes in the indexes of other data tables with association in the database;
and performing equivalent connection calculation on the data table according to the main key index and the non-main key index by using a preset SQL script to obtain an equivalent connection calculation result.
Optionally, the classifying the data table with the association according to the isovalent connection calculation result to obtain a main table and a sub table includes:
selecting a data table with a plurality of times in the equivalent connection calculation result as a sub-table;
and selecting the data table with less times in the equivalent connection calculation result as a main table.
Optionally, the generating an entity relationship diagram by using a preset drawing tool according to the corresponding relationship includes:
extracting field information with preset rules from the corresponding relation as an entity;
extracting the characteristics corresponding to the entities from the corresponding relations as attributes;
extracting the mapping relation and the mapping cardinality between the entities from the corresponding relation;
and generating an entity relationship graph by using a preset entity relationship graph generating tool according to the entity, the attribute, the mapping relationship and the mapping cardinal number.
Optionally, after the entity relationship graph is generated by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes:
and mapping the entity relationship graph into a relationship table according to a preset mapping rule.
In order to solve the above problem, the present invention further provides a data table entity relationship diagram generating apparatus, including:
the query module is used for acquiring indexes and index types of all data tables in a preset database, and querying the data tables according to the indexes to obtain query results;
the analysis module is used for analyzing the data tables with the association 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 when the data tables with the association are judged according to the query result;
and the drawing module is used for generating an entity relation diagram by using a preset drawing tool according to the corresponding relation.
In order to solve the above problem, the present invention also provides an electronic device, including:
at least one processor; and the number of the first and second groups,
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 executable by the at least one processor to enable the at least one processor to perform the data table entity relationship graph generating method described above.
In order to solve the above problem, the present invention further provides a computer-readable storage medium, in which at least one computer program is stored, and the at least one computer program is executed by a processor in an electronic device to implement the data table entity relationship diagram generation method described above.
According to the embodiment of the invention, indexes and index types of all data tables in a preset database are obtained, and the data tables are inquired 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 and the field information, directly extracting the relation between the data tables from the index of the data tables, and promoting the acquisition efficiency of the data table relation without backstepping the data relation from a page through foreign keys or developers. Therefore, the data table entity relation graph generation method, the data table entity relation graph generation device, the electronic equipment and the computer readable storage medium can solve the problem that the data table relation graph acquisition method is low in efficiency.
Drawings
FIG. 1 is a flowchart illustrating a method for generating a data table entity relationship diagram according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a detailed implementation of one step in the method for generating a data table entity relationship diagram shown in FIG. 1;
FIG. 3 is a flowchart illustrating a detailed implementation of another step in the method for generating an entity-relationship diagram of a data table shown in FIG. 1;
FIG. 4 is a functional block diagram of an apparatus for generating an entity relationship diagram of a data table according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device for implementing the method for generating an entity relationship diagram of a data table according to an embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The embodiment of the application provides a method for generating a data table entity relationship diagram. The execution subject of the data table entity relationship diagram generation method includes, but is not limited to, at least one of electronic devices such as a server and a terminal that can be configured to execute the method provided by the embodiment of the present application. In other words, the data table entity relationship diagram generation method may be executed by software or hardware installed in the terminal device or the server device, and the software may be a block chain 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 may be an independent server, or may be a cloud server that provides basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, web service, cloud communication, middleware service, domain name service, security service, Content Delivery Network (CDN), and a big data and artificial intelligence platform.
Fig. 1 is a schematic flow chart of a method for generating a data table entity relationship diagram according to an embodiment of the present invention. In this embodiment, the method for generating the data table entity relationship diagram includes:
s1, obtaining 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.
In the embodiment of the invention, the preset database is a relational database which is established on the basis of a relational database model and consists of all entities and a set of relations among the entities in a given application field. Each column of the table in the relational database represents one or more data types, and each row contains a unique data entity.
In the embodiment of the invention, the index is a structure for sequencing one or more columns of values in a data table of a database, and the index can be used for quickly accessing specific information in the data table.
In this embodiment of the present invention, the index types include: common index (normal), unique index (unique), full text search index (full text). Wherein the common index is not limited; wherein, the unique index represents a unique index which is not allowed to be repeated, and if the field information ensures that the index is not repeated, such as an identification number, the unique index can be set; wherein the full-text search index represents an index of a full-text search, such as may be used when conducting a long-text search.
In the embodiment of the invention, the indexing algorithm is commonly BTree and Hash, and BTree can be adopted in the embodiment of the invention.
In detail, in S1, the querying the data table according to the index to obtain a query result includes:
selecting a main 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;
and 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 a plurality of keys in common, and the value of the primary key index cannot be null nor repeated.
In this embodiment of the present invention, the non-primary key index is a secondary index, a leaf node of the non-primary key index stores a value of the primary key index, and the non-primary key index is the same as the primary key index mechanism, but the value of the non-primary key index may be repeated.
In the implementation of the present invention, the primary key index is matched with the non-primary key index to obtain a query result, and the query result is divided into a value that can be queried from the primary key index to be the same as the non-primary key index and a value that cannot be queried from the primary key index to be the same as the non-primary key index.
S2, judging whether the data tables are related according to the query result.
In the embodiment of the invention, when the query result indicates that the non-primary key indexes can be queried from the primary key indexes to have the same value, the data tables are associated.
In the embodiment of the invention, when the query result is that the same value of the non-primary key indexes cannot be queried from the primary key indexes, the data table is indicated to have no association.
And when no association exists between the data table and other data tables, S3, taking the data table without association as a basic data table, and not processing.
In the embodiment of the invention, the basic data table does not relate to business data and mainly stores case data, table structure comments and the like.
In the embodiment of the invention, when the data table does not have an incidence relation with other data tables, the data table is used as a basic data table and is stored in a preset database without further processing.
And when the data tables are judged to have the association according to the query result, S4, analyzing the data tables with the association according to the index and the index type to obtain a main table and a sub table and the corresponding relation between the main table and the sub table.
In detail, referring to fig. 2, the S4 includes:
s41, analyzing the data table with association according to the index and the index type to obtain an equivalent connection calculation result and a data table relation type;
s42, classifying the data tables with the association according to the equivalent connection calculation result to obtain a main table and a sub table;
s43, extracting corresponding field information in the main table and the sub table, and obtaining the corresponding relation between the main table and the sub table by using the field information, the index and the data table relation type.
In the embodiment of the present invention, the relationship type of the data table includes: 1:1,1: n, M:1 and M: N, wherein N, M are natural numbers respectively; the mapping relations between the data tables are 1 to 1, 1 to many, many to 1 and many to many.
Wherein the 1 to 1(1:1) is, for example: for data table a and data table B, each entity in data table a has a relationship with at most one entity in data table B; conversely, each entity in the data table B has a relationship with at most one entity in the data table a.
Wherein the 1-to-many (1: N), for example: for the entities in the data table A, at least N entities in the data table B are related; and each entity in data table B has a relationship with at most one entity in data table a.
Wherein the plurality of pairs 1(M:1), for example: the entities in the data table B are related to at least M entities in the data table A; and each entity in data table a has a relationship with at most one entity in data table B.
Wherein the many-to-many (M: N), for example: each entity in data table a has a relationship with at least M entities in data table B, and each entity in data table B has a relationship with at least N entities in entity set a.
In the embodiment of the invention, the Entity (Entity) is a collection of objects which exist objectively and can be distinguished from each other, and an individual of each type of data object is called an Entity.
In detail, referring to fig. 3, in S41, analyzing the data table with association according to the index and the index type to obtain an equivalence relation calculation result, including:
s411, selecting a primary key index in the index of any data table with association in the database;
s412, selecting non-primary key indexes in the indexes of other data tables with association in the database;
and S413, performing equivalent connection calculation on the data table according to the main key index and the non-main key index by using a preset SQL script to obtain an equivalent connection calculation result.
In the embodiment of the invention, the preset SQL script is used for counting the number of IDs with equal connecting fields in the two tables. For example: SELECT count (DISTINCT t.id), count (DISTINCT m.id) FROM t _ s _ user _ ext01t inner join t _ s _ user01 m _ on m.id ═ t.user _ id, wherein DISTINCT t.id is a value after non-primary key value deduplication; (DISTINCT m.id) data value after main key deduplication is mainly performed; 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 _ user 01; and t, the user _ id is a non-primary key value of the data table t _ s _ user _ ext 01.
Wherein the isojoin computation is implemented using an isojoin (inner join) operation statement that combines the primary key indices and non-primary key indices in the two tables, and returns a row in the two tables with equal join fields when there is at least one match.
Further, the classifying the data table with the association according to the isojunction calculation result to obtain a main table and a sub table includes:
selecting a data table with a plurality of times in the equivalent connection calculation result as a sub-table;
and selecting the data table with few times in the equivalent connection calculation result as a main table.
In the embodiment of the present invention, for example, if the result of the isovalent joining calculation is that the data table t _ s _ user _ ext01 is 3, and the data table t.user _ id is 2, the data table t.user _ id is a main table, and the data table t _ s _ user _ ext01 is a sub table.
In the embodiment of the present invention, the corresponding relationship includes all the associated field information of the data table and the association relationship between the fields.
In the embodiment of the invention, the data table with the association is analyzed through the index and the index type to obtain the main table and the sub table and the corresponding relation between the main table and the sub table, the relation between the data tables is directly extracted from the index of the data table, the data relation does not need to be pushed back from a page through a foreign key or a developer, and the acquisition efficiency of the data table relation is improved.
And S5, generating an entity relation graph by using a preset drawing tool according to the corresponding relation.
In the embodiment of the invention, the preset drawing tool can be selected from DbSchema, PowerDesigner, ERStudio and other tools.
In the embodiment of the invention, the Entity Relationship Diagram is an ER Diagram (Entity Relationship Diagram) and consists of entities, attributes, mapping relations and connecting lines. The entity is a thing which is distinguished from each other, namely an entity, and the entity can be a specific person or object and is represented by a rectangular frame; wherein, the attribute entity has a certain characteristic, one entity can be characterized by a plurality of attributes, and is represented by an ellipse; wherein the mapping relation reflects the association inside or between the entities and is represented by diamonds.
In detail, the S5 includes:
extracting field information with preset rules from the corresponding relation as an entity;
extracting the characteristics corresponding to the entities from the corresponding relationship as attributes;
extracting the mapping relation and the mapping cardinality between the entities from the corresponding relation;
and generating an entity relationship graph by using a preset entity relationship graph generating tool according to the entity, the attribute, the mapping relationship and the mapping cardinal number.
In the embodiment of the invention, the field information with the preset rule is mainly the object which is confirmed to exist objectively according to business requirements and can be distinguished from each other. For example, in a student class learning system, students, teachers and courses are all entities.
In the embodiment of the present invention, the mapping cardinality is the number of the mapping relationship, for example, a one-to-one relationship, a one-to-many relationship, a many-to-many relationship, and the like may exist between the entity a and the entity B.
Further, after the entity relationship diagrams are generated, when attribute conflict, naming conflict, structure conflict, redundant data and redundant entity relation occur in each entity relationship diagram, the entity relationship diagrams need to be modified or reconstructed, and besides, the redundant data and redundant entity relation can be eliminated by using a normalization theory.
In an embodiment of the present invention, after generating an entity relationship diagram by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes: and mapping the entity relationship graph into a relationship table according to a preset mapping rule. The relationship table contains rows (not repeatable), columns (attributes), primary keys, foreign keys; the foreign key represents the correlation between two relation tables. The relational table can display the incidence relation among the data tables more intuitively and in detail, and developers can clearly see the incidence relation among the data tables in the database.
According to the embodiment of the invention, indexes and index types of all data tables in a preset database are obtained, and the data tables are inquired 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 and the field information, directly extracting the relation between the data tables from the index of the data tables, and promoting the acquisition efficiency of the data table relation without backstepping the data relation from a page through foreign keys or developers. Therefore, the method for generating the data table entity relationship diagram can solve the problem of low efficiency of the method for acquiring the data table relationship diagram.
Fig. 4 is a functional block diagram of an apparatus for generating a data table entity relationship diagram according to an embodiment of the present invention.
The data table entity relationship diagram generating device 100 of the present invention can be installed in an electronic device. According to the realized functions, the data table entity relationship diagram generating device 100 can comprise a query module 101, an analysis module 102 and a drawing module 103. The module of the present invention, which may also be referred to as a unit, refers to a series of computer program segments that can be executed by a processor of an electronic device and that can perform a fixed function, and that are stored in a memory of the electronic device.
In the present embodiment, the functions regarding the respective modules/units are as follows:
the query module 101 is configured to obtain indexes and index types of all data tables in a preset database, and query the data tables according to the indexes to obtain a query result.
In the embodiment of the invention, the preset database is a relational database which is established on the basis of a relational database model and consists of all entities and a set of relations among the entities in a given application field. Each column of the table in the relational database represents one or more data types, and each row contains a unique data entity.
In the embodiment of the invention, the index is a structure for sequencing one or more columns of values in a data table of a database, and the index can be used for quickly accessing specific information in the data table.
In this embodiment of the present invention, the index types include: common index (normal), unique index (unique), full text search index (full text). Wherein the common index is not limited; wherein, the unique index represents a unique index which is not allowed to be repeated, and if the field information ensures that the index is not repeated, such as an identification number, the unique index can be set; wherein the full-text search index represents an index of a full-text search, such as may be used when conducting a long-text search.
In the embodiment of the invention, the indexing algorithm commonly uses BTree and Hash, and BTree can be adopted in the embodiment of the invention.
In detail, the query module 101 queries the data table according to the index to obtain a query result, and is configured to:
selecting a main 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;
and 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 a plurality of keys in common, and the value of the primary key index cannot be null nor repeated.
In this embodiment of the present invention, the non-primary key index is a secondary index, a leaf node of the non-primary key index stores a value of the primary key index, and the non-primary key index is the same as the primary key index mechanism, but the value of the non-primary key index may be repeated.
In the implementation of the present invention, the primary key index is matched with the non-primary key index to obtain a query result, and the query result is divided into a value that can be queried from the primary key index to be the same as the non-primary key index and a value that cannot be queried from the primary key index to be the same as the non-primary key index.
The analysis module 102 is configured to, when it is determined that there is an association between the data tables according to the query result, analyze the data tables having the association according to the index and the index type to obtain a main table and a sub table and a corresponding relationship between the main table and the sub table.
According to the embodiment of the invention, whether the data tables are associated or not is judged according to the query result.
In the embodiment of the invention, when the query result indicates that the same value of the non-primary key indexes can be queried from the primary key indexes, the data tables are associated.
In the embodiment of the invention, when the query result indicates that the same value of the non-primary key indexes cannot be queried from the primary key indexes, the data table is not associated.
And when no association exists between the data table and other data tables, taking the data table without the association as a basic data table without processing.
In the embodiment of the invention, the basic data table does not relate to business data and mainly stores case data, table structure comments and the like.
In the embodiment of the invention, when the data table does not have an incidence relation with other data tables, the data table is used as a basic data table and is stored in a preset database without further processing.
And 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.
In detail, referring to fig. 2, the analysis module 102 is configured to:
analyzing the data table with the association according to the index and the index type to obtain an equivalent connection calculation result and a data table relation type;
classifying the data tables with the association according to the equivalent connection calculation result to obtain a main table and a sub table;
and extracting corresponding field information in the main table and the sub-table, and obtaining the corresponding relation between the main table and the sub-table by utilizing the field information, the index and the data table relation type.
In the embodiment of the present invention, the relationship type of the data table includes: 1:1,1: n, M:1 and M: N, wherein N, M are natural numbers respectively; the mapping relations between the data tables are 1 to 1, 1 to many, many to 1 and many to many.
Wherein the 1 to 1(1:1) is, for example: for data table a and data table B, each entity in data table a has a relationship with at most one entity in data table B; conversely, each entity in the data table B has a relationship with at most one entity in the data table a.
Wherein the 1-to-many (1: N) is, for example: for the entities in the data table A, at least N entities in the data table B are related; and each entity in data table B has a relationship with at most one entity in data table a.
Wherein the plurality of pairs 1(M:1), for example: the entities in the data table B are related to at least M entities in the data table A; and each entity in data table a has a relationship with at most one entity in data table B.
Wherein the many-to-many (M: N), for example: each entity in data table a has a relationship with at least M entities in data table B, and each entity in data table B has a relationship with at least N entities in entity set a.
In the embodiment of the invention, the Entity (Entity) is a collection of objects which exist objectively and can be distinguished from each other, and an individual of each type of data object is called an Entity.
In detail, referring to fig. 3, the data table with association is analyzed according to the index and the index type to obtain an isojunction calculation result, which is used for:
selecting a main key index in the index of any data table with association in the database;
selecting non-primary key indexes in the indexes of other data tables with association in the database;
and performing equivalent connection calculation on the data table according to the main key index and the non-main key index by using a preset SQL script to obtain an equivalent connection calculation result.
In the embodiment of the invention, the preset SQL script is used for counting the number of IDs with equal connecting fields in the two tables. For example: SELECT count (DISTINCT t.id), count (DISTINCT m.id) FROM t _ s _ user _ ext01t inner join t _ s _ user01 m _ on m.id ═ t.user _ id, wherein DISTINCT t.id is a value after non-primary key value deduplication; (DISTINCT m.id) data value after main key deduplication is mainly performed; 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 _ user 01; and t.user _ id is a non-primary key value of the data table t _ s _ user _ ext 01.
Wherein the isojoin computation is implemented using an isojoin (inner join) operation statement that combines the primary key indices and non-primary key indices in the two tables, and returns a row in the two tables with equal join fields when there is at least one match.
Further, the data table with association is classified according to the result of the isojunction calculation to obtain a main table and a sub-table, which are used for:
selecting a data table with a plurality of times in the equivalent connection calculation result as a sub-table;
and selecting the data table with less times in the equivalent connection calculation result as a main table.
In the embodiment of the present invention, for example, if the result of the isovalent joining calculation is that the data table t _ s _ user _ ext01 is 3, and the data table t.user _ id is 2, the data table t.user _ id is a main table, and the data table t _ s _ user _ ext01 is a sub table.
In the embodiment of the present invention, the corresponding relationship includes all the associated field information of the data table and the association relationship between the fields.
In the embodiment of the invention, the data table with the association is analyzed through the index and the index type to obtain the main table and the sub table and the corresponding relation between the main table and the sub table, the relation between the data tables is directly extracted from the index of the data table, the data relation does not need to be pushed back from a page through a foreign key or a developer, and the acquisition efficiency of the data table relation is improved.
And the drawing module 103 is configured to generate an entity relationship diagram by using a preset drawing tool according to the corresponding relationship.
In the embodiment of the invention, the preset drawing tool can be selected from DbSchema, PowerDesigner, ERStudio and other tools.
In the embodiment of the invention, the Entity Relationship Diagram is an ER Diagram (Entity Relationship Diagram) and consists of entities, attributes, mapping relations and connecting lines. The entity is a thing which is distinguished from each other, namely an entity, can be a specific person or object, and is represented by a rectangular frame; wherein, the attribute entity has a certain characteristic, one entity can be characterized by a plurality of attributes, and is represented by an ellipse; wherein the mapping relation reflects the association inside or between the entities and is represented by diamonds.
In detail, the drawing module 103 is configured to:
extracting field information with preset rules from the corresponding relation as an entity;
extracting the characteristics corresponding to the entities from the corresponding relations as attributes;
extracting the mapping relation and the mapping cardinality between the entities from the corresponding relation;
and generating an entity relationship diagram by using a preset entity relationship diagram generation tool according to the entity, the attribute, the mapping relationship and the mapping cardinality.
In the embodiment of the invention, the field information with the preset rule is mainly the object which is confirmed to exist objectively according to business requirements and can be distinguished from each other. For example, in a student class learning system, students, teachers and courses are all entities.
In the embodiment of the present invention, the mapping cardinality is the number of the mapping relationship, for example, a one-to-one relationship, a one-to-many relationship, a many-to-many relationship, and the like may exist between the entity a and the entity B.
Further, after the entity relationship diagrams are generated, when attribute conflict, naming conflict, structure conflict, redundant data and redundant entity relation occur in each entity relationship diagram, the entity relationship diagrams need to be modified or reconstructed, and besides, the redundant data and redundant entity relation can be eliminated by using a normalization theory.
In an embodiment of the present invention, after generating an entity relationship diagram by using a preset drawing tool according to the corresponding relationship and the field information, the method further includes: and mapping the entity relationship graph into a relationship table according to a preset mapping rule. The relationship table contains rows (not repeatable), columns (attributes), primary keys, foreign keys; the foreign key represents the correlation between two relation tables. The relational table can display the incidence relation among the data tables in a more visual and detailed manner, and developers can clearly see the incidence relation among the data tables in the database.
In detail, in the embodiment of the present invention, when the modules in the apparatus 100 for generating an entity relationship diagram of a data table are used, the same technical means as the method for generating an entity relationship diagram of a data table described in fig. 1 to fig. 3 are used, and the same technical effect can be produced, which is not described herein again.
Fig. 5 is a schematic structural diagram of an electronic device for implementing a data table entity relationship diagram generation method according to an embodiment of the present invention.
The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may further include a computer program, such as a data table entity relationship diagram generating program, stored in the memory 11 and executable on the processor 10.
In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or may be composed of a plurality of integrated circuits packaged with the same function or different functions, and includes one or more Central Processing Units (CPUs), a microprocessor, a digital Processing chip, a graphics processor, a combination of various control chips, and the like. The processor 10 is a Control Unit (Control Unit) of the electronic device, connects various components of the electronic device by using various interfaces and lines, and executes or executes programs or modules (for example, a data table entity relationship diagram generating program and the like) stored in the memory 11 and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
The memory 11 includes at least one type of readable storage medium including flash memory, removable hard disks, multimedia cards, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, magnetic disks, optical disks, etc. The memory 11 may in some embodiments be an internal storage unit of the electronic device, for example a removable hard disk of the electronic device. The memory 11 may also be an external storage device of the electronic device in other embodiments, such as a plug-in mobile hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the electronic device. Further, the memory 11 may also include both an internal storage unit and an external storage device of the electronic device. The memory 11 may be used to store not only application software installed in the electronic device and various types of data, such as codes of a data table entity relationship diagram generation program, but also temporarily store data that has been output or is to be output.
The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is arranged to enable connection communication between the memory 11 and at least one processor 10 or the like.
The communication interface 13 is used for communication between the electronic device and other devices, and includes a network interface and a user interface. Optionally, the network interface may include a wired interface and/or a wireless interface (e.g., WI-FI interface, bluetooth interface, etc.), which are commonly 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 a standard wired interface, a wireless interface. Alternatively, 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) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable, among other things, for displaying information processed in the electronic device and for displaying a visualized user interface.
Fig. 5 only shows an electronic device with components, and it will be understood by a person skilled in the art that the structure shown in fig. 5 does not constitute a limitation of the electronic device 1, and may comprise fewer or more components than shown, or a combination of certain components, or a different arrangement of components.
For example, although not shown, the electronic device may further include a power supply (such as a battery) for supplying power to each component, and preferably, the power supply may be logically connected to the at least one processor 10 through a power management device, so that functions such as charge management, discharge management, and power consumption management are implemented through the power management device. The power supply may also include any component of one or more dc or ac power sources, recharging devices, power failure detection circuitry, power converters or inverters, power status indicators, and the like. The electronic device may further include various sensors, a bluetooth module, a Wi-Fi module, and the like, which are not described herein again.
It is to be understood that the described embodiments are for purposes of illustration only and that the scope of the appended claims is not limited to such structures.
The data table entity relationship diagram generating program stored in the memory 11 of the electronic device 1 is a combination of a plurality of instructions, and when running in the processor 10, can realize that:
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.
Specifically, the specific implementation method of the instruction by the processor 10 may refer to the description of the relevant steps in the embodiment corresponding to the drawings, which is not described herein again.
Further, the integrated modules/units of the electronic device 1, if implemented in the form of software functional units and sold or used as separate products, 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 said computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM).
The present invention also provides a computer-readable storage medium, storing a computer program which, when executed by a processor of an electronic device, may implement:
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 the embodiments provided in the present invention, it should be understood that the disclosed apparatus, device and method can be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical functional division, and other divisions may be realized in practice.
The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one position, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional module.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof.
The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
Furthermore, it will be obvious that the term "comprising" does not exclude other elements or steps, and the singular does not exclude the plural. A plurality of units or means recited in the system claims may also be implemented by one unit or means in software or hardware. The terms first, second, etc. are used to denote names, but not any particular order.
Finally, it should be noted that the above embodiments are only for illustrating the technical solutions of the present invention and not for limiting, and although the present invention is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention.

Claims (10)

1. A method for generating a data table entity relationship graph, the method comprising:
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.
2. The method for generating the data table entity relationship graph according to claim 1, wherein the querying the data table according to the index to obtain a query result comprises:
selecting a main 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;
and matching the primary key index with the non-primary key index to obtain a query result.
3. The method for generating the data table entity relationship diagram according to claim 1, wherein the analyzing the data table with association according to the index and the index type to obtain a main table and a sub table and a corresponding relationship between the main table and the sub table comprises:
analyzing the data table with the association according to the index and the index type to obtain an equivalent connection calculation result and a data table relation type;
classifying the data tables with the association according to the equivalent connection calculation result to obtain a main table and a sub table;
extracting corresponding field information in the main table and the sub table, and obtaining the corresponding relation between the main table and the sub table by utilizing the field information, the index and the data table relation type.
4. The method for generating the data table entity relationship graph according to claim 3, wherein the analyzing the data table with the association according to the index and the index type to obtain the equivalent connection calculation result comprises:
selecting a main key index in the index of any data table with association in the database;
selecting non-primary key indexes in the indexes of other data tables with association in the database;
and performing equivalent connection calculation on the data table according to the main key index and the non-main key index by using a preset SQL script to obtain an equivalent connection calculation result.
5. The method for generating the data table entity relationship diagram according to claim 3, wherein the classifying the data table with the association according to the isovalent connection calculation result to obtain a main table and a sub table comprises:
selecting a data table with a plurality of times in the equivalent connection calculation result as a sub-table;
and selecting the data table with few times in the equivalent connection calculation result as a main table.
6. The method for generating an entity relationship diagram of a data table according to claim 1, wherein the generating an entity relationship diagram by using a preset drawing tool according to the corresponding relationship comprises:
extracting field information with preset rules from the corresponding relation as an entity;
extracting the characteristics corresponding to the entities from the corresponding relations as attributes;
extracting the mapping relation and the mapping cardinality between the entities from the corresponding relation;
and generating an entity relationship graph by using a preset entity relationship graph generating tool according to the entity, the attribute, the mapping relationship and the mapping cardinal number.
7. The method for generating an entity relationship diagram of a data table according to any one of claims 1 to 6, wherein after generating an entity relationship diagram by using a preset drawing tool according to the corresponding relationship and the field information, the method further comprises:
and mapping the entity relationship graph into a relationship table according to a preset mapping rule.
8. An apparatus for generating a data table entity relationship graph, the apparatus comprising:
the query module is used for acquiring indexes and index types of all data tables in a preset database, and querying the data tables according to the indexes to obtain query results;
the analysis module is used for analyzing the data tables with the association 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 when the data tables with the association are judged according to the query result;
and the drawing module is used for generating an entity relation diagram by using a preset drawing tool according to the corresponding relation.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and (c) a second step of,
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 executable by the at least one processor to enable the at least one processor to perform the data table entity relationship graph generation method of any of claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out a data table entity relationship diagram generation method according to any one of claims 1 to 7.
CN202210255798.9A 2022-03-15 2022-03-15 Data table entity relation graph generation method, device, equipment and storage medium Pending CN114637811A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210255798.9A CN114637811A (en) 2022-03-15 2022-03-15 Data table entity relation graph generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210255798.9A CN114637811A (en) 2022-03-15 2022-03-15 Data table entity relation graph generation method, device, equipment and storage medium

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 Data table entity relation graph generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114637811A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116303342A (en) * 2023-02-01 2023-06-23 北京三维天地科技股份有限公司 Reverse model construction method and system
CN116501757A (en) * 2023-06-20 2023-07-28 鹏城实验室 ER diagram-based simulation data construction method and device

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, equipment and storage medium for data writing and data query
CN113934722A (en) * 2020-06-29 2022-01-14 京东科技控股股份有限公司 Method and device for generating data table relational graph, computer system and storage medium

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, equipment 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 device for generating data table relational graph, computer system and storage medium
CN111984745A (en) * 2020-08-18 2020-11-24 平安国际智慧城市科技股份有限公司 Dynamic expansion method, device, equipment and storage medium for database field

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
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
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

Similar Documents

Publication Publication Date Title
CN114979120B (en) Data uploading method, device, equipment and storage medium
CN114637811A (en) Data table entity relation graph generation method, device, equipment and storage medium
CN112364107A (en) System analysis visualization method and device, electronic equipment and computer readable storage medium
CN112115152A (en) Data increment updating and querying method and device, electronic equipment and storage medium
CN105302730A (en) Calculation model detection method, testing server and service platform
CN112949278A (en) Data checking method and device, electronic equipment and readable storage medium
CN112231417A (en) Data classification method and device, electronic equipment and storage medium
CN113806434A (en) Big data processing method, device, equipment and medium
CN114637866B (en) Information management method and device for digitalized new media
CN113032403A (en) Data insight method, device, electronic equipment and storage medium
CN114612194A (en) Product recommendation method and device, electronic equipment and storage medium
CN114840531A (en) Data model reconstruction method, device, equipment and medium based on blood relationship
CN113254446B (en) Data fusion method, device, electronic equipment and medium
CN114398346A (en) Data migration method, device, equipment and storage medium
CN113434542A (en) Data relation identification method and device, electronic equipment and storage medium
CN114003704A (en) Method and device for creating designated tag guest group, electronic equipment and storage medium
CN114238375B (en) Index query method and device, electronic equipment and storage medium
CN115062023A (en) Wide table optimization method and device, electronic equipment and computer readable storage medium
CN115862791A (en) Questionnaire label generation method, device, equipment and medium based on health evaluation
CN115774717A (en) Data searching method and device, electronic equipment and computer readable storage medium
CN115098534A (en) Data query method, device, equipment and medium based on index weight lifting
CN115481145A (en) Data query method, device, equipment and medium based on search engine
CN114491196A (en) Information granularity-based information export method, device, equipment and medium
CN111553133B (en) Report generation method and device, electronic equipment and storage medium
CN114490666A (en) Chart generation method, device and equipment based on data requirements 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