CN113761290A - Query method and query system for realizing full-text search graph database based on SQL - Google Patents

Query method and query system for realizing full-text search graph database based on SQL Download PDF

Info

Publication number
CN113761290A
CN113761290A CN202110260410.XA CN202110260410A CN113761290A CN 113761290 A CN113761290 A CN 113761290A CN 202110260410 A CN202110260410 A CN 202110260410A CN 113761290 A CN113761290 A CN 113761290A
Authority
CN
China
Prior art keywords
query
sql
graph
user
establishing
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
CN202110260410.XA
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.)
Golaxy Data Technology Co ltd
Original Assignee
Golaxy Data 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 Golaxy Data Technology Co ltd filed Critical Golaxy Data Technology Co ltd
Priority to CN202110260410.XA priority Critical patent/CN113761290A/en
Publication of CN113761290A publication Critical patent/CN113761290A/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/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/90335Query processing

Landscapes

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

Abstract

The invention discloses a query method and a query system for realizing a full-text retrieval graph database based on SQL, which comprises the following steps: s1, establishing a mapping relation between the sql query system and the graph query system; s2, establishing a user mapping relation between a query user of the sql query system and the graph query system; s3, establishing a corresponding relation between objects such as nodes, edges and the like in a table and a graph query system in the sql query system; and S4, issuing the query related to the graph node relationship in the query to a graph database for execution, and returning the records meeting the conditions to the user through SQL full-text retrieval aiming at the records returned by the graph database query. The invention has the beneficial effects that: the data stored in the graph database and the relational database can be associated and inquired together, and the burden of a user for developing a system is reduced.

Description

Query method and query system for realizing full-text search graph database based on SQL
Technical Field
The invention relates to the field of query of graph databases, in particular to a query method and a query system for realizing a full-text retrieval graph database based on SQL.
Background
With the rapid development of the industries such as social contact, e-commerce, finance, retail, internet of things and the like, a huge and complex relationship network is organized in the real society, and the traditional database is difficult to process relationship operation. The relationship between data needing to be processed in the big data industry increases in a geometric progression along with the data volume, and a database and a graph database which support massive complex data relational operation are urgently needed.
At present, two of the most popular query languages in the field of graph databases are Cypher and Gremlin. These graph query languages all focus on finding nodes and relationships that satisfy conditions through graph traversal, but condition checking on the relationships or attributes of the nodes is simple, for example, when an additional attribute of a node is a document, it is difficult to query a more conditional node through the document in the current graph database query.
An effective solution to the problems in the related art has not been proposed yet.
Disclosure of Invention
Aiming at the problems in the related art, the invention provides a query method and a query system for realizing a full-text retrieval map database based on SQL, which solve the problem of difficult query aiming at the complex attributes of the map at present and reduce the burden of a user for developing the system.
The technical scheme of the invention is realized as follows:
according to one aspect of the invention, a query method for realizing a full-text search graph database based on SQL is provided, which comprises the following steps:
s1, establishing a mapping relation between the sql query system and the graph query system;
s2, establishing a user mapping relation between a query user of the sql query system and the graph query system;
s3, establishing a corresponding relation between objects such as nodes, edges and the like in a table and a graph query system in the sql query system;
and S4, issuing the query related to the graph node relationship in the query to a graph database for execution, and returning the records meeting the conditions to the user through SQL full-text retrieval aiming at the records returned by the graph database query.
Further, the step S1 of establishing the mapping relationship between the sql query system and the graph query system includes the following steps:
s11, inputting the access url address of the graph query system in the sql query system by the user;
s12, establishing a mapping relation from the sql inquiry system to the graph database on the url address.
Further, the url address includes an ip port number and a graph database name.
Further, the step S2 of establishing the user mapping relationship between the query user of the sql query system and the user of the graph query system includes the following steps:
s21, inputting an access user and an access password of a graph database in the sql query system by the user;
and S22, establishing a mapping relation between the current sql user and the graph database according to the access user and the access password.
Further, the step S3 of establishing the correspondence between the nodes, edges, and other objects in the table and graph query system in the sql query system includes the following steps:
s31, establishing a table of attribute writing documents containing edges and other objects in the sql query system;
s32, establishing the corresponding relation between the table and the object such as the graph database query condition edge.
Further, the step S4 is to issue the query related to the graph node relationship in the query to the database for execution, and the step of returning the record meeting the condition to the user through SQL full-text retrieval includes the following steps:
s41, inputting relevant words in the document published in the edge and other objects;
s42, when the system receives the user query SQL statement, performing lexical grammar analysis on the SQL statement;
s43, generating an SQL execution plan;
s44, establishing connection with a remote database system;
s45, issuing a related graph query language to a graph database;
s46, reading records of which the graph database meets the conditions;
further, in step S42, when the system receives the user query SQL statement, the system performs lexical syntax analysis on the SQL statement, and if there is an error, returns an error message to the user, and if there is no error, continues to execute step S43.
According to another aspect of the invention, a query system for realizing a full-text retrieval map database based on SQL is provided, which comprises a client, a parser, an optimizer, an executor, an external data wrapper and a data dictionary, wherein the client, the parser, the optimizer and the executor are sequentially in telecommunication connection, the external data wrapper is respectively in telecommunication connection with the optimizer and the executor, and the external data wrapper is in telecommunication connection with the parser through the data dictionary;
the parser is used for realizing the functions of syntax parsing, semantic checking and query rewriting of SQL statements;
the optimizer generates an SQL query plan by adopting a cost-based query optimization (CBO) mode;
the external data wrapper adopts a callback function mode to provide functions of FDW object management, external Server (Foreign Server) object management, external table object management and user mapping management;
the data dictionary is used for defining FDW objects, external servers, external tables and user mapping related metadata information.
The invention has the beneficial effects that: by using the method provided by the invention, a user sends a request to the system through an SQL sentence, the system sends the request related to graph query and retrieval to database query, and full-text retrieval is carried out on the request based on the returned result, so that the problem of difficulty in querying the complex attributes of the graph at present is solved, the burden of a user development system is reduced, and the retrieval of the database is significant.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings without creative efforts.
FIG. 1 is a flow chart of a method for implementing a query of a full-text search graph database based on SQL according to an embodiment of the invention;
FIG. 2 is a block diagram of a query system implementing a full-text search graph database based on SQL in accordance with an embodiment of the invention;
fig. 3 is a flow chart of a method for implementing query of a full-text search graph database based on SQL according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present invention.
Referring to fig. 1 and fig. 3, according to an embodiment of the present invention, a method for implementing query of a full-text search graph database based on SQL is provided, which includes the following steps:
s1, establishing a mapping relation between the sql query system and the graph query system;
s11, inputting the access url address (including ip and port number map database name) of the map query system in the sql query system by the user;
s12, establishing the mapping relation of the sql inquiry system to the database so as to access the database data later.
The code of step S1 is as follows:
CREATE SERVER graph_server
FOREIGN DATA WRAPPER graph_fdw
OPTIONS(url'http://10.170.130.127:8223/db');
s2, establishing a user mapping relation between a query user of the sql query system and a graph query system
S21, inputting an access user and an access password of a graph database in the sql query system by the user;
and S22, establishing a mapping relation between the current sql user and the database, so that the current sql user can access the data of the database.
The code of step S2 is as follows:
create user MAPPING FOR db_user server graph_server
options(username'graph_user',password'graph_user');
s3, establishing a corresponding relation between objects such as nodes, edges and the like in a table and a graph query system in the sql query system;
the following description will be made in order to find out the human side and other objects recognized by Lihua, and the steps are as follows:
s31, establishing a table containing attributes of the person recognized by Lihua, such as name, age and written document, in an sql query system;
s32, establishing the corresponding relation between the table and the person identified by the graph database query condition Lihua.
The code of step S3 is as follows:
CREATE FOREIGN TABLE persons(
name text,
age int,
doc text)
SERVER graph_server
OPTIONS(query'{"query":"MATCH(person:Person)-[:KNOWS](foaf:Person)WHERE person.name="Lihua"}');
and S4, issuing the query related to the graph node relationship in the query to a graph database for execution, and returning the records meeting the conditions to the user through SQL full-text retrieval aiming at the records returned by the graph database query.
S41, inputting relevant words in the document published in the edge and other objects;
if it is found that the document published by the person recognized by Lihua includes people similar to artificial intelligence words, the codes of the step are:
select name, doc from persons where doc @ ('jieba _ qry', 'artificial intelligence');
s42, when the system receives the user query SQL statement, performing lexical grammar analysis on the SQL statement, if an error exists, returning error information to the user, and continuing to execute the step S43 if no error exists;
s43, generating an SQL execution plan;
s44, establishing connection with a remote database system;
s45, issuing a related graph query language to a graph database;
s46, reading records of which the graph database meets the conditions;
and S47, performing full-text retrieval query on the read records, and returning the records meeting the conditions to the user.
As shown in fig. 2, according to an embodiment of the present invention, there is also provided a query system for implementing a full-text search graph database based on SQL, including a client, a parser, an optimizer, an executor, an external data wrapper and a data dictionary, where the client, the parser, the optimizer and the executor are sequentially and electrically connected, the external data wrapper is respectively and electrically connected to the optimizer and the executor, and the external data wrapper is electrically connected to the parser through the data dictionary;
the parser is used for realizing the functions of syntax parsing, semantic checking and query rewriting of SQL statements;
the optimizer generates an SQL query plan by adopting a cost-based query optimization (CBO) mode;
the external data wrapper adopts a callback function mode to provide functions of FDW object management, external Server (Foreign Server) object management, external table object management and user mapping management;
the data dictionary is used for defining FDW objects, external servers, external tables and user mapping related metadata information.
In summary, by means of the technical scheme, the problem that complex query is difficult to perform on attributes of a graph database query system is solved, document attributes can be filtered according with conditions through the full-text retrieval function of SQL, and if full-text retrieval is not used, only ordinary like retrieval can be used, so that the retrieval effect is not good, for example, friendly, friends and the like cannot be retrieved when friends are searched. The problem can be solved by using the full-text retrieval function of SQL, a user sends a request to the system through SQL sentences, the system sends the request related to graph query retrieval to a graph database for query, full-text retrieval is carried out on the graph database based on returned results, the problem that complex attribute query aiming at the graph is difficult at present is solved, the burden of a user development system is reduced, and the retrieval of the graph database is significant.
Meanwhile, due to the introduction of the SQL query system, the association query can be carried out on the heterogeneous data source mapped to the system through SQL, namely, the data stored by the graph database and the relational database can be associated and queried together, and the burden of a user on developing the system is reduced.
The terms mentioned in the invention are briefly described as follows:
and (3) node: nodes are the main data elements of the graph, connected to other nodes by relationships. A node may have one or more attributes (i.e., attributes stored as key/value pairs).
The relationship is as follows: and connecting the two nodes and representing the association mode of the two nodes. A relationship may have one or more attributes (i.e., attributes stored as key/value pairs).
Full text retrieval: and segmenting the document, segmenting the search condition, and performing matching query on the document according to the segmentation result.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (8)

1. A query method for realizing a full text retrieval graph database based on SQL is characterized by comprising the following steps:
s1, establishing a mapping relation between the sql query system and the graph query system;
s2, establishing a user mapping relation between a query user of the sql query system and the graph query system;
s3, establishing a corresponding relation between objects such as nodes, edges and the like in a table and a graph query system in the sql query system;
and S4, issuing the query related to the graph node relationship in the query to a graph database for execution, and returning the records meeting the conditions to the user through SQL full-text retrieval aiming at the records returned by the graph database query.
2. The method according to claim 1, wherein the step S1 of establishing the mapping relationship between the SQL query system and the graph query system comprises the following steps:
s11, inputting the access url address of the graph query system in the sql query system by the user;
s12, establishing a mapping relation from the sql inquiry system to the graph database on the url address.
3. The method according to claim 2, wherein the url address comprises an ip port number and a name of the graph database.
4. The method according to claim 1, wherein the step S2 of establishing the mapping relationship between the query user of the SQL query system and the user of the graph query system comprises the following steps:
s21, inputting an access user and an access password of a graph database in the sql query system by the user;
and S22, establishing a mapping relation between the current sql user and the graph database according to the access user and the access password.
5. The method according to claim 1, wherein the step S3 of establishing the correspondence between the nodes and edges in the table and graph query system in the SQL query system comprises the following steps:
s31, establishing a table of attribute writing documents containing edges and other objects in the sql query system;
s32, establishing the corresponding relation between the table and the object such as the graph database query condition edge.
6. The method according to claim 1, wherein the step S4 is executed by issuing a query related to graph node relationship to the database, and returning a record satisfying a condition to the user through SQL full-text retrieval for the record returned by the query with the database comprises the following steps:
s41, inputting relevant words in the document published in the edge and other objects;
s42, when the system receives the user query SQL statement, performing lexical grammar analysis on the SQL statement;
s43, generating an SQL execution plan;
s44, establishing connection with a remote database system;
s45, issuing a related graph query language to a graph database;
s46, reading records of which the graph database meets the conditions;
and S47, performing full-text retrieval query on the read records, and returning the records meeting the conditions to the user.
7. The method according to claim 6, wherein in step S42, when the system receives the user query SQL sentence, the system performs lexical syntax analysis on the SQL sentence, if there is an error, the system returns an error message to the user, and if there is no error, the system continues to execute step S43.
8. A query system for realizing a full-text retrieval map database based on SQL, which is used for realizing the query method for realizing the full-text retrieval map database based on SQL according to any one of claims 1 to 7, and comprises a client, a parser, an optimizer, an actuator, an external data wrapper and a data dictionary, wherein the client, the parser, the optimizer and the actuator are sequentially and electrically connected, the external data wrapper is respectively and electrically connected with the optimizer and the actuator, and the external data wrapper is electrically connected with the parser through the data dictionary;
the parser is used for realizing the functions of syntax parsing, semantic checking and query rewriting of SQL statements;
the optimizer generates an SQL query plan by adopting a cost-based query optimization (CBO) mode;
the external data wrapper adopts a callback function mode to provide functions of FDW object management, external Server (Foreign Server) object management, external table object management and user mapping management;
the data dictionary is used for defining FDW objects, external servers, external tables and user mapping related metadata information.
CN202110260410.XA 2021-03-10 2021-03-10 Query method and query system for realizing full-text search graph database based on SQL Pending CN113761290A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110260410.XA CN113761290A (en) 2021-03-10 2021-03-10 Query method and query system for realizing full-text search graph database based on SQL

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110260410.XA CN113761290A (en) 2021-03-10 2021-03-10 Query method and query system for realizing full-text search graph database based on SQL

Publications (1)

Publication Number Publication Date
CN113761290A true CN113761290A (en) 2021-12-07

Family

ID=78786803

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110260410.XA Pending CN113761290A (en) 2021-03-10 2021-03-10 Query method and query system for realizing full-text search graph database based on SQL

Country Status (1)

Country Link
CN (1) CN113761290A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114297224A (en) * 2021-12-22 2022-04-08 重庆邮电大学 RDF-based heterogeneous data integration and query system and method
CN114490095A (en) * 2022-04-19 2022-05-13 北京闪马智建科技有限公司 Request result determination method and device, storage medium and electronic device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160092527A1 (en) * 2014-09-30 2016-03-31 Bitnine Co., Ltd. Data processing apparatus and data mapping method thereof
CN107092639A (en) * 2017-02-23 2017-08-25 武汉智寻天下科技有限公司 A kind of search engine system
CN107515887A (en) * 2017-06-29 2017-12-26 中国科学院计算机网络信息中心 A kind of interactive query method suitable for a variety of big data management systems
CN109684349A (en) * 2018-11-20 2019-04-26 中国科学院计算技术研究所 A kind of querying method and system calculating interactive analysis based on SQL and figure
CN111949650A (en) * 2019-05-15 2020-11-17 华为技术有限公司 Multi-language fusion query method and multi-mode database system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160092527A1 (en) * 2014-09-30 2016-03-31 Bitnine Co., Ltd. Data processing apparatus and data mapping method thereof
CN107092639A (en) * 2017-02-23 2017-08-25 武汉智寻天下科技有限公司 A kind of search engine system
CN107515887A (en) * 2017-06-29 2017-12-26 中国科学院计算机网络信息中心 A kind of interactive query method suitable for a variety of big data management systems
CN109684349A (en) * 2018-11-20 2019-04-26 中国科学院计算技术研究所 A kind of querying method and system calculating interactive analysis based on SQL and figure
CN111949650A (en) * 2019-05-15 2020-11-17 华为技术有限公司 Multi-language fusion query method and multi-mode database system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114297224A (en) * 2021-12-22 2022-04-08 重庆邮电大学 RDF-based heterogeneous data integration and query system and method
CN114490095A (en) * 2022-04-19 2022-05-13 北京闪马智建科技有限公司 Request result determination method and device, storage medium and electronic device
CN114490095B (en) * 2022-04-19 2022-06-21 北京闪马智建科技有限公司 Request result determination method and device, storage medium and electronic device

Similar Documents

Publication Publication Date Title
US8126892B2 (en) Automatically linking documents with relevant structured information
CN110291517B (en) Query language interoperability in graph databases
US9558186B2 (en) Unsupervised extraction of facts
US8862458B2 (en) Natural language interface
Chakaravarthy et al. Efficiently linking text documents with relevant structured information
CN107391677B (en) Method and device for generating Chinese general knowledge graph with entity relation attributes
US8832147B2 (en) Relational meta-model and associated domain context-based knowledge inference engine for knowledge discovery and organization
US6910003B1 (en) System, method and article of manufacture for concept based information searching
Bikakis et al. The XML and semantic web worlds: technologies, interoperability and integration: a survey of the state of the art
CN104657440B (en) Structured query statement generation system and method
US9208229B2 (en) Anchor text summarization for corroboration
WO2021135439A1 (en) Speech semantics-based information search method and related device
US20060253495A1 (en) Metadata database management system and method therefor
CN104657439A (en) Generation system and method for structured query sentence used for precise retrieval of natural language
US11263218B2 (en) Global matching system
Chen et al. Constraint preserving XML storage in relations
CN113761290A (en) Query method and query system for realizing full-text search graph database based on SQL
US11500876B2 (en) Method for duplicate determination in a graph
CN108536728A (en) A kind of data query method and apparatus
CN114218472A (en) Intelligent search system based on knowledge graph
CN113851219A (en) Intelligent diagnosis guiding method based on multi-mode knowledge graph
CN117149804A (en) Data processing method, device, electronic equipment and storage medium
CN116467291A (en) Knowledge graph storage and search method and system
Tran et al. Semantic search–using graph-structured semantic models for supporting the search process
Lehmberg Web table integration and profiling for knowledge base augmentation

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: 20211207