CN112015754A - Data query method, device and system - Google Patents

Data query method, device and system Download PDF

Info

Publication number
CN112015754A
CN112015754A CN201910461541.7A CN201910461541A CN112015754A CN 112015754 A CN112015754 A CN 112015754A CN 201910461541 A CN201910461541 A CN 201910461541A CN 112015754 A CN112015754 A CN 112015754A
Authority
CN
China
Prior art keywords
tag
query
label
database
information
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
CN201910461541.7A
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.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201910461541.7A priority Critical patent/CN112015754A/en
Publication of CN112015754A publication Critical patent/CN112015754A/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/24Querying
    • G06F16/245Query processing
    • 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/2453Query optimisation
    • 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/25Integrating or interfacing systems involving database management systems
    • G06F16/256Integrating or interfacing systems involving database management systems in federated or virtual databases
    • 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

Abstract

The invention provides a data query method, a data query device and a data query system, relates to the technical field of databases, and is used for improving the convenience of data query and expanding the application range of data query. Wherein, the method comprises the following steps: determining target data storage information according to a received tag query command and a pre-established tag mapping relation, wherein the tag mapping relation comprises an incidence relation between tag information and data storage information, and the tag query command comprises target tag information to be queried; and performing data query according to the target data storage information. The embodiment of the invention is used for data query.

Description

Data query method, device and system
Technical Field
The invention relates to the technical field of databases, in particular to a data query method, a data query device and a data query system.
Background
A database is a repository that organizes, stores, and manages data according to a data structure. With the advent of the big data age, many businesses need to query a large amount of data for required data by accessing a database.
In database applications, as the amount of data increases, new databases are usually added to reduce the pressure of a single database, and when data query is performed, required data may be distributed among multiple databases, and cross-database query is performed. Currently, when performing a cross-database Query, a Query is generally performed through Structured Query Language (SQL), in which a Query statement indicates storage information of data to be queried: the database, data tables, fields, etc.
At present, in the cross-database query mode, a user needs to be very clear of storage information of underlying data, so that the use is not convenient enough, and the use threshold is high, so that the application range of data query is limited.
Disclosure of Invention
In view of this, the present invention provides a data query method, apparatus and system, which are used to improve the convenience of data query and expand the application range of data query.
In order to achieve the above object, in a first aspect, an embodiment of the present invention provides a data query method, including:
determining target data storage information according to a received tag query command and a pre-established tag mapping relation, wherein the tag mapping relation comprises an association relation between tag information and data storage information, and the tag query command comprises target tag information to be queried;
and performing data query according to the target data storage information.
As an optional implementation manner of the embodiment of the present invention, the determining target data storage information according to the received tag query command and the pre-established tag mapping relationship includes:
analyzing the target tag information from the tag query command;
sending a request carrying the target label information to a label server to indicate the label server to determine target data storage information according to the target label information and a pre-established label mapping relation, wherein the label server stores the label mapping relation;
and receiving target data storage information returned by the label server.
As an optional implementation manner of the embodiment of the present invention, the parsing the target tag information from the tag query command includes:
analyzing the label query command to obtain an abstract syntax tree;
and extracting the target label information from the abstract syntax tree.
As an optional implementation manner of the embodiment of the present invention, the target data storage information includes data source connection information, and the performing data query according to the target data storage information includes:
analyzing the label query command to generate a Structured Query Language (SQL) statement corresponding to a database related to the target data storage information;
and accessing a corresponding database according to the SQL statement and the data source connection information to perform data query.
As an optional implementation manner of the embodiment of the present invention, the target data storage information includes database configuration information, and the performing data query according to the target data storage information includes:
when the target data storage information relates to data tables in a plurality of databases, judging whether cross-database query can be performed or not based on the database configuration information;
and when cross-database query can be carried out, cross-database query is carried out according to the target data storage information.
As an optional implementation manner of the embodiment of the present invention, the method further includes:
and when the cross-database query cannot be carried out, prompting a user to combine the data tables related to the target data storage information into the same database for carrying out data query.
As an optional implementation manner of the embodiment of the present invention, the determining whether cross-database query can be performed based on the target data storage information includes:
when the plurality of databases related to the target data storage information are all one of the first type databases, judging whether the plurality of databases are not physically and logically isolated according to the database configuration information; if yes, determining that cross-database query can be performed;
when the plurality of databases related to the target data storage information are all one of the second type databases, judging whether the data source connection information of the plurality of databases is the same; if yes, determining that cross-database query can be performed;
the first type database comprises a MySQL database and a MySQL derived database, and the second type database comprises an Open Data Processing Service (ODPS) database and an Analytical Database (ADS).
As an optional implementation manner of the embodiment of the present invention, before determining the target data storage information according to the received tag query command and the pre-established tag mapping relationship, the method further includes:
and generating database configuration information of the database according to the database configuration operation of the user.
As an optional implementation manner of the embodiment of the present invention, before determining the target data storage information according to the received tag query command and the pre-established tag mapping relationship, the method further includes:
generating the label mapping relation according to a first label configuration operation of a user;
after the generating the tag mapping relationship according to the first tag configuration operation of the user, the method further includes:
and updating the label mapping relation according to the second label configuration operation of the user.
As an optional implementation manner of the embodiment of the present invention, before determining the target data storage information according to the received tag query command and the pre-established tag mapping relationship, the method further includes:
receiving a data query request carrying the tag query command;
after the querying data according to the target data storage information, the method further comprises:
and returning a data query result.
As an optional implementation manner of the embodiment of the present invention, the receiving a data query request carrying the tag query command includes:
and receiving a data query request carrying the tag query command through a tag query Application Program Interface (API).
As an optional implementation manner of the embodiment of the present invention, the tag query command is a tag query language TQL statement.
As an optional implementation manner of the embodiment of the present invention, the tag information includes an entity and a tag, and the data storage information includes a data table, a database where the data table is located, and a field included in the data table; the label mapping relationship specifically includes an association relationship between an entity and a label, and an association relationship between a label and a field of a data table in a database, where the label is an attribute of the entity, each entity includes at least one label, and each label is associated with at least one data table.
In a second aspect, an embodiment of the present invention provides a data query method, including:
receiving a request which is sent by data query equipment and carries the target label information;
determining target data storage information according to the target label information and a pre-established label mapping relation, wherein the label mapping relation comprises an incidence relation between the label information and the data storage information;
and returning the target data storage information to the data query equipment.
As an optional implementation manner of the embodiment of the present invention, the data storage information includes database configuration information, and before determining the target data storage information according to the target tag information and a pre-established tag mapping relationship, the method further includes:
and generating database configuration information of the database according to the database configuration operation of the user.
As an optional implementation manner of the embodiment of the present invention, before determining the target data storage information according to the target tag information and a pre-established tag mapping relationship, the method further includes:
generating the label mapping relation according to a first label configuration operation of a user;
after the generating the tag mapping relationship according to the first tag configuration operation of the user, the method further includes:
and updating the label mapping relation according to the second label configuration operation of the user.
In a third aspect, an embodiment of the present invention provides a data query apparatus, including:
the receiving module is used for receiving a label inquiry command;
the determining module is used for determining target data storage information according to the tag query command received by the receiving module and a pre-established tag mapping relation, wherein the tag mapping relation comprises an incidence relation between tag information and data storage information, and the tag query command comprises target tag information to be queried;
and the query module is used for carrying out data query according to the target data storage information.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: a sending module, wherein the determining module is specifically configured to: analyzing the target tag information from the tag query command;
the sending module is used for: sending a request carrying the target label information to a label server to indicate the label server to determine target data storage information according to the target label information and a pre-established label mapping relation, wherein the label server stores the label mapping relation;
the receiving module is further configured to: and receiving target data storage information returned by the label server.
As an optional implementation manner of the embodiment of the present invention, the determining module is specifically configured to:
analyzing the label query command to obtain an abstract syntax tree;
and extracting the target label information from the abstract syntax tree.
As an optional implementation manner of the embodiment of the present invention, the query module is specifically configured to:
analyzing the label query command to generate a Structured Query Language (SQL) statement corresponding to a database related to the target data storage information;
and accessing a corresponding database according to the SQL statement and the data source connection information to perform data query.
As an optional implementation manner of the embodiment of the present invention, the target data storage information includes database configuration information, and the query module is specifically configured to:
when the target data storage information relates to data tables in a plurality of databases, judging whether cross-database query can be performed or not based on the database configuration information;
and when cross-database query can be carried out, cross-database query is carried out according to the target data storage information.
As an optional implementation manner of the embodiment of the present invention, the query module is further configured to:
and when the cross-database query cannot be carried out, prompting a user to combine the data tables related to the target data storage information into the same database for carrying out data query.
As an optional implementation manner of the embodiment of the present invention, the database configuration information includes data source connection information, and the query module is specifically configured to:
when the plurality of databases related to the target data storage information are all one of the first type databases, judging whether the plurality of databases are not physically and logically isolated according to the database configuration information; if yes, determining that cross-database query can be performed;
when the plurality of databases related to the target data storage information are all one of the second type databases, judging whether the data source connection information of the plurality of databases is the same; if yes, determining that cross-database query can be performed;
the first type database comprises a MySQL database and a MySQL derived database, and the second type database comprises an Open Data Processing Service (ODPS) database and an Analytical Database (ADS).
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and the first generation module is used for generating database configuration information of the database according to the database configuration operation of the user before the determination module determines the target data storage information according to the received label query command and the pre-established label mapping relation.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
the second generation module is used for generating the label mapping relation according to the first label configuration operation of the user before the determination module determines the target data storage information according to the received label query command and the pre-established label mapping relation;
the device further comprises: and the updating module is used for updating the label mapping relation according to the second label configuration operation of the user after the second generating module generates the label mapping relation according to the first label configuration operation of the user.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and the return module is used for returning the data query result.
As an optional implementation manner of the embodiment of the present invention, the receiving module is specifically configured to:
and receiving a data query request carrying the tag query command through a tag query Application Program Interface (API).
As an optional implementation manner of the embodiment of the present invention, the tag query command is a tag query language TQL statement.
As an optional implementation manner of the embodiment of the present invention, the tag information includes an entity and a tag, and the data storage information includes a data table, a database where the data table is located, and a field included in the data table; the label mapping relationship specifically includes an association relationship between an entity and a label, and an association relationship between a label and a field of a data table in a database, where the label is an attribute of the entity, each entity includes at least one label, and each label is associated with at least one data table.
In a fourth aspect, an embodiment of the present invention provides a data query apparatus, including:
the receiving module is used for receiving a request which is sent by data query equipment and carries the target label information;
the determining module is used for determining target data storage information according to the target label information and a pre-established label mapping relation, wherein the label mapping relation comprises an incidence relation between the label information and the data storage information;
and the sending module is used for returning the target data storage information to the data query equipment.
As an optional implementation manner of the embodiment of the present invention, the data storage information includes database configuration information, and the apparatus further includes:
and the first generation module is used for generating database configuration information of the database according to the database configuration operation of the user before the determination module determines the target data storage information according to the target label information and the pre-established label mapping relation.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
the second generation module is used for generating the label mapping relation according to the first label configuration operation of the user before the receiving module determines the target data storage information according to the target label information and the pre-established label mapping relation;
the device further comprises: and the updating module is used for updating the label mapping relation according to the second label configuration operation of the user after the second generating module generates the label mapping relation according to the first label configuration operation of the user.
In a fifth aspect, an embodiment of the present invention provides a data query device, including: a memory for storing a computer program and a processor; the processor is configured to perform the method of the first aspect or any of the embodiments of the first aspect when the computer program is invoked.
In a sixth aspect, an embodiment of the present invention provides a tag server, including: a memory for storing a computer program and a processor; the processor is adapted to perform the method of the second aspect or any of the embodiments of the second aspect when the computer program is invoked.
In a seventh aspect, an embodiment of the present invention provides a data query system, including: a data query device as described in the fifth aspect above and a tag server as described in the sixth aspect above.
In an eighth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method of the first aspect or the second aspect.
According to the data query method, the device and the system provided by the embodiment of the invention, when a tag query command is received, target data storage information is determined according to the received tag query command and a pre-established tag mapping relation, wherein the tag mapping relation comprises an incidence relation between tag information and data storage information, and the tag query command comprises target tag information to be queried; and then, data query is carried out according to the target data storage information. Due to the technical scheme provided by the embodiment of the invention, when a user inquires data, the user only needs to specify the label information to be inquired without paying attention to specific data storage information such as a database, a data table, a field and the like, so that the data inquiry system is more convenient to use, the use threshold is reduced, and the application range of data inquiry is expanded.
Drawings
Fig. 1 is a schematic flow chart of a data query method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for determining target data storage information according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a method for performing data query according to target data storage information according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a data query device according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a tag server according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a data query system according to an embodiment of the present invention.
Detailed Description
Aiming at the technical problems that the storage information of bottom data is very clear to a user, so that the data query is inconvenient to use and the application range is limited in the existing cross-database query method, the embodiment of the invention provides a data query method, a device and a system, wherein data query equipment determines target data storage information according to a received tag query command and a pre-established tag mapping relation when receiving the tag query command, wherein the tag mapping relation comprises the association relation between the tag information and the data storage information, and the tag query command comprises the target tag information to be queried; and then, data query is carried out according to the target data storage information, so that when a user carries out data query, the user only needs to specify the label information to be queried without paying attention to specific data storage information such as a database, a data table, a field and the like, the convenience of data query is improved, and the application range of data query is expanded.
In the following, some terms involved in the embodiments of the present invention are first explained to facilitate understanding of the technical solutions in the embodiments of the present invention:
entity: objects or relationships, where an object is an abstraction of real things, such as: personnel, trains, hotels, cases, etc.; relationships are established on two or more objects, such as: train trip, hotel accommodation, relationship between personnel and case, and the like.
Labeling: description attributes attached to an entity, such as: the person's name, age, and native place tags belong to the person's attributes of the entity; labels such as train trip time, departure station and destination belong to the attribute of the relationship of personnel train trip; the hotel stay time and the number of hotel stay days are attributes of this relationship of the staff hotel stay.
Data table: a tag for an entity may be associated with at least one table stored in a database.
TQL: the Tagged Query Language (TQL), a statement composed of entities and tags, is written in a form similar to SQL, where the entities are similar to data tables in SQL and the tags are similar to fields of data tables in SQL.
AST: an Abstract Syntax Tree (AST) is an Abstract representation of the source code Syntax structure. It represents the syntactic structure of the programming language in the form of a tree, each node on the tree representing a structure in the source code.
The technical solution of the present invention will be described in detail below with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments.
Fig. 1 is a schematic flowchart of a data query method according to an embodiment of the present invention, and as shown in fig. 1, the method according to the embodiment may include the following steps:
s110, determining target data storage information according to the received label query command and a label mapping relation established in advance.
In this embodiment, the data query device may pre-establish a label mapping relationship, so as to facilitate later database query. Specifically, the label mapping relationship can be stored in the data query device to facilitate data query; the label mapping relation can also be stored in the label server, so that the pressure of the data query device is reduced, and the management of the label mapping relation is facilitated.
When the tag mapping relationship is specifically established, the data query device or the tag server may import the tag mapping relationship from other devices, or the user may perform a tag configuration operation (referred to as a first tag configuration operation herein) through the client or directly on the data query device or the tag server, and after receiving the first tag configuration operation, the data query device or the tag server generates the tag mapping relationship according to the first tag configuration operation.
The label mapping relation comprises an incidence relation between label information and data storage information. In this embodiment, the tag information may include an entity and a tag, and the data storage information may include a data table, a database where the data table is located, and a field included in the data table; the label mapping relationship may specifically include an association relationship between the entity and the label, and an association relationship between the label and a field of a data table in the database.
The first tag configuration operation may include an association operation of the entity with a data table in the database, and an association operation of the tag with a field in the data table.
In a specific configuration, an entity may associate data tables in one or more databases, and for each database associated, the entity may associate one or more data tables in the database; a tag may associate data tables in multiple databases, and for each database associated, the tag associates a field of one of the data tables in that database. Assuming that an entity is associated with M data tables, a tag of the entity may be associated with a field of N data tables in the M data tables, where M and N are positive integers, and N is less than or equal to M.
In this embodiment, after the tag mapping relationship is established, the data query device or the tag server may also update the tag mapping relationship. Specifically, the tag mapping relationship may be updated according to a second tag configuration operation of the user. Wherein the second tag configuration operation may include adding, deleting and/or modifying a tag mapping relationship.
After the label mapping relation is established, a user can input a label query command and perform data query based on the label mapping relation.
For convenience of understanding, the tag query command in this embodiment is exemplarily described as a TQL statement, and the TQL statement is also used in the following description instead of the tag query command.
In this embodiment, a plurality of data tables are abstracted into one entity through the label mapping relationship, which is equivalent to one table for a user, and data query can be performed only by providing label information (including labels and entities) during query. Similar to the query of data by using SQL statements, when querying data according to the tag mapping relationship, corresponding TQL statements may be used, where the TQL statements include tag information to be queried (referred to herein as target tag information).
Specifically, the data query device may receive the TQL statements input by the user through the client or directly, and in addition, in this embodiment, the tag query function may also be saved as an Application Programming Interface (API), and then the data query device may also receive the TQL statements input by the user through the tag query API, so that the TQL statements may be called by other applications, and thus, the Application range of the tag query may be expanded.
In this embodiment, when the tag mapping relationship is stored in the data query device, in a specific query, the data query device may first parse the target tag information from the TQL statement, and then determine the data storage information (referred to as target data storage information herein) corresponding to the target tag information directly according to the target tag information and the pre-established tag mapping relationship.
When the label mapping relationship is stored in the label server, it can be implemented according to the method shown in fig. 2 when querying specifically. Fig. 2 is a schematic flowchart of a method for determining target data storage information according to an embodiment of the present invention, as shown in fig. 2, the method includes the following steps:
and S111, the data query equipment analyzes target label information from the TQL sentences.
Specifically, the data query device may parse the TQL statement by using a syntax parser to obtain an abstract syntax tree, traverse nodes of the parsed abstract syntax tree, and extract target tag information, that is, entities and tags related to the abstract syntax tree, from the abstract syntax tree.
S112, the data query equipment sends a request carrying target label information to the label server.
After the data query device parses the target tag information, it may send a request (referred to as a storage information obtaining request) carrying the target tag information to the tag server to obtain target data storage information corresponding to the target tag information.
S113, the label server receives a request which is sent by the data query equipment and carries target label information.
S114, the label server determines target data storage information according to the target label information and a label mapping relation established in advance.
After receiving the storage information acquisition request, the tag server queries the tag mapping relationship according to the entity and the tag in the target tag information, and can determine the data table and the field (namely the target data storage information) where the tag is located.
S115, the tag server returns target data storage information to the data query device.
And after determining the target data storage information, the tag server returns the target data storage information to the data query equipment.
S116, the data query equipment receives the target data storage information returned by the label server.
The data query device receives the target data storage information from the tag server and can then perform data query according to the target data storage information.
And S120, performing data query according to the target data storage information.
After determining the target data storage information, the data query device can analyze the TQL statements, generate SQL statements corresponding to the database related to the target data storage information, and then perform data query on the database related to the target data storage information according to the SQL statements. Therefore, the user does not need to write the corresponding SQL sentences according to the database to be accessed, and only needs to write the uniform TQL sentences, namely, the user does not need to consider the difference of the database, so that the convenience of data query of the user can be improved, the use threshold can be reduced, and the application range of data query is expanded.
For example: an entity obj1 has two tags t1 and t2, and t1 and t2 are associated with a table, respectively, wherein: tag t1 is associated with table1.col1, and tag t2 is associated with table2.col 1.
The TQL sentences entered by the user are: select t1, t2 from obj1, the corresponding SQL statement is:
select table.col1 as t1,table2.col1 as t2 from table1 left join table2 on table1.id=table2.id。
in this embodiment, the database to which the target data storage information relates may be one database or may be multiple databases, and when multiple databases are involved, according to the tag information in the TQL statements, SQL statements corresponding to each database in the multiple databases are respectively generated, and then data queries are respectively performed on the corresponding databases.
In this embodiment, the target data storage information may include data source connection information (may include information such as an access account and a password of a database related in the target data storage information), and when a specific query is performed, the data query device may access the corresponding database according to the SQL statement and the data source connection information in the target data storage information to perform the data query.
In addition, in this embodiment, when the target data storage information relates to a plurality of databases, the data query device needs to perform cross-database query.
In consideration of factors such as the security of the database, the database supporting the cross-database query needs to satisfy a certain condition. Before data query is carried out, a user can set database configuration information of a database, and in concrete implementation, the database configuration information is similar to the label mapping relation establishment, the user can carry out database configuration operation on data query equipment or a label server through a client side or directly, and after the data query equipment or the label server receives the database configuration operation, the database configuration information of the database is generated according to the database configuration operation, so that whether cross-database query can be carried out or not is judged according to the database configuration information at a later stage. The database configuration information may include database instance information, account authority information, data source connection information, and the like.
For different types of databases, different configuration policies may be employed in this embodiment. For example: for a first type of database such as a MySQL database, a MySQL derived database and the like, if cross-database query is to be supported, the database needs to be ensured to be physically and logically not isolated, and specifically, a database instance of the database supporting the cross-database query and account authority information can be set to be the same; for a second type of database, such as an Open Data Processing Service (ODPS) database (including a big Data computing Service (MaxCompute) database) and an Analytic database (analytical DB, ADS), to support cross-database query, it is required to ensure that connection information of Data sources of the type of database is the same, that is, the connection information of Data sources of the type of database supporting cross-database query is set to be consistent information. Of course, the above is only an example, and according to needs, the first type database and the second type database may further include other databases, and further, the databases of more types may be divided according to actual situations of the accessed databases, and the corresponding specific conditions for supporting the cross-database query may also be set according to actual needs, which is not particularly limited in this embodiment.
After the database configuration information is set, in the present embodiment, when the target data storage information relates to data tables in a plurality of databases, data query may be performed according to the method shown in fig. 3. Fig. 3 is a schematic flowchart of a method for querying data according to target data storage information according to an embodiment of the present invention, as shown in fig. 3, the method includes the following steps:
s121, judging whether cross-database query can be performed or not based on database configuration information; if so, go to step S122, otherwise, go to step S123.
Specifically, when determining whether cross-database query is possible, based on the database configuration information of the above example, the following method may be adopted for determination:
when the plurality of databases related to the target data storage information are all one of the first type databases, judging whether the plurality of databases are not physically and logically isolated according to the database configuration information; if yes, determining that cross-database query can be performed; if not, determining that cross-database query cannot be performed. For example: when a plurality of databases related to the target data storage information are MySQL databases, if the plurality of databases are in the same database instance and account authority information is consistent, cross-database query can be performed.
When the plurality of databases related to the target data storage information are all one of the second type databases, judging whether the data source connection information of the plurality of databases is the same; if yes, determining that cross-database query can be performed; if not, determining that cross-database query cannot be performed. For example: when a plurality of databases related to the target data storage information are all ODPS databases, if the connection information of the data sources of the plurality of databases is consistent, cross-database query can be performed.
When the plurality of databases involved in the target data storage information do not belong to either of the two cases, it is determined that cross-database querying is not possible.
And S122, performing cross-database query according to the target data storage information.
Specifically, when the data query device determines that cross-database query can be performed, cross-database query can be performed according to the target data storage information, that is, the TQL statements are analyzed to generate SQL statements corresponding to the database, and then the SQL statements query data are executed in the corresponding database.
And S123, prompting a user to combine the data tables related to the target data storage information into the same database for data query.
When the cross-database query cannot be performed, the data query device can return a prompt message to the user to prompt the user to combine the data tables related to the target data storage information into the same database for data query, and perform data query after the user has configured the related data. Wherein the same database may be any one of a plurality of databases to which the target data storage information relates.
Of course, the data query device may also generate query failure information and return it to the user.
After the data query device performs data query, the data query result can be returned to the user, and if the user accesses the data query device through the client to perform query, the data query device can return the data query result to the client.
In the data query method provided by this embodiment, when a tag query command is received, target data storage information is determined according to the received tag query command and a pre-established tag mapping relationship, where the tag mapping relationship includes an association relationship between tag information and data storage information, and the tag query command includes target tag information to be queried; and then, data query is carried out according to the target data storage information. Due to the technical scheme provided by the embodiment of the invention, when a user inquires data, the user only needs to specify the label information to be inquired without paying attention to specific data storage information such as a database, a data table, a field and the like, so that the data inquiry system is more convenient to use, the use threshold is reduced, and the application range of data inquiry is expanded.
Based on the same inventive concept, as an implementation of the foregoing method, an embodiment of the present invention provides a data query apparatus, where an embodiment of the apparatus corresponds to the foregoing method embodiment, and for convenience of reading, details of the foregoing method embodiment are not repeated in this apparatus embodiment, but it should be clear that the apparatus in this embodiment can correspondingly implement all the contents in the foregoing method embodiment.
Fig. 4 is a schematic structural diagram of a data query apparatus according to an embodiment of the present invention, where the apparatus may be a stand-alone device or may be integrated in the data query device. As shown in fig. 4, the data query apparatus 110 provided in this embodiment includes:
a receiving module 111, configured to receive a tag query command;
a determining module 112, configured to determine target data storage information according to the tag query command received by the receiving module 111 and a pre-established tag mapping relationship, where the tag mapping relationship includes an association relationship between tag information and data storage information, and the tag query command includes target tag information to be queried;
and the query module 113 is configured to perform data query according to the target data storage information.
Wherein, the tag query command may be a TQL statement.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes: the sending module 114 and the determining module 112 are specifically configured to: target tag information is analyzed from the tag query command;
the sending module 114 is configured to: sending a request carrying target label information to a label server to indicate the label server to determine target data storage information according to the target label information and a pre-established label mapping relation, wherein the label server stores the label mapping relation;
the receiving module 111 is further configured to: and receiving target data storage information returned by the label server.
As an optional implementation manner of the embodiment of the present invention, the determining module 112 is specifically configured to:
analyzing the label query command to obtain an abstract syntax tree;
and extracting target label information from the abstract syntax tree.
As an optional implementation manner of the embodiment of the present invention, the query module 113 is specifically configured to:
analyzing the label query command, and generating a Structured Query Language (SQL) statement corresponding to a database related to the target data storage information;
and accessing the corresponding database according to the SQL statement and the data source connection information to perform data query.
As an optional implementation manner of the embodiment of the present invention, the target data storage information includes database configuration information, and the query module 113 is specifically configured to:
when the target data storage information relates to data tables in a plurality of databases, judging whether cross-database query can be performed or not based on database configuration information;
and when cross-database query can be carried out, cross-database query is carried out according to the target data storage information.
As an optional implementation manner of the embodiment of the present invention, the query module 113 is further configured to:
and when the cross-database query cannot be carried out, prompting a user to combine the data tables related to the target data storage information into the same database for carrying out data query.
As an optional implementation manner of the embodiment of the present invention, the database configuration information includes data source connection information, and the query module 113 is specifically configured to:
when the plurality of databases related to the target data storage information are all one of the first type databases, judging whether the plurality of databases are not physically and logically isolated according to the database configuration information; if yes, determining that cross-database query can be performed;
when the plurality of databases related to the target data storage information are all one of the second type databases, judging whether the data source connection information of the plurality of databases is the same; if yes, determining that cross-database query can be performed;
the first type database comprises a MySQL database and a MySQL derived database, and the second type database comprises an Open Data Processing Service (ODPS) database and an Analytical Database (ADS).
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
the first generating module 115 is configured to generate database configuration information of the database according to a database configuration operation of a user before the determining module 112 determines the target data storage information according to the received tag query command and the pre-established tag mapping relationship.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
a second generating module 116, configured to generate a tag mapping relationship according to a first tag configuration operation of a user before the determining module 112 determines target data storage information according to the received tag query command and a pre-established tag mapping relationship;
the device still includes: an updating module 117, configured to update the label mapping relationship according to the second label configuration operation of the user after the second generating module 116 generates the label mapping relationship according to the first label configuration operation of the user.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
and a returning module 118 for returning the data query result.
Wherein the return module 118 may be combined with the send module 114 into the same module.
As an optional implementation manner of the embodiment of the present invention, the receiving module 111 is specifically configured to:
and receiving a data query request carrying a tag query command through a tag query Application Program Interface (API).
As an optional implementation manner of the embodiment of the present invention, the tag information includes an entity and a tag, and the data storage information includes a data table, a database where the data table is located, and a field included in the data table; the label mapping relationship specifically includes an association relationship between an entity and a label, and an association relationship between the label and a field of a data table in a database, where the label is an attribute of the entity, each entity includes at least one label, and each label is associated with at least one data table.
Fig. 5 is a schematic structural diagram of another data query apparatus according to an embodiment of the present invention, where the apparatus may be a stand-alone device or may be integrated in a tag server. As shown in fig. 5, the data query apparatus 120 provided in this embodiment includes:
a receiving module 121, configured to receive a request carrying target tag information sent by a data query device;
a determining module 122, configured to determine target data storage information according to target tag information and a pre-established tag mapping relationship, where the tag mapping relationship includes an association relationship between the tag information and the data storage information;
and the sending module 123 is configured to return the target data storage information to the data query device.
As an optional implementation manner of the embodiment of the present invention, the data storage information includes database configuration information, and the apparatus further includes:
a first generating module 124, configured to generate database configuration information of the database according to a database configuration operation of a user before the determining module 122 determines the target data storage information according to the target tag information and a pre-established tag mapping relationship.
As an optional implementation manner of the embodiment of the present invention, the apparatus further includes:
a second generating module 125, configured to generate a tag mapping relationship according to a first tag configuration operation of a user before the determining module 122 determines target data storage information according to target tag information and a pre-established tag mapping relationship;
the device also includes: the updating module 126 is configured to update the label mapping relationship according to the second label configuration operation of the user after the second generating module 125 generates the label mapping relationship according to the first label configuration operation of the user.
The data query apparatus provided in this embodiment may perform the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Based on the same inventive concept, the embodiment of the invention also provides data query equipment. Fig. 6 is a schematic structural diagram of a data query device according to an embodiment of the present invention, and as shown in fig. 6, the data query device according to the embodiment includes: a memory 211 and a processor 212, the memory 211 being for storing computer programs; the processor 212 is adapted to perform the method according to the above-described method embodiment when the computer program is invoked.
The data query device provided in this embodiment may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
The embodiment of the invention also provides a label server. Fig. 7 is a schematic structural diagram of a tag server according to an embodiment of the present invention, and as shown in fig. 7, the tag server according to the embodiment includes: a memory 221 and a processor 222, the memory 221 being for storing computer programs; the processor 222 is adapted to perform the method according to the above-described method embodiment when the computer program is called.
The tag server provided in this embodiment may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Fig. 8 is a schematic structural diagram of the data query system provided in the embodiment of the present invention, and as shown in fig. 8, the data query system provided in the embodiment includes: the method comprises the following steps: a data query device 100 and a tag server 200.
Wherein, the tag server 200 can access a database to establish a tag mapping relationship, wherein the database 300 comprises a database which can be queried across libraries and a database which cannot be queried across libraries; the data query device 100 may access the database 300 for data queries.
In the system provided in this embodiment, the data query device 100 and the tag server 200 may execute the above method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.
Embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the method described in the above method embodiments.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied in the medium.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media may implement information storage by any method or technology, and the information may be computer-readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (22)

1. A method for querying data, comprising:
determining target data storage information according to a received tag query command and a pre-established tag mapping relation, wherein the tag mapping relation comprises an association relation between tag information and data storage information, and the tag query command comprises target tag information to be queried;
and performing data query according to the target data storage information.
2. The method of claim 1, wherein determining target data storage information according to the received tag query command and a pre-established tag mapping relationship comprises:
analyzing the target tag information from the tag query command;
sending a request carrying the target label information to a label server to indicate the label server to determine target data storage information according to the target label information and a pre-established label mapping relation, wherein the label server stores the label mapping relation;
and receiving target data storage information returned by the label server.
3. The method of claim 2, wherein the parsing the target tag information from the tag query command comprises:
analyzing the label query command to obtain an abstract syntax tree;
and extracting the target label information from the abstract syntax tree.
4. The method of claim 1, wherein the target data storage information includes data source connection information, and the performing data query according to the target data storage information includes:
analyzing the label query command to generate a Structured Query Language (SQL) statement corresponding to a database related to the target data storage information;
and accessing a corresponding database according to the SQL statement and the data source connection information to perform data query.
5. The method of claim 1, wherein the target data storage information includes database configuration information, and the querying data according to the target data storage information includes:
when the target data storage information relates to data tables in a plurality of databases, judging whether cross-database query can be performed or not based on the database configuration information;
and when cross-database query can be carried out, cross-database query is carried out according to the target data storage information.
6. The method of claim 5, further comprising:
and when the cross-database query cannot be carried out, prompting a user to combine the data tables related to the target data storage information into the same database for carrying out data query.
7. The method of claim 5, wherein the database configuration information includes data source connection information, and the determining whether cross-database querying is possible based on the target data storage information includes:
when the plurality of databases related to the target data storage information are all one of the first type databases, judging whether the plurality of databases are not physically and logically isolated according to the database configuration information; if yes, determining that cross-database query can be performed;
when the plurality of databases related to the target data storage information are all one of the second type databases, judging whether the data source connection information of the plurality of databases is the same; if yes, determining that cross-database query can be performed;
the first type database comprises a MySQL database and a MySQL derived database, and the second type database comprises an Open Data Processing Service (ODPS) database and an Analytical Database (ADS).
8. The method of claim 5, wherein prior to said determining target data storage information from the received tag query command and the pre-established tag mapping relationship, the method further comprises:
and generating database configuration information of the database according to the database configuration operation of the user.
9. The method of claim 1, wherein prior to determining target data storage information based on the received tag query command and the pre-established tag mapping relationship, the method further comprises:
generating the label mapping relation according to a first label configuration operation of a user;
after the generating the tag mapping relationship according to the first tag configuration operation of the user, the method further includes:
and updating the label mapping relation according to the second label configuration operation of the user.
10. The method of claim 1, wherein prior to determining target data storage information based on the received tag query command and the pre-established tag mapping relationship, the method further comprises:
receiving a data query request carrying the tag query command;
after the querying data according to the target data storage information, the method further comprises:
and returning a data query result.
11. The method of claim 10, wherein receiving the data query request carrying the tag query command comprises:
and receiving a data query request carrying the tag query command through a tag query Application Program Interface (API).
12. The method as claimed in claim 1, wherein the tag query command is a tag query language TQL statement.
13. The method according to any one of claims 1 to 12, wherein the tag information comprises an entity and a tag, and the data storage information comprises a data table, a database where the data table is located, and fields contained in the data table; the label mapping relationship specifically includes an association relationship between an entity and a label, and an association relationship between a label and a field of a data table in a database, where the label is an attribute of the entity, each entity includes at least one label, and each label is associated with at least one data table.
14. A method for querying data, comprising:
receiving a request which is sent by data query equipment and carries the target label information;
determining target data storage information according to the target label information and a pre-established label mapping relation, wherein the label mapping relation comprises an incidence relation between the label information and the data storage information;
and returning the target data storage information to the data query equipment.
15. The method of claim 14, wherein the data storage information includes database configuration information, and before determining the target data storage information according to the target tag information and a pre-established tag mapping relationship, the method further comprises:
and generating database configuration information of the database according to the database configuration operation of the user.
16. The method of claim 14 or 15, wherein prior to said determining target data storage information from said target tag information and a pre-established tag mapping relationship, the method further comprises:
generating the label mapping relation according to a first label configuration operation of a user;
after the generating the tag mapping relationship according to the first tag configuration operation of the user, the method further includes:
and updating the label mapping relation according to the second label configuration operation of the user.
17. A data query apparatus, comprising:
the receiving module is used for receiving a label inquiry command;
the determining module is used for determining target data storage information according to the tag query command received by the receiving module and a pre-established tag mapping relation, wherein the tag mapping relation comprises an incidence relation between tag information and data storage information, and the tag query command comprises target tag information to be queried;
and the query module is used for carrying out data query according to the target data storage information.
18. A data query apparatus, comprising:
the receiving module is used for receiving a request which is sent by data query equipment and carries the target label information;
the determining module is used for determining target data storage information according to the target label information and a pre-established label mapping relation, wherein the label mapping relation comprises an incidence relation between the label information and the data storage information;
and the sending module is used for returning the target data storage information to the data query equipment.
19. A data query device, comprising: a memory for storing a computer program and a processor; the processor is adapted to perform the method of any of claims 1-13 when the computer program is invoked.
20. A tag server, comprising: a memory for storing a computer program and a processor; the processor is adapted to perform the method of any of claims 14-16 when the computer program is invoked.
21. A data query system, comprising: a data query device as claimed in claim 19 and a tag server as claimed in claim 20.
22. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-16.
CN201910461541.7A 2019-05-30 2019-05-30 Data query method, device and system Pending CN112015754A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910461541.7A CN112015754A (en) 2019-05-30 2019-05-30 Data query method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910461541.7A CN112015754A (en) 2019-05-30 2019-05-30 Data query method, device and system

Publications (1)

Publication Number Publication Date
CN112015754A true CN112015754A (en) 2020-12-01

Family

ID=73501860

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910461541.7A Pending CN112015754A (en) 2019-05-30 2019-05-30 Data query method, device and system

Country Status (1)

Country Link
CN (1) CN112015754A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527917A (en) * 2020-12-04 2021-03-19 广州橙行智动汽车科技有限公司 Data processing method and device
CN112860696A (en) * 2021-02-07 2021-05-28 中国邮政储蓄银行股份有限公司 Data query method and device and data query model
CN113343072A (en) * 2021-05-07 2021-09-03 深圳市酷开网络科技股份有限公司 Label query method, device, equipment and storage medium
CN114116866A (en) * 2021-11-22 2022-03-01 广州新科佳都科技有限公司 Data acquisition method and device, terminal equipment and storage medium

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112527917A (en) * 2020-12-04 2021-03-19 广州橙行智动汽车科技有限公司 Data processing method and device
CN112860696A (en) * 2021-02-07 2021-05-28 中国邮政储蓄银行股份有限公司 Data query method and device and data query model
CN112860696B (en) * 2021-02-07 2024-04-12 中国邮政储蓄银行股份有限公司 Data query method and device and data query model
CN113343072A (en) * 2021-05-07 2021-09-03 深圳市酷开网络科技股份有限公司 Label query method, device, equipment and storage medium
CN114116866A (en) * 2021-11-22 2022-03-01 广州新科佳都科技有限公司 Data acquisition method and device, terminal equipment and storage medium

Similar Documents

Publication Publication Date Title
CN107239479B (en) Block chain based data storage and query method and device
US10042931B2 (en) Data query method and apparatus
US11907247B2 (en) Metadata hub for metadata models of database objects
CN112015754A (en) Data query method, device and system
US9280568B2 (en) Zero downtime schema evolution
US10552416B2 (en) Processing SQL statement in alternating modes
US10120916B2 (en) In-querying data cleansing with semantic standardization
CN109492053B (en) Method and device for accessing data
US20210209098A1 (en) Converting database language statements between dialects
US20220067024A1 (en) Facilitating performance of database operations using microservices
CN107103011B (en) Method and device for realizing terminal data search
US10353723B2 (en) PL/SQL language parsing at a virtual machine
CN105164673A (en) Query integration across databases and file systems
US10360232B2 (en) Semantic mapping of data from an entity-relationship model to a graph-based data format to facilitate simplified querying
CN110046170A (en) Sentence based on multifile management executes method, apparatus, equipment and medium
US11561976B1 (en) System and method for facilitating metadata identification and import
US20230091845A1 (en) Centralized metadata repository with relevancy identifiers
CN114116767A (en) Method and device for converting SQL (structured query language) query statement of database
CN109063061B (en) Cross-distributed system data processing method, device, equipment and storage medium
CN112541001A (en) Data query method, device, storage medium and equipment
US10157206B2 (en) Data retrieval across multiple models
US11205049B2 (en) Method for managing semantic information on M2M/IoT platform
CN106407345B (en) Dirty data updating method and device
US11645283B2 (en) Predictive query processing
US10037349B2 (en) Optimization of an in memory data grid (IMDG) schema based upon a No-SQL document model

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