CN112416962A - Data query method, device and storage medium - Google Patents

Data query method, device and storage medium Download PDF

Info

Publication number
CN112416962A
CN112416962A CN202011231922.5A CN202011231922A CN112416962A CN 112416962 A CN112416962 A CN 112416962A CN 202011231922 A CN202011231922 A CN 202011231922A CN 112416962 A CN112416962 A CN 112416962A
Authority
CN
China
Prior art keywords
query statement
query
data
graph
grammar
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
CN202011231922.5A
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.)
Beijing Even Number Technology Co ltd
Original Assignee
Beijing Even Number 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 Beijing Even Number Technology Co ltd filed Critical Beijing Even Number Technology Co ltd
Priority to CN202011231922.5A priority Critical patent/CN112416962A/en
Publication of CN112416962A publication Critical patent/CN112416962A/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/242Query formulation
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/901Indexing; Data structures therefor; Storage structures
    • G06F16/9024Graphs; Linked lists
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/9032Query formulation

Landscapes

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

Abstract

The application discloses a data query method, a data query device and a storage medium, wherein the method comprises the following steps: receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and performing query operation in the target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.

Description

Data query method, device and storage medium
Technical Field
The present application relates to the field of graph database technologies, and in particular, to a data query method, device, and storage medium.
Background
Currently, the query languages of graph database management systems and database management systems are two different sets of languages. The former generally adopts graph data Query languages such as Cypher, Gremlin, GSQL, etc., while the latter generally adopts relational data Query languages such as SQL (structured Query language), etc. The use of different languages for the graph database management system and the database management system makes it difficult for a user to query the graph data and the relationship data simultaneously. Especially for application scenarios with a union of both graph data and relational data.
In view of the above technical problem in the prior art that it is difficult to query a database including both graph data and relationship data simultaneously, no effective solution has been proposed at present.
Disclosure of Invention
Embodiments of the present disclosure provide a data query method, apparatus and storage medium, so as to solve at least the data query method, apparatus and storage medium existing in the prior art.
According to an aspect of an embodiment of the present disclosure, there is provided a data query method including: receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and performing query operation in the target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
According to another aspect of the embodiments of the present disclosure, there is also provided a storage medium including a stored program, wherein the method of any one of the above is performed by a processor when the program is executed.
According to another aspect of the embodiments of the present disclosure, there is also provided a data query apparatus including: the system comprises a first receiving module, a second receiving module and a third receiving module, wherein the first receiving module is used for receiving a first query statement input by a user, and the first query statement consists of a graph database grammar and a relational database grammar; and the first query module is used for performing query operation in the target database according to the first query statement and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
According to another aspect of the embodiments of the present disclosure, there is also provided a data query apparatus including: a processor; and a memory coupled to the processor for providing instructions to the processor for processing the following processing steps: receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and performing query operation in the target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
In the embodiment of the present disclosure, since the first query expression is composed of the graph database syntax and the relational database syntax, the database storing the relational data and the graph data can be queried for corresponding data information according to the first query expression. Compared with the prior art, the query language combines the grammars of the graph data and the relational data, so that the purpose of simultaneously considering the query of the graph data and the relational data is realized, the technical effect of improving the access capability is achieved, and the query language can be applied to various application scenes of fusion of the graph data and the relational data. The technical problem that simultaneous query of the graph data and the relation data is difficult to perform on a database which comprises both the graph data and the relation data in the prior art is further solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the disclosure and together with the description serve to explain the disclosure and not to limit the disclosure. In the drawings:
fig. 1 is a hardware block diagram of a computing device for implementing the method according to embodiment 1 of the present disclosure;
fig. 2 is a schematic flow chart of a data query method according to embodiment 1 of the present disclosure;
fig. 3 is a schematic diagram schematically illustrating the structure of graph data according to embodiment 1 of the present disclosure;
FIG. 4 is a schematic diagram of a parsing module according to embodiment 1 of the disclosure;
FIG. 5 is a schematic overall flow chart of data query according to embodiment 1 of the present disclosure;
fig. 6a is a schematic diagram of a structure of a syntax tree according to embodiment 1 of the present disclosure;
FIG. 6b is a diagram of a structure of a query tree according to embodiment 1 of the present disclosure;
fig. 7 is a schematic diagram of a data query device according to embodiment 2 of the present disclosure; and
fig. 8 is a schematic diagram of a data query device according to embodiment 3 of the present disclosure.
Detailed Description
In order to make those skilled in the art better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure. It is to be understood that the described embodiments are merely exemplary of some, and not all, of the present disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Example 1
According to the present embodiment, a data query method embodiment is provided, it should be noted that the steps shown in the flowchart of the figure may be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that here.
The method embodiments provided by the present embodiment may be executed in a server or similar computing device. Fig. 1 shows a hardware configuration block diagram of a computing device for implementing the data query method. As shown in fig. 1, the computing device may include one or more processors (which may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory for storing data, and a transmission device for communication functions. Besides, the method can also comprise the following steps: a display, an input/output interface (I/O interface), a Universal Serial Bus (USB) port (which may be included as one of the ports of the I/O interface), a network interface, a power source, and/or a camera. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the electronic device. For example, the computing device may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
It should be noted that the one or more processors and/or other data processing circuitry described above may be referred to generally herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part in software, hardware, firmware, or any combination thereof. Further, the data processing circuitry may be a single, stand-alone processing module, or incorporated in whole or in part into any of the other elements in the computing device. As referred to in the disclosed embodiments, the data processing circuit acts as a processor control (e.g., selection of a variable resistance termination path connected to the interface).
The memory may be used to store software programs and modules of application software, such as program instructions/data storage devices corresponding to the data query method in the embodiments of the present disclosure, and the processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, implementing the data query method of the application program. The memory may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory located remotely from the processor, which may be connected to the computing device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device is used for receiving or transmitting data via a network. Specific examples of such networks may include wireless networks provided by communication providers of the computing devices. In one example, the transmission device includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device may be a Radio Frequency (RF) module, which is used for communicating with the internet in a wireless manner.
The display may be, for example, a touch screen type Liquid Crystal Display (LCD) that may enable a user to interact with a user interface of the computing device.
It should be noted here that in some alternative embodiments, the computing device shown in fig. 1 described above may include hardware elements (including circuitry), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. It should be noted that FIG. 1 is only one example of a particular specific example and is intended to illustrate the types of components that may be present in a computing device as described above.
In the operating environment described above, according to the first aspect of the present embodiment, a data query method is provided, which can be executed, for example, in a server applied to a database system including both graph data and relationship data. Fig. 2 shows a flow diagram of the method, which, with reference to fig. 2, comprises:
s202: receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and
s204: and performing query operation in the target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
As described in the background, the query languages for both the graph database management system and the database management system are currently two different sets of languages. The former generally adopts graph data Query languages such as Cypher, Gremlin, GSQL, etc., while the latter generally adopts relational data Query languages such as SQL (structured Query language), etc. The use of different languages for the graph database management system and the database management system makes it difficult for a user to query the graph data and the relationship data simultaneously. Especially for application scenarios with a union of both graph data and relational data.
In order to solve the technical problem in the prior art, in step S202, in the technical solution of the present embodiment, a server of a database first receives a first query statement input by a user, where the first query statement is composed of a graph database syntax and a relational database syntax. For example, the user may input the first query statement through a client provided by the system, in which case the server may receive the first query statement. Wherein the first query statement is composed of a graph database syntax (e.g., syntax of Cypher, Gremlin, GSQL) and a relational database syntax (e.g., SQL syntax). In one embodiment, the first query statement combines the syntax of SELECT and CREATE in the SQL statement with the syntax of MATCH, CONSTRUCT, and the like in the graph database statement, for example, the form of the first query statement is as follows:
SELECT n FROM MATCH (n) ON g; (represents reading all attributes of vertex n in graph g that satisfy the condition);
SELECT n FROM MATCH (n) - [ e ] - > (m) on g; (represents all attributes of the starting point n of the path e satisfying the condition in the reading graph g);
in addition, the first query statement may also be a statement to create a graph from a graph, such as:
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) ON f; (all vertices construction diagram g of the diagram f is shown)
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) - [ e ] - > (m) ON f; (all edges of graph f are shown to construct graph g).
Referring to the first query statement (e.g., SELECT n. FROM MATCH (n) ON g), the first query statement may be constructed by first searching for a vertex in the graph g through the graph database statement mthch, and then searching for an attribute through the SELECT syntax of the relational database, so as to finally read all the attributes of the vertex n satisfying the condition in the graph g.
The syntax construction method of the first query statement (GQL) is a method for expanding graph data access on the basis of SQL. More recently, a context-free grammar of the Backus Normal Form (BNF) was used. The Backowsian form of the specific construction is as follows:
Figure BDA0002765507020000061
Figure BDA0002765507020000071
Figure BDA0002765507020000081
Figure BDA0002765507020000091
Figure BDA0002765507020000101
Figure BDA0002765507020000111
then, in step S204, the server performs a query operation in the target database according to the first query statement, and returns data information corresponding to the first query statement. That is, corresponding data is returned according to the first query statement, for example: the first query statement is SELECT n, FROM MATCH (n) ON g, and all the attributes of vertex n in graph g that satisfy the condition are returned. In a specific example, fig. 3 exemplarily shows one graph data, and the corresponding relationship data related to the graph data includes attributes such as "person", "name", "weight", "age", and "six", and the relationship data and the graph data are both stored in the target database. The server may query in the target database according to the first query statement.
Thus, in this manner, since the first query expression is composed of the graph database syntax and the relational database syntax, it is possible to query the database storing the relational data and the graph data for the corresponding data information based on the first query expression. Compared with the prior art, the query language combines the grammars of the graph data and the relational data, so that the purpose of simultaneously considering the query of the graph data and the relational data is realized, the technical effect of improving the access capability is achieved, and the query language can be applied to various application scenes of fusion of the graph data and the relational data. The technical problem that simultaneous query of the graph data and the relation data is difficult to perform on a database which comprises both the graph data and the relation data in the prior art is further solved.
Optionally, before performing a query operation in the target database according to the first query statement, the method further includes: and analyzing the first query statement to judge whether the grammar of the first query statement is accurate.
Specifically, before performing a query operation in the target database according to the first query statement, the server further needs to analyze the first query statement to determine whether the syntax of the first query statement is accurate. The query operation is performed only when the first query statement is judged to be correct, so that the data access can be safely and reliably performed.
Optionally, analyzing the first query statement to determine whether the syntax of the first query statement is accurate includes: performing lexical analysis on the first query statement to determine a word sequence contained in the first query statement; and carrying out syntactic analysis on the word sequence to generate a syntactic tree, and judging whether the grammar of the first query sentence is accurate.
Specifically, referring to fig. 4, in the process of analyzing the first query sentence (corresponding to GQL in fig. 4), the first query sentence may be firstly lexically analyzed to obtain a group of word sequences. Referring to fig. 5, the system may be configured to perform lexical analysis on the first query statement by using a lexical parser 100, for example, the lexical parser 100 may be a lexical analysis tool Flex, and during the analysis, a left-to-right direction is used, and the tokens are obtained by using a regular expression segmentation-by-segmentation algorithm, and may be classified into the following categories: (1) annotating; (2) a keyword; (3) an operator; (4) opening and closing the mark; (5) a placeholder; (6) a blank space; (7) and the text, the number, the field and other constants of the quotation mark package. In one embodiment, the first query statement is, for example, "SELECT n. FROM MATCH (n) ON g", and the following word sequence can be obtained according to the matching rule FROM left to right: SELECT, n., FROM, MATCH, (, n,), ON, g.
Further, the server parses the word sequence and generates a syntax tree (fig. 6a exemplarily shows a structural schematic diagram of the syntax tree), and referring to fig. 5, for example, the parser 200 may be configured to parse the word sequence to determine whether it is grammatically correct. The syntax parsing method adopted by the syntax parser 200 is, for example, LALR (1), which is a bottom-up parsing algorithm, and finally outputs a syntax tree, and then determines whether the syntax of the first query statement is accurate. In addition, other lexical analysis methods and syntax analysis methods in the prior art may be adopted, and are not specifically limited herein. Therefore, lexical analysis and syntactic analysis can be performed on the first query statement, and the fact that the lexical analysis and the syntactic analysis of the first query statement are correct is guaranteed.
Optionally, the present solution further includes: and performing semantic analysis on the syntax tree, and judging whether the semantics of the first query statement are correct or not.
Specifically, referring to fig. 5, the system is further provided with a semantic analyzer 300 for semantic analysis. Referring to fig. 4, after parsing, a syntax tree is obtained. Furthermore, semantic analysis can be carried out on the obtained syntax tree to judge whether the syntax tree is semantically legal or not. The principle of semantic analysis is to construct a reduced grammar from the target grammar and then represent the generated target as a query tree based on the grammar, thereby implementing a top-down query tree generation process, the output query tree of this step is shown in fig. 6 b. Therefore, semantic analysis can be performed on the first query statement, and semantic accuracy can be guaranteed.
Optionally, the present solution further includes: receiving a second query statement input by a user, wherein the second query statement is a graph database query statement or a relational database query statement; analyzing the second query statement and judging whether the grammar of the second query statement is accurate; and returning data information corresponding to the second query statement from the target database under the condition that the grammar of the second query statement is accurate.
The technical scheme of the embodiment can query the first query statement composed of the graph database grammar and the relational database grammar, and can also perform graph data query or relational data query. In particular, the server may receive a second query statement, where the second query statement may be a graph database query statement or a relational database query statement. In one embodiment, the second query statement is, for example: CONSTRUCT (n) MATCH (n) ON g; (representing all vertices found in graph g), CONSTRUCT (n) MATCH (n) e- > (m) on g; (representing looking up all edges in graph g), etc.
Further, the server analyzes the second query statement and judges whether the grammar of the second query statement is accurate. The analysis process may refer to the analysis process of the first query statement, which is not described herein again. Finally, in the case where the syntax of the second query statement is accurate, data information corresponding to the second query statement is returned from the target database. Therefore, the method and the device can not only query the first query statement composed of the database grammar and the relational database grammar, but also query a single graph data statement or a relational database statement, and therefore different requirements can be met.
Optionally, the present solution further comprises creating the target database according to the following steps: receiving a creation request, wherein the creation request comprises graph data structure information and relational data structure information related to attributes contained in the graph data structure; and creating a target database according to the graph data structure information and the relational data structure information in response to the creation request.
Specifically, the implementation of the technical solution of the present embodiment is performed in the target database storing the graph data and the relationship data related to the graph data. Thus, the present solution also includes building the target database. Specifically, a creation request is first received, where the creation request includes graph data structure information and relational data structure information related to attributes contained in the graph data structure. For example: referring to fig. 3, the relationship between vertices and edges in the graph corresponds to graph data structure information, and attributes such as "person", "name", "weight", "age", and "six" are relational data structure information. Then, in response to the creation request, the target database is created based on the graph data structure information and the relational data structure information. Thus, a target database storing graph data and relationship data related to the graph data can be created according to the requirements of users.
In traditional relational databases, data can only be returned in a relational manner. Such as SQL language, etc., which cannot process the data of the graph. Such as:
SELECT FROM t; (indicating that all data are read from Table t)
In graph databases, data can only be returned in graph form (e.g. Cypher, Gremlin language, etc.):
MATCH (p: type) RETURN p; (indicating returning all types as type vertex)
MATCH () - [ e: type ] - > () RETURN e; (indicating the Return of all types of type sides)
The technical solution of this embodiment provides a new query statement (corresponding to GQL in fig. 4), which can be returned in a relational manner or in a graph manner according to different data types, for example:
1) statement returned by relationship:
SELECT n FROM MATCH (n) ON g; (representing all attributes of vertices n of the reading graph g that satisfy the condition)
SELECT n FROM MATCH (n) - [ e ] - > (m) on g; (all attributes representing the starting point n of the path e satisfying the condition in the reading graph g)
2) Statement returned as per the figure:
CONSTRUCT (n) MATCH (n) ON g; (indicating all vertices in the lookup graph g)
CONSTRUCT (n) MATCH (n) - [ e ] - > (m) on g; (indicating all edges in the lookup graph g)
3) Create a statement of a graph from a graph:
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) ON f; (all vertices are shown by f. construction drawing g)
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) - [ e ] - > (m) ON f; (all edge construction graph g with f)
After the relational query language and the graph query language are organically combined through the GQL, the data of the relational and graph modes can be processed in the same database.
In a specific implementation, referring to fig. 4, the query process is as follows:
s1: the user enters a sentence of GQL.
For example:
1) statement returned by relationship:
SELECT n FROM MATCH (n) ON g; (representing all attributes of vertices n of the reading graph g that satisfy the condition)
SELECT n FROM MATCH (n) - [ e ] - > (m) on g; (all attributes representing the starting point n of the path e satisfying the condition in the reading graph g)
2) Statement returned as per the figure:
CONSTRUCT (n) MATCH (n) ON g; (indicating all vertices in the lookup graph g)
CONSTRUCT (n) MATCH (n) - [ e ] - > (m) on g; (indicating all edges in the lookup graph g)
3) Create a statement of a graph from a graph:
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) ON f; (all vertices are shown by f. construction drawing g)
CREATE GRAPH g AS CONSTRUCT (n) MATCH (n) - [ e ] - > (m) ON f; (all edge construction graph g with f)
And S2, performing lexical analysis on the GQL sentences to obtain a group of marks (Token). Here, the token is obtained by a regular expression segmentation-by-segmentation algorithm in the left-to-right direction by means of a lexical analysis tool Flex. These markers can be classified into the following categories: (1) annotating; (2) a keyword; (3) an operator; (4) opening and closing the mark; (5) a placeholder; (6) a blank space; (7) and the text, the number, the field and other constants of the quotation mark package. For example, for SELECT n, FROM MATCH (n) ON g, the following labels can be obtained according to the matching rule FROM left to right: SELECT, n., FROM, MATCH, (, n,), ON, g.
The resulting set of tokens is parsed to determine if it is syntactically correct, S3. The syntax analysis method used in this step is LALR (1), which is a bottom-up analysis algorithm, and finally outputs a syntax tree (see fig. 6 a).
And S4, performing semantic analysis on the obtained syntax tree to judge whether the syntax tree is semantically legal or not. The principle of the method is that a reduction grammar is constructed according to target grammar, and then a generated target is expressed as a query tree based on the grammar, so that the top-down query tree generation process is realized. The query tree output by this step is shown in FIG. 6 b.
Therefore, the MATCH and CONSTRUCT statements of the graph model are added on the basis of the relational schema to CONSTRUCT the graph query, thereby providing the query capability in the graph schema. Therefore, the graph query language of the GQL can simultaneously realize the query of graph data and relationship data; thereby providing efficient and secure data access capabilities; furthermore, the user friendliness and ease of use for a large number of SQL users also makes the language easily applicable to a wide variety of practical scenarios.
Further, referring to fig. 1, according to a second aspect of the present embodiment, there is provided a storage medium. The storage medium comprises a stored program, wherein the method of any of the above is performed by a processor when the program is run.
Thus, according to the present embodiment, since the first query expression is composed of the graph database syntax and the relational database syntax, it is possible to query the database storing the relational data and the graph data for the corresponding data information according to the first query expression. Compared with the prior art, the query language combines the grammars of the graph data and the relational data, so that the purpose of simultaneously considering the query of the graph data and the relational data is realized, the technical effect of improving the access capability is achieved, and the query language can be applied to various application scenes of fusion of the graph data and the relational data. The technical problem that simultaneous query of the graph data and the relation data is difficult to perform on a database which comprises both the graph data and the relation data in the prior art is further solved.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Example 2
Fig. 7 shows a data querying device 700 according to the present embodiment, the device 700 corresponding to the method according to the first aspect of embodiment 1. Referring to fig. 7, the apparatus 700 includes: a first receiving module 710, configured to receive a first query statement input by a user, where the first query statement is composed of a graph database syntax and a relational database syntax; and a first query module 720, configured to perform a query operation in the target database according to the first query statement, and return data information corresponding to the first query statement, where the target database stores graph data and relationship data related to the graph data.
Optionally, the apparatus 700 further comprises: and the analysis module is used for analyzing the first query statement before query operation is carried out in the target database according to the first query statement and judging whether the grammar of the first query statement is accurate.
Optionally, an analysis module comprising: the lexical analysis sub-module is used for carrying out lexical analysis on the first query sentence and determining a word sequence contained in the first query sentence; and the syntax analysis submodule is used for carrying out syntax analysis on the word sequence and generating a syntax tree and judging whether the syntax of the first query sentence is accurate or not.
Optionally, the apparatus 700 further comprises: and the semantic analysis submodule is used for performing semantic analysis on the syntax tree and judging whether the semantics of the first query statement are correct or not.
Optionally, the apparatus 700 further comprises: the second receiving module is used for receiving a second query statement input by a user, wherein the second query statement is a graph database query statement or a relational database query statement; the judging module is used for analyzing the second query statement and judging whether the grammar of the second query statement is accurate or not; and the second query module is used for returning the data information corresponding to the second query statement from the target database under the condition that the grammar of the second query statement is accurate.
Optionally, the apparatus 700 further comprises: a database creation module for creating a target database according to the steps of: receiving a creation request, wherein the creation request comprises graph data structure information and relational data structure information related to attributes contained in the graph data structure; and creating a target database according to the graph data structure information and the relational data structure information in response to the creation request.
Thus, according to the present embodiment, since the first query expression is composed of the graph database syntax and the relational database syntax, it is possible to query the database storing the relational data and the graph data for the corresponding data information according to the first query expression. Compared with the prior art, the query language combines the grammars of the graph data and the relational data, so that the purpose of simultaneously considering the query of the graph data and the relational data is realized, the technical effect of improving the access capability is achieved, and the query language can be applied to various application scenes of fusion of the graph data and the relational data. The technical problem that simultaneous query of the graph data and the relation data is difficult to perform on a database which comprises both the graph data and the relation data in the prior art is further solved.
Example 3
Fig. 8 shows a data querying device 800 according to the present embodiment, the device 800 corresponding to the method according to the first aspect of embodiment 1. Referring to fig. 8, the apparatus 800 includes: a processor 810; and a memory 820 coupled to the processor 810 for providing instructions to the processor 810 to process the following process steps: receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and performing query operation in the target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
Optionally, the memory 820 is further configured to provide the processor 810 with instructions for processing the following processing steps: before query operation is carried out in the target database according to the first query statement, the first query statement is analyzed, and whether the grammar of the first query statement is accurate or not is judged.
Optionally, analyzing the first query statement to determine whether the syntax of the first query statement is accurate includes: performing lexical analysis on the first query statement to determine a word sequence contained in the first query statement; and carrying out syntactic analysis on the word sequence to generate a syntactic tree, and judging whether the grammar of the first query sentence is accurate.
Optionally, the memory 820 is further configured to provide the processor 810 with instructions for processing the following processing steps: and performing semantic analysis on the syntax tree, and judging whether the semantics of the first query statement are correct or not.
Optionally, the memory 820 is further configured to provide the processor 810 with instructions for processing the following processing steps: receiving a second query statement input by a user, wherein the second query statement is a graph database query statement or a relational database query statement; analyzing the second query statement and judging whether the grammar of the second query statement is accurate; and returning data information corresponding to the second query statement from the target database under the condition that the grammar of the second query statement is accurate.
Optionally, the memory 820 is further configured to provide the processor 810 with instructions for the process steps of creating a target database according to the following steps: receiving a creation request, wherein the creation request comprises graph data structure information and relational data structure information related to attributes contained in the graph data structure; and creating a target database according to the graph data structure information and the relational data structure information in response to the creation request.
Thus, according to the present embodiment, since the first query expression is composed of the graph database syntax and the relational database syntax, it is possible to query the database storing the relational data and the graph data for the corresponding data information according to the first query expression. Compared with the prior art, the query language combines the grammars of the graph data and the relational data, so that the purpose of simultaneously considering the query of the graph data and the relational data is realized, the technical effect of improving the access capability is achieved, and the query language can be applied to various application scenes of fusion of the graph data and the relational data. The technical problem that simultaneous query of the graph data and the relation data is difficult to perform on a database which comprises both the graph data and the relation data in the prior art is further solved.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units 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, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A method for querying data, comprising:
receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and
and performing query operation in a target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
2. The method of claim 1, further comprising, prior to performing a query operation in a target database in accordance with the first query statement:
and analyzing the first query statement, and judging whether the grammar of the first query statement is accurate.
3. The method of claim 2, wherein analyzing the first query statement to determine whether the syntax of the first query statement is accurate comprises:
performing lexical analysis on the first query statement to determine a word sequence contained in the first query statement; and
and carrying out syntactic analysis on the word sequence to generate a syntactic tree, and judging whether the grammar of the first query sentence is accurate.
4. The method of claim 3, further comprising: and performing semantic analysis on the syntax tree, and judging whether the semantics of the first query statement are correct or not.
5. The method of claim 1, further comprising:
receiving a second query statement input by the user, wherein the second query statement is a graph database query statement or a relational database query statement;
analyzing the second query statement and judging whether the grammar of the second query statement is accurate; and
and returning data information corresponding to the second query statement from the target database under the condition that the grammar of the second query statement is accurate.
6. The method of claim 1, further comprising creating the target database according to the steps of:
receiving a creation request, wherein the creation request comprises graph data structure information and relational data structure information related to attributes contained in the graph data structure; and
in response to the creation request, creating the target database from the graph data structure information and the relational data structure information.
7. A storage medium comprising a stored program, wherein the method of any one of claims 1 to 6 is performed by a processor when the program is run.
8. A data query apparatus, comprising:
the system comprises a first receiving module, a second receiving module and a third receiving module, wherein the first receiving module is used for receiving a first query statement input by a user, and the first query statement consists of a graph database grammar and a relational database grammar; and
and the first query module is used for performing query operation in a target database according to the first query statement and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
9. The apparatus of claim 8, further comprising:
and the analysis module is used for analyzing the first query statement before query operation is carried out in a target database according to the first query statement and judging whether the grammar of the first query statement is accurate or not.
10. A data query apparatus, comprising:
a processor; and
a memory coupled to the processor for providing instructions to the processor for processing the following processing steps:
receiving a first query statement input by a user, wherein the first query statement consists of a graph database grammar and a relational database grammar; and
and performing query operation in a target database according to the first query statement, and returning data information corresponding to the first query statement, wherein the target database stores graph data and relational data related to the graph data.
CN202011231922.5A 2020-11-06 2020-11-06 Data query method, device and storage medium Pending CN112416962A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011231922.5A CN112416962A (en) 2020-11-06 2020-11-06 Data query method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011231922.5A CN112416962A (en) 2020-11-06 2020-11-06 Data query method, device and storage medium

Publications (1)

Publication Number Publication Date
CN112416962A true CN112416962A (en) 2021-02-26

Family

ID=74782059

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011231922.5A Pending CN112416962A (en) 2020-11-06 2020-11-06 Data query method, device and storage medium

Country Status (1)

Country Link
CN (1) CN112416962A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112800285A (en) * 2021-02-03 2021-05-14 京东数字科技控股股份有限公司 Data query method, equipment, storage medium and product based on graph database
CN112988822A (en) * 2021-03-04 2021-06-18 京东数字科技控股股份有限公司 Data query method, device, equipment, readable storage medium and product
CN113051362A (en) * 2021-03-18 2021-06-29 中国工商银行股份有限公司 Data query method and device and server
CN113220710A (en) * 2021-05-11 2021-08-06 北京百度网讯科技有限公司 Data query method and device, electronic equipment and storage medium
CN113609100A (en) * 2021-08-02 2021-11-05 北京百度网讯科技有限公司 Data storage method, data query method, data storage device, data query device and electronic equipment
CN115269561A (en) * 2022-09-21 2022-11-01 国网智能电网研究院有限公司 Hybrid database management method and device, hybrid database and electronic equipment

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123369A (en) * 2014-07-24 2014-10-29 中国移动通信集团广东有限公司 CMDB system based on graphic data base and implementation method
CN105868249A (en) * 2015-12-15 2016-08-17 乐视网信息技术(北京)股份有限公司 Data query control method and device
US20180067987A1 (en) * 2016-09-07 2018-03-08 Bitnine Co., Ltd. Database capable of integrated query processing and data processing method thereof
CN109241080A (en) * 2018-09-29 2019-01-18 焦点科技股份有限公司 A kind of the building application method and its system of FQL query language
US20190095395A1 (en) * 2016-04-26 2019-03-28 DataWalk Spólka Akcyjna Systems and methods for querying databases
CN109753537A (en) * 2019-01-25 2019-05-14 中国人民大学 A kind of interactive data moving method from relation data to diagram data
CN111708805A (en) * 2020-06-18 2020-09-25 腾讯科技(深圳)有限公司 Data query method and device, electronic equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104123369A (en) * 2014-07-24 2014-10-29 中国移动通信集团广东有限公司 CMDB system based on graphic data base and implementation method
CN105868249A (en) * 2015-12-15 2016-08-17 乐视网信息技术(北京)股份有限公司 Data query control method and device
US20190095395A1 (en) * 2016-04-26 2019-03-28 DataWalk Spólka Akcyjna Systems and methods for querying databases
US20180067987A1 (en) * 2016-09-07 2018-03-08 Bitnine Co., Ltd. Database capable of integrated query processing and data processing method thereof
CN109241080A (en) * 2018-09-29 2019-01-18 焦点科技股份有限公司 A kind of the building application method and its system of FQL query language
CN109753537A (en) * 2019-01-25 2019-05-14 中国人民大学 A kind of interactive data moving method from relation data to diagram data
CN111708805A (en) * 2020-06-18 2020-09-25 腾讯科技(深圳)有限公司 Data query method and device, electronic equipment and storage medium

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112800285A (en) * 2021-02-03 2021-05-14 京东数字科技控股股份有限公司 Data query method, equipment, storage medium and product based on graph database
CN112988822A (en) * 2021-03-04 2021-06-18 京东数字科技控股股份有限公司 Data query method, device, equipment, readable storage medium and product
CN112988822B (en) * 2021-03-04 2024-07-16 京东科技控股股份有限公司 Data query method, device, equipment, readable storage medium and product
CN113051362A (en) * 2021-03-18 2021-06-29 中国工商银行股份有限公司 Data query method and device and server
CN113051362B (en) * 2021-03-18 2024-03-22 中国工商银行股份有限公司 Data query method, device and server
CN113220710A (en) * 2021-05-11 2021-08-06 北京百度网讯科技有限公司 Data query method and device, electronic equipment and storage medium
CN113220710B (en) * 2021-05-11 2024-06-04 北京百度网讯科技有限公司 Data query method, device, electronic equipment and storage medium
CN113609100A (en) * 2021-08-02 2021-11-05 北京百度网讯科技有限公司 Data storage method, data query method, data storage device, data query device and electronic equipment
CN113609100B (en) * 2021-08-02 2023-10-27 北京百度网讯科技有限公司 Data storage method, data query device and electronic equipment
CN115269561A (en) * 2022-09-21 2022-11-01 国网智能电网研究院有限公司 Hybrid database management method and device, hybrid database and electronic equipment
CN115269561B (en) * 2022-09-21 2023-01-24 国网智能电网研究院有限公司 Hybrid database management method and device, hybrid database and electronic equipment

Similar Documents

Publication Publication Date Title
CN112416962A (en) Data query method, device and storage medium
CN107451153B (en) Method and device for outputting structured query statement
US9448995B2 (en) Method and device for performing natural language searches
US11514034B2 (en) Conversion of natural language query
CN109522341B (en) Method, device and equipment for realizing SQL-based streaming data processing engine
CN109241080B (en) Construction and use method and system of FQL query language
CN108563629B (en) Automatic log analysis rule generation method and device
CN111949800A (en) Method and system for establishing knowledge graph of open source project
CN110263121B (en) Table data processing method, apparatus, electronic apparatus and computer readable storage medium
CN112181924A (en) File conversion method, device, equipment and medium
CN113505143B (en) Sentence type conversion method and device, storage medium and electronic device
US9720905B2 (en) Augmented text search with syntactic information
CN108008947B (en) Intelligent prompting method and device for programming statement, server and storage medium
CN110727651A (en) Log processing method and device, terminal equipment and computer readable storage medium
CN117667979A (en) Data mining method, device, equipment and medium based on large language model
CN114490709B (en) Text generation method and device, electronic equipment and storage medium
CN101089841B (en) Precision search method and system based on knowledge code
CN115982204A (en) Query statement conversion method and device, electronic equipment and storage medium
KR20120070713A (en) Method for indexing natural language and mathematical formula, apparatus and computer-readable recording medium with program therefor
CN113128201B (en) Sentence similarity determining method, answer searching method, device, equipment, system and medium
CN114089980A (en) Programming processing method, device, interpreter and nonvolatile storage medium
US20130103668A1 (en) Question conversion for information searching
CN113934430A (en) Data retrieval analysis method and device, electronic equipment and storage medium
CN113821533A (en) Data query method, device, equipment and storage medium
CN110929501A (en) Text analysis method and device

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210226