CN102567329B - Data query method and data query system - Google Patents
Data query method and data query system Download PDFInfo
- Publication number
- CN102567329B CN102567329B CN 201010589261 CN201010589261A CN102567329B CN 102567329 B CN102567329 B CN 102567329B CN 201010589261 CN201010589261 CN 201010589261 CN 201010589261 A CN201010589261 A CN 201010589261A CN 102567329 B CN102567329 B CN 102567329B
- Authority
- CN
- China
- Prior art keywords
- data
- tables
- attribute
- property value
- default attribute
- 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.)
- Active
Links
Images
Landscapes
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a data query method, which includes a preprocessing process: constructing a mapping table and a data table, wherein the mapping table records mapping relationships among attribute values of preset attributes of the data table and field names, the data table is provided with a plurality of attributes arrayed according to the preset sequence, one of the attributes is a preset attribute, and the attribute values of the preset attribute in the data table are substituted by the field names corresponding to the preset attribute; and a query process: receiving query requests of one or more attribute values carrying the preset attribute, referring to the mapping table to determine the field names corresponding to the attribute values as target field names; and querying data content corresponding to the target field names from the data table and providing the data content for a user. By the aid of the data query method in the embodiment, data can be queried only by traversing the data table once, so that data query efficiency is effectively improved.
Description
Technical field
The present invention relates to the database application technical field, particularly relate to a kind of data enquire method and system.
Background technology
In the database application, often can relate to the inquiry problem of data.For example in a database that stores Students’Score List (tb), the design of showing in the database such as table 1:
Table 1
The row name | Type |
Student number | Character string |
Term | Character string |
The subject title | Character string |
Score | Numerical value |
Storage example such as table 2 with the corresponding reality of table 1 file layout:
Table 2
Student number | Term | The subject title | Score |
200101 | The first term | Chinese language | 65 |
200101 | The first term | Mathematics | 68 |
200101 | The first term | English | 89 |
200101 | Second term | Chinese language | 87 |
200101 | Second term | Mathematics | 82 |
200101 | Second term | Physics | 45 |
200101 | Second term | Chemistry | 68 |
When showing Query Result, generally speaking display interface such as table 3:
Table 3
Student number | Term | Chinese language | Mathematics | English | Physics | Chemistry |
200101 | The first term | 65 | 68 | 89 | ||
200101 | Second term | 87 | 82 | 45 | 68 |
Therefore, when inquiry, need to write the query statement that row turns row; In this example, query statement is as follows:
Select student number as student number,
Sum (case course when ' Chinese language ' then mark else 0 end) Chinese language,
Sum (case course when ' mathematics ' then mark else 0 end) mathematics,
Sum (case course when ' English ' then mark else 0 end) English,
Sum (case course when ' physics ' then mark else 0 end) physics,
Sum (case course when ' chemistry ' then mark else 0 end) chemistry
from tb
Group by student number
Can find out that from upper example the row of prior art turns the query scheme of row, query statement of every execution all needs to travel through tables of data one time, especially when the property value of the field that needs inquiry is a lot, can have a strong impact on the efficient of inquiry.For example in the list of results, the subject field has a plurality of property values, is respectively Chinese language, mathematics, English, physics and chemistry, and when carrying out score inquiry, the achievement of every inquiry one section all needs to travel through list of results one time, and the efficient of inquiry is very low.
Summary of the invention
In view of this, the invention provides a kind of data enquire method, to solve the low problem of prior art search efficiency, technical scheme is as follows:
A kind of data enquire method comprises:
Preprocessing process:
Make up mapping table and tables of data, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name, described tables of data has a plurality of attributes of arranging according to preset order, one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data;
Query script:
The query requests of one or more property values of described default attribute is carried in reception;
With reference to described mapping table, determine the field corresponding with described property value aiming field name by name;
In described tables of data, search the data content corresponding with described aiming field name and offer the user.
Preferably, in the above-mentioned data enquire method, the property value of described default attribute, the difference along with the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order.
Preferably, in the above-mentioned data enquire method, described tables of data is list of results; Described default attribute is subject; Described field is called mark.
A kind of data query system comprises:
Pretreatment unit, be used for making up mapping table and tables of data, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name, described tables of data has a plurality of attributes of arranging according to preset order, one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data;
Storage unit is used for storing described mapping table and tables of data;
The information interaction unit is used for carrying out information interaction with the user;
The first processing unit for the query requests of the one or more property values that carry described default attribute that obtain according to described information interaction unit, with reference to described mapping table, is determined the field corresponding with described property value aiming field name by name;
The second processing unit is used for searching the data content corresponding with described aiming field name in described tables of data, and offers this user.
Preferably, in the above-mentioned data query system, the property value of described default attribute, the difference along with the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order.
Preferably, in the above-mentioned data query system, described tables of data is list of results; Described default attribute is subject; Described field is called mark.
In the technical scheme provided by the present invention, by making up mapping table and tables of data, wherein, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name; Described tables of data has a plurality of attributes of arranging according to preset order, and one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data; Thereby when the user carries out data query, from query requests, obtain one or more property values of described default attribute after, can be with reference to described mapping table, determine that the field corresponding with described property value is called the aiming field name; Then in described tables of data, search the data content corresponding with described aiming field name and offer the user; Thereby only need travel through the query script that tables of data just can be finished data, effectively raise search efficiency.
Description of drawings
In order to be illustrated more clearly in technical scheme of the present invention, the accompanying drawing of required use was done to introduce simply during the below will describe the present invention, apparently, accompanying drawing in the following describes only is some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
A kind of data enquire method process flow diagram that Fig. 1 provides for the embodiment of the invention;
A kind of data query system structural representation that Fig. 2 provides for the embodiment of the invention.
Embodiment
The prior art data enquire method, when facing the inquiry field with a plurality of property values, because of needs ergodic data table repeatedly, and the search efficiency that causes is low.
The embodiment of the invention provides a solution, its basic thought is: newly-increased mapping table in database, the property value of the default attribute of this mapping table record data table and the mapping relations between the field name, the property value of default attribute is substituted by the field name corresponding with it in the tables of data.
In order to make those skilled in the art understand better the present invention program, the present invention is described in further detail below in conjunction with embodiment.
Please refer to Fig. 1, a kind of data enquire method process flow diagram that provides for the embodiment of the invention.
At first, carry out preprocessing process, that is:
Make up mapping table and tables of data, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name, described tables of data has a plurality of attributes of arranging according to preset order, one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data.
Then, enter query script, specifically may further comprise the steps:
S101, the query requests of one or more property values of described default attribute is carried in reception.
S102 with reference to described mapping table, determines the field corresponding with described property value aiming field name by name.
S103 searches the data content corresponding with described aiming field name and offers the user in described tables of data.
The embodiment of the invention is by newly-increased mapping table in database, the property value of the default attribute of this mapping table record data table and the mapping relations between the field name, the property value of default attribute is substituted by the field name corresponding with it in the tables of data, when the user carries out data query, after from query requests, obtaining one or more property values of described default attribute, with reference to described mapping table, determine the field corresponding with described property value aiming field name by name, then in described tables of data, search the data content corresponding with described aiming field name and offer the user, thereby only need travel through a tables of data and just can finish the data query process, improve efficiency data query.
The property value of described default attribute can be along with in the tables of data, the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order and difference.
Described default attribute generally be one can dynamic change attribute, can follow the variation of the property value of a certain attribute in the tables of data and change, for such dynamic attribute, generally can expand it, in tables of data, give certain extended field, only need in mapping table, to record the mapping relations between this attribute and the extended field.
In other embodiments, described tables of data is list of results; Described default attribute is subject; Described field is called mark.Below will contrast the example of the database of the record student performance of introducing in the background technology, technical solution of the present invention will be further elaborated.
Make up list of results and mapping table, respectively referring to shown in table 4 and the table 5.
Table 4
The row name | Type |
Student number | Character string |
Term | Character string |
Mark 1 | Numerical value |
Mark 2 | Numerical value |
Mark 3 | Numerical value |
Mark 4 | Numerical value |
Mark 5 | Numerical value |
Table 5
The row name | Type |
Subject | Character string |
The corresponding field name | Character string |
Like this, behind the form record of the data in the background technology list of results with table 4 and table 5, actual display interface, respectively shown in table 6 and table 7:
Table 6: list of results
Student number | Term | Mark 1 | Mark 2 | Mark 3 | Mark 4 | Mark 5 |
200101 | The first term | 65 | 68 | 89 | ||
200101 | Second term | 87 | 82 | 45 | 68 |
Table 7: mapping table
Subject | The corresponding field name |
Chinese language | Mark 1 |
Mathematics | Mark 2 |
English | Mark 3 |
Chemistry | Mark 5 |
Physics | Mark 4 |
It is simple a lot of that the achievement information that the tables of data that provides according to the embodiment of the invention and mapping table are inquired about the student will become, and " Chinese language, mathematics and the English " achievement take the inquiry student number as the student of " 200101 " illustrates as example:
At first, in mapping table, investigate and prosecute the subject name that will look into, can utilize following SQL statement:
Select*from mapping table where subject in (Chinese language, mathematics, English)
The result that then will inquire forms character string, i.e. str=" mark 1, mark 2, mark 3 "
Then, the splicing SQL statement, in list of results, inquire about:
Sql=" the select student number, term, "+str+ " from list of results where student number=' 200101 ' ".
The result who checks out is as shown in table 7:
Table 7
Student number | Term | Mark 1 | Mark 2 | Mark 3 |
200101 | The first term | 65 | 68 | 89 |
200101 | Second term | 87 | 82 |
In the present embodiment, be that a property value to list of results is that subject is expanded, wherein subject is followed the variation in term and is changed, and has the attribute of dynamic column.After it was expanded, the property value of having set up subject was the corresponding relation between Chinese language, mathematics, English etc. and the corresponding field name, i.e. Chinese language reciprocal fraction 1, mathematics reciprocal fraction 2, English reciprocal fraction 3 etc., and at the mapping table record.
When carrying out students' result enquiry, after a plurality of property values that subject is carried in reception are the query requests of Chinese language, mathematics and English, at first at described mapping table, determine that the field name corresponding with Chinese language, mathematics and English is that mark 1, mark 2 and mark 3 are the aiming field name, then in tables of data, search the data content corresponding with mark 1, mark 2 and mark 3 and offer the user.
Compare with existing querying method, the embodiment of the invention only need travel through a list of results just can finish the query script of student performance, thereby has improved the search efficiency of data.
One of ordinary skill in the art will appreciate that: all or part of step that realizes said method embodiment can be finished by the relevant hardware of programmed instruction, aforesaid program can be stored in the computer read/write memory medium, this program is carried out the step that comprises said method embodiment when carrying out; Also can in distributed computing environment, realize the present invention, in these distributed computing environment, be executed the task by the teleprocessing equipment that is connected by communication network.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.And aforesaid storage medium comprises: the various media that can be program code stored such as ROM, RAM, magnetic disc or CD.
Corresponding to top embodiment of the method, the present invention also provides a kind of data query system, referring to shown in Figure 2, comprising:
The property value of described default attribute can be along with in the tables of data, the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order and difference.
Described default attribute generally be one can dynamic change attribute, can follow the variation of the property value of a certain attribute in the tables of data and change, for such dynamic attribute, generally can expand it, in tables of data, give certain extended field, only need in mapping table, to record the mapping relations between this attribute and the extended field.
The first processing unit 24 for the query requests of the one or more property values that carry described default attribute that obtain according to described information interaction unit, with reference to described mapping table, is determined the field corresponding with described property value aiming field name by name.
The second processing unit 25 is used for searching the data content corresponding with described aiming field name in described tables of data, and offers this user.
The embodiment of the invention is by newly-increased mapping table in database, the property value of the default attribute of this mapping table record data table and the mapping relations between the field name, the property value of default attribute is substituted by the field name corresponding with it in the tables of data, when the user carries out data query, after from query requests, obtaining one or more property values of described default attribute, with reference to described mapping table, determine the field corresponding with described property value aiming field name by name, then in described tables of data, search the data content corresponding with described aiming field name and offer the user, thereby only need travel through a tables of data and just can finish the data query process, improve efficiency data query.
In other embodiments, described tables of data is list of results; Described default attribute is subject; Described field is called mark.
For system embodiment, because it is substantially corresponding to embodiment of the method, so describe fairly simplely, relevant part gets final product referring to the part explanation of embodiment of the method.System embodiment described above only is schematic, wherein said unit as the separating component explanation can or can not be physically to separate also, the parts that show as the unit can be or can not be physical locations also, namely can be positioned at a place, perhaps also can be distributed on a plurality of network element.Can select according to the actual needs wherein some or all of module to realize the purpose of present embodiment scheme.Those of ordinary skills namely can understand and implement in the situation of not paying creative work.
Need to prove, in this article, relational terms such as the first and second grades only is used for an entity or operation are made a distinction with another entity or operation, and not necessarily requires or hint and have the relation of any this reality or sequentially between these entities or the operation.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thereby not only comprise those key elements so that comprise process, method, article or the equipment of a series of key elements, but also comprise other key elements of clearly not listing, or also be included as the intrinsic key element of this process, method, article or equipment.Do not having in the situation of more restrictions, the key element that is limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment that comprises described key element and also have other identical element.
Be understandable that the present invention can be used in numerous general or special purpose computingasystem environment or the configuration.For example: personal computer, server computer, handheld device or portable set, plate equipment, multicomputer system, the system based on microprocessor, set-top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, comprise distributed computing environment of above any system or equipment etc.
The above only is the specific embodiment of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.
Claims (6)
1. a data enquire method is applied to face the inquiry field with a plurality of property values, it is characterized in that, comprising:
Preprocessing process:
Make up mapping table and tables of data, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name, described tables of data has a plurality of attributes of arranging according to preset order, one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data;
Query script:
The query requests of one or more property values of described default attribute is carried in reception;
With reference to described mapping table, determine the field corresponding with described property value aiming field name by name;
In described tables of data, search the data content corresponding with described aiming field name and offer the user.
2. data enquire method according to claim 1 is characterized in that, the property value of described default attribute, the difference along with the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order.
3. data enquire method according to claim 1 and 2 is characterized in that, described tables of data is list of results; Described default attribute is subject; Described field is called mark.
4. a data query system is applied to face the inquiry field with a plurality of property values, it is characterized in that, comprising:
Pretreatment unit, be used for making up mapping table and tables of data, described mapping table records the property value of default attribute of described tables of data and the mapping relations between the field name, described tables of data has a plurality of attributes of arranging according to preset order, one of them attribute is described default attribute, and the property value of default attribute is substituted by the field name corresponding with it in the described tables of data;
Storage unit is used for storing described mapping table and tables of data;
The information interaction unit is used for carrying out information interaction with the user;
The first processing unit for the query requests of the one or more property values that carry described default attribute that obtain according to described information interaction unit, with reference to described mapping table, is determined the field corresponding with described property value aiming field name by name;
The second processing unit is used for searching the data content corresponding with described aiming field name in described tables of data, and offers this user.
5. data query system according to claim 4 is characterized in that, the property value of described default attribute, the difference along with the difference of the property value of one of them attribute of described a plurality of attributes of arranging according to preset order.
6. according to claim 4 or 5 described data query systems, it is characterized in that described tables of data is list of results; Described default attribute is subject; Described field is called mark.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201010589261 CN102567329B (en) | 2010-12-15 | 2010-12-15 | Data query method and data query system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201010589261 CN102567329B (en) | 2010-12-15 | 2010-12-15 | Data query method and data query system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102567329A CN102567329A (en) | 2012-07-11 |
CN102567329B true CN102567329B (en) | 2013-10-23 |
Family
ID=46412770
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN 201010589261 Active CN102567329B (en) | 2010-12-15 | 2010-12-15 | Data query method and data query system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102567329B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106933904A (en) * | 2015-12-31 | 2017-07-07 | 北京国双科技有限公司 | The filter method and device of data |
Families Citing this family (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103049473A (en) * | 2012-10-15 | 2013-04-17 | 新浪技术(中国)有限公司 | Data querying method and device |
CN103150401B (en) * | 2013-03-27 | 2017-03-08 | 领航动力信息系统有限公司 | A kind of field entirety replacement method based on MapReduce |
CN104424190A (en) * | 2013-08-20 | 2015-03-18 | 富士通株式会社 | Method and device for integrating a plurality of databases |
CN105808540A (en) * | 2014-12-29 | 2016-07-27 | 金蝶软件(中国)有限公司 | Configuration data storage method and system |
CN106933918A (en) * | 2015-12-31 | 2017-07-07 | 北京国双科技有限公司 | The querying method and device of tables of data |
CN106933892B (en) * | 2015-12-31 | 2019-05-31 | 北京国双科技有限公司 | The storage method and device of description information |
CN108563736B (en) * | 2018-04-10 | 2021-04-27 | 口碑(上海)信息技术有限公司 | Method and device for querying data based on data characteristics |
CN110597849B (en) * | 2018-05-25 | 2022-03-22 | 北京国双科技有限公司 | Data query method and device |
CN110727672A (en) * | 2018-06-28 | 2020-01-24 | 北京京东尚科信息技术有限公司 | Data mapping relation query method and device, electronic equipment and readable medium |
CN109299234B (en) * | 2018-09-19 | 2022-03-15 | 北京明略软件系统有限公司 | Information query method and device and computer readable storage medium |
CN110309053A (en) * | 2019-05-22 | 2019-10-08 | 梁俊杰 | A kind of the definition method and relevant device of ontology |
CN112769880B (en) * | 2019-11-01 | 2022-09-16 | 腾讯科技(深圳)有限公司 | Attribute query method and device, storage medium and computer equipment |
CN113903421B (en) * | 2021-10-11 | 2022-04-12 | 上海柯林布瑞信息技术有限公司 | Method and device for rapidly processing medical scientific research form data |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101593180A (en) * | 2008-05-30 | 2009-12-02 | 国际商业机器公司 | The SPARQL inquiry is changed into the method and apparatus of SQL query |
CN101667201A (en) * | 2009-09-18 | 2010-03-10 | 浙江大学 | Integration method of Deep Web query interface based on tree merging |
CN101727465A (en) * | 2008-11-03 | 2010-06-09 | 中国移动通信集团公司 | Methods for establishing and inquiring index of distributed column storage database, device and system thereof |
-
2010
- 2010-12-15 CN CN 201010589261 patent/CN102567329B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101593180A (en) * | 2008-05-30 | 2009-12-02 | 国际商业机器公司 | The SPARQL inquiry is changed into the method and apparatus of SQL query |
CN101727465A (en) * | 2008-11-03 | 2010-06-09 | 中国移动通信集团公司 | Methods for establishing and inquiring index of distributed column storage database, device and system thereof |
CN101667201A (en) * | 2009-09-18 | 2010-03-10 | 浙江大学 | Integration method of Deep Web query interface based on tree merging |
Non-Patent Citations (2)
Title |
---|
关于语义网格环境中异构数据资源整合的研究;李庆忠等;《南京大学学报(自然科学版)》;20060331;第42卷(第02期);第141-147页 * |
李庆忠等.关于语义网格环境中异构数据资源整合的研究.《南京大学学报(自然科学版)》.2006,第42卷(第02期),第141-147页. |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106933904A (en) * | 2015-12-31 | 2017-07-07 | 北京国双科技有限公司 | The filter method and device of data |
CN106933904B (en) * | 2015-12-31 | 2019-12-03 | 北京国双科技有限公司 | The filter method and device of data |
Also Published As
Publication number | Publication date |
---|---|
CN102567329A (en) | 2012-07-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102567329B (en) | Data query method and data query system | |
CN109074383B (en) | Document search with visualization within the context of a document | |
CN102023989B (en) | Information retrieval method and system thereof | |
CN101876983B (en) | Method for partitioning database and system thereof | |
US8086592B2 (en) | Apparatus and method for associating unstructured text with structured data | |
US20160048584A1 (en) | On-the-fly determination of search areas and queries for database searches | |
CN104765731B (en) | Database inquiry optimization method and apparatus | |
US10585927B1 (en) | Determining a set of steps responsive to a how-to query | |
US9449117B2 (en) | Metadata search based on semantics | |
CN103425687A (en) | Retrieval method and system based on queries | |
CN110109910A (en) | Data processing method and system, electronic equipment and computer readable storage medium | |
US20090228430A1 (en) | Multidimensional data cubes with high-cardinality attributes | |
CN102999625A (en) | Method for realizing semantic extension on retrieval request | |
US20140046928A1 (en) | Query plans with parameter markers in place of object identifiers | |
CN101136027B (en) | System and method for database indexing, searching and data retrieval | |
CN108170752B (en) | Template-based metadata management method and system | |
US20140095145A1 (en) | Responding to natural language queries | |
US8745062B2 (en) | Systems, methods, and computer program products for fast and scalable proximal search for search queries | |
CN103678362A (en) | Search method and search system | |
CN104714974A (en) | Method and device for parsing and reprocessing query statement | |
CN103365914A (en) | Database query system and method based on search engine | |
US8527518B2 (en) | Inverted indexes with multiple language support | |
US8156144B2 (en) | Metadata search interface | |
US11487719B2 (en) | Single table multi-schema data store in a key value store | |
CN101963993B (en) | Method for fast searching database sheet table record |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |