The content of the invention
It is a primary object of the present invention to provide a kind of data query method and device of database, to solve to analysis
When big dimension table inquires about the data of a nearest processing time period in database, the problem of slow efficiency comparison of inquiry velocity is low.
To achieve these goals, according to an aspect of the invention, there is provided a kind of data query method of database.
Included according to the data query method of the database of the present invention:The first dimension table in the first database is obtained, wherein, the first number
It is used to store all data in dimension table according to storehouse;The second dimension table created in the second database is obtained, wherein, the second database
For the database inquired about for data processing;The dynamic condition added for the first dimension table is obtained, wherein, dynamic condition makes the
Two-dimensionses table preserves the data of the nearest dimension processing time period stored in the first dimension table;Looked into by the second dimension table
Ask the data of a nearest dimension processing time period.
Further, the first dimension table obtained in the first database includes:Member value sum in the first dimension table is detected,
Wherein, multiple member value are included in the first dimension table, member value sum is used for the total quantity for representing multiple member value;Judge into
Whether member's value sum is more than the first predetermined threshold value;In the case where member value sum is more than the first predetermined threshold value, obtains first and tie up
Spend table.
Further, the data for inquiring about a nearest dimension processing time period by the second dimension table include:Obtain thing
Index in real table, wherein, true table stores all achievement datas;Second dimension table is mapped with the Index Establishment in true table
Relation;By mapping relations, the data of a nearest dimension processing time period are inquired about by the second dimension table, inquiry knot is obtained
Really.
Further, method also includes:The data processing time cycle of the second dimension table is detected, wherein, during data processing
Between the cycle be the time cycle pre-set;According to the data processing time cycle, data processing is carried out to the second dimension table.
Further, include after the data that a nearest dimension processing time period is inquired about by the second dimension table:Inspection
Survey the Query Result for the data that a nearest dimension processing time period is inquired about by the second dimension table;By Query Result send to
Distributor is inquired about, wherein, inquiry Distributor is used to collect all inquiry request information and Query Result;Inquiry distribution
Server sends Query Result information to client.
To achieve these goals, there is provided a kind of data query method of database according to another aspect of the present invention
Device.The device includes:First acquisition unit, for obtaining the first dimension table in the first database, wherein, the first database
For storing all data in dimension table;Second acquisition unit, for obtaining the second dimension table created in the second database, its
In, the second database is the database inquired about for data processing;3rd acquiring unit, adds for obtaining for the first dimension table
Plus dynamic condition, wherein, dynamic condition make the second dimension table preserve the first dimension table in store a nearest dimension processing
The data of time cycle;Query unit, the data for inquiring about a nearest dimension processing time period by the second dimension table.
Further, first acquisition unit includes:First detection module, for detecting that member value is total in the first dimension table
Number, wherein, include multiple member value in the first dimension table, member value sum is used for the total quantity for representing multiple member value;Sentence
Disconnected module, for judging whether member value sum is more than the first predetermined threshold value;First acquisition module, for big in member value sum
In the case of the first predetermined threshold value, the first dimension table is obtained.
Further, query unit includes:Second acquisition module, for obtaining the index in true table, wherein, true table
Store all achievement datas;Creation module, for by the second dimension table and the Index Establishment mapping relations in true table;First looks into
Module is ask, for by mapping relations, the data of a nearest dimension processing time period being inquired about by the second dimension table, are obtained
Query Result.
Further, device also includes:Second detection module, the data processing time week for detecting the second dimension table
Phase, wherein, the data processing time cycle is the time cycle pre-set;Processing module, for according to data processing time week
Phase, data processing is carried out to the second dimension table.
Further, device also includes:3rd detection module, a nearest dimension is inquired about for detecting by the second dimension table
Spend the Query Result of the data of processing time period;Sending module, for Query Result to be sent to inquiry Distributor, its
In, inquiry Distributor is used to collect all inquiry request information and Query Result;Second enquiry module, for inquiring about distribution
Server sends Query Result information to client.
The data query method of the database provided by the present invention, by obtaining the first dimension in the first database
Table, the first database is used to store all data in dimension table;The second dimension table created in the second database is obtained, wherein,
Second database is the database inquired about for data processing;Obtain the dynamic condition added for the first dimension table, dynamic bar
Part makes the data of the nearest dimension processing time period stored in the second dimension table the first dimension table of preservation;Pass through the second dimension
The data that table inquires about a nearest dimension processing time period are spent, are solved to big dimension table inquiry nearest one in analytical database
During the data of individual processing time period, the problem of slow efficiency comparison of inquiry velocity is low has reached and has accelerated inquiry velocity, improves
The effect of search efficiency.
Embodiment
It should be noted that in the case where not conflicting, the feature in embodiment and embodiment in the application can phase
Mutually combination.Describe the present invention in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
In order that those skilled in the art is better understood from the present invention program, below in conjunction with the embodiment of the present invention
Accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is only
The embodiment of a part of the invention, rather than whole embodiments.Based on the embodiment in the present invention, in ordinary skill
Personnel do not make the every other embodiment obtained under the premise of creative work, should all belong to the protection model of the present invention
Enclose.
It should be noted that term " first " in description and claims of this specification and above-mentioned accompanying drawing, "
Two " etc. be for distinguishing similar object, without for describing specific order or precedence.It should be appreciated that so using
Data can exchange in the appropriate case, so as to embodiments of the invention described herein can with except illustrating herein or
Order beyond those of description is implemented.In addition, term " comprising " and " having " and their any deformation, it is intended that cover
Lid is non-exclusive to be included.
Fig. 1 is the flow chart of the first embodiment of the data query method of the database according to the present invention.As shown in figure 1,
This method includes steps S101 to step S104:
Step S101, obtains the first dimension table in the first database.
First database in this refers to data warehouse, English name Data Warehouse, abbreviation DW or DWH, data
Warehouse is the strategy for all types data supported for the decision-making system process raising of all ranks of enterprise.It is that individual data is deposited
Storage, the purpose of Chinese idiom analytical presentation and decision support and create, being provided for enterprise needs business intelligence to know operation flow
Improve and time of supervision, cost, quality and control.
Dimension table can be regarded as including true record in fact table in the window that user carrys out analyze data, dimension table
Characteristic, some characteristics provide descriptive information, and some characteristics specify how to collect fact table data, to be analyst
Useful information is provided, dimension table includes the hierarchical structure for the characteristic for helping combined data.For example, the dimension comprising product information
If each class that table is generally comprised in the hierarchical structure that product is divided into the Ganlei such as food, beverage, non-consumption product, these products is entered
One step is repeatedly segmented, until each product reaches lowest level.In dimension table, each table is included independently of other dimension tables
True characteristic, for example, client's dimension table includes the data about client.Information can be divided into difference by the row field in dimension table
The structural level of level.Dimension table contains the associated detailed information of specified attribute in true table, such as, detailed product, client
Attribute, storage information etc..
The first dimension table in the first database is obtained, is the data volume for first detecting the first dimension table, then by each dimension table
Data volume and setting the first predetermined threshold value be compared, pick out data volume be more than the first predetermined threshold value dimension., this step
Purpose be in order to filter out the big dimension table in database, i.e. data volume exceed threshold value dimension table, to the big dimension filtered out
Degree table passes through subsequent treatment, lifts data query speed.
Step S102, obtains the second dimension table created in the second database.
The second above-mentioned database refers to analytical database, and analytical database can carry out Online statistics, data to data
The work of information data value is excavated in on-line analysis, immediately inquiry etc., is one important branch of database product.
The second dimension table is created in analytical database, the second dimension table is obtained.The purpose of this step is to create one
Store the dimension table of a nearest time-triggered protocol cycle data.
Step S103, obtains the dynamic condition added for the first dimension table.
To filtering out the addition dynamic condition of the big dimension table in database, the purpose of this step is nearest in order to ensure only to return
The data of one time cycle, it is ensured that the data stored in the second dimension table are the data of a nearest time cycle.
For example, a concrete implementation code is as follows:
CREATE VIEW[SnapshotLatestWindow].[DimFactSessionView]
AS
SELECT SessionKey,'-'AS SessionKeyName
FROM dbo.FactSession S
WHERE S.SessionTimeKey>=(SELECT MIN (timekey) FROM dbo.DimTime WHERE
PreciseHourDateTime=CONVERT (DATE, DATEADD (dd, -2, GETDATE ())))
Realize all Session only retained in two days SessionKey data.Where a line, is as moved above
State filter condition, the meaning of expression is Session data of the time that is returned only in two days, wherein where followed by condition
For more than or equal to the sessiontimekey values before two days.
Step S104, the data of a nearest dimension processing time period are inquired about by the second dimension table.
When it is the data of a nearest dimension processing time period to inquire about Distributor to detect inquiry data, pass through
The second dimension table in analytical database is inquired about.This step, which is avoided, is inquiring about the number of a nearest dimension processing time period
According to when, historical data base is inquired about in analytical database.So as to accelerate inquiry velocity, improve search efficiency.
The data query method of the database provided in embodiments of the invention, by obtaining first in the first database
Dimension table, the first database is used to store all data in dimension table;The second dimension table created in the second database is obtained, its
In, the second database is the database inquired about for data processing;Obtain the dynamic condition added for the first dimension table, dynamic
Condition makes the data of the nearest dimension processing time period stored in the second dimension table the first dimension table of preservation;Pass through second
Dimension table inquires about the data of a nearest dimension processing time period, solves nearest to big dimension table inquiry in analytical database
During the data of one processing time period, the problem of slow efficiency comparison of inquiry velocity is low has reached and has accelerated inquiry velocity, raising
The effect of search efficiency.
Above-mentioned first embodiment is further comprising the steps of:The index in true table is obtained, wherein, true table storage is all to be referred to
Mark data.
The true each data warehouse of table editor includes one or more fact table.Fact table may be included
Business sales data, such as cash register affairs.Produced data, fact table generally comprises substantial amounts of row.Factual data
Being mainly characterized by of table includes numerical data, and these digital informations can collect, to provide units concerned as history
Data, each fact table includes an index being made up of some, and the index is included to be tieed up as the correlation of external key
The major key of table is spent, and dimension table includes the characteristic of true record.Fact table should not include descriptive information, also should not
This includes except digital metric field and makes any data in true and dimension table in addition to the relative index field of respective items.Comprising
" metric " in fact table has two kinds:A kind of is the metric that can add up, and another is non-accumulative metric.
Most useful metric is the metric that can add up, and its numeral added up is significantly.User can be by tired
Count metric and obtain summary information, for example.The sales situation of the particular commodity in one group of shop in the specific period can be collected.It is non-
Accumulative metric can be used for fact table, and single summarized results is usually nonsensical, for example, at mansion
During diverse location measurement temperature, if it is nonsensical that the temperature of all diverse locations in mansion, which is added up, but it is averaging
Value is meaningful.
In general, a fact table will be associated with one or more dimension tables, and user is utilizing true number
When creating cube according to table, one or more dimension tables can be used.
By the second dimension table and the Index Establishment mapping relations in true table.
Mapping refers to the relation of element mutually " correspondence " between the collection of two elements, also refers to " formation corresponding relation ".It will obtain
Index sets up mapping relations with the second dimension table in true table.
By mapping relations, the data of a nearest dimension processing time period are inquired about by the second dimension table, are looked into
Ask result.
By the second dimension table and Index Establishment mapping relations, when inquiring about nearest dimension processing by the second dimension table
Between the cycle data, its corresponding index can be mapped to accordingly by the second dimension table.Poll-final, so as to can just succeed
Return Query Result.
Fig. 2 is the flow chart of the second embodiment of the data query method of the database according to the present invention.As shown in figure 1,
This method includes steps S201 to step S206:
Member value sum in step S201, the first dimension table of detection, wherein, include multiple members in the first dimension table
Value, member value sum is used for the total quantity for representing multiple member value.
Step S202, judges whether member value sum is more than the first predetermined threshold value.
First predetermined threshold value refers to refer to the big default numerical value of dimension member value total quantity.
Step S203, in the case where member value sum is more than the first predetermined threshold value, obtains the first dimension table.
In the case where member value sum is more than the first predetermined threshold value, the first dimension table is obtained.Even if filtering out member value
Sum is more than the big dimension table of the first predetermined threshold value, obtains big dimension table.
Step S204, obtains the second dimension table created in the second database.
The step is with above-mentioned steps S102.
Step S205, obtains the dynamic condition added for the first dimension table.
The step is with above-mentioned steps S103.
Step S206, the data of a nearest dimension processing time period are inquired about by the second dimension table.
The step is with above-mentioned steps S104.
The data query method of the database provided in embodiments of the invention, by detecting member value in the first dimension table
Sum, wherein, include multiple member value in the first dimension table, member value sum is used for the total quantity for representing multiple member value;
Judge whether member value sum is more than the first predetermined threshold value;In the case where member value sum is more than the first predetermined threshold value, obtain
First dimension table, obtains the second dimension table created in the second database, obtains the dynamic condition added for the first dimension table,
The data of a nearest dimension processing time period are inquired about by the second dimension table, are solved to big dimension table in analytical database
When inquiring about the data of a nearest processing time period, the problem of slow efficiency comparison of inquiry velocity is low has reached and has accelerated inquiry
Speed, the effect for improving search efficiency.
Fig. 3 is the flow chart of the 3rd embodiment of the data query method of the database according to the present invention.As shown in figure 3,
This method includes steps S301 to step S307:
Step S301, obtains the first dimension table in the first database.
The step is with above-mentioned steps S101.
Step S302, obtains the second dimension table created in the second database.
The step is with above-mentioned steps S102.
Step S303, obtains the dynamic condition added for the first dimension table.
The step is with above-mentioned steps S103.
Step S304, the data of a nearest dimension processing time period are inquired about by the second dimension table.
The step is with above-mentioned steps S104.
The inquiry knot of the data of a nearest dimension processing time period is inquired about in step S305, detection by the second dimension table
Really.
Step S306, Query Result is sent to inquiry Distributor;Wherein, inquiry Distributor is used to collect institute
There are inquiry request information and Query Result.
In data processing field, inquiry Distributor is used for all inquiry request information in collection system, and will look into
Ask solicited message and be sent to inquiry server.When inquiry server lookup terminates, inquiry Distributor receives inquiry server
Query Result.It is connected by data query server with inquiry Distributor, inquires about Distributor by the progress of collection
The information of data query is sent to data query server, and data query server obtains data query information.Looked into by data
The information of inquiry, data query server sends query statement, and inquiry Distributor obtains Query Result.Data query server
After progress data query terminates, Query Result is sent to inquiry Distributor, inquiry Distributor obtains inquiry and tied
Really.
Step S307, inquiry Distributor sends Query Result information to client.
Query Result is fed back to client by inquiry Distributor, can obtain the Query Result from client.This step
Purpose Query Result can be made into feedback in time, be easy to obtain Query Result in time.
The data query method of the database provided in embodiments of the invention, by obtaining first in the first database
Dimension table, obtains the second dimension table created in the second database, obtains the dynamic condition added for the first dimension table, passes through
Second dimension table inquires about the data of a nearest dimension processing time period, and detection inquires about a nearest dimension by the second dimension table
Spend the Query Result of the data of processing time period;Query Result is sent to inquiry Distributor, wherein, inquiry distribution clothes
Business device is used to collect all inquiry request information and Query Result;Inquiry Distributor sends Query Result information to client
End, is solved to when big dimension table inquires about the data of a nearest processing time period in analytical database, inquiry velocity is imitated slowly
Rate than it is relatively low the problem of, reached the effect for improving search efficiency and being capable of feedback query result in time.
It should be noted that can be in such as one group computer executable instructions the step of the flow of accompanying drawing is illustrated
Performed in computer system, and, although logical order is shown in flow charts, but in some cases, can be with not
The order being same as herein performs shown or described step.
Fig. 4 is the schematic diagram of the first embodiment of the data query arrangement of the database according to the present invention.The database
Data query arrangement includes:First acquisition unit 10, second acquisition unit 20, the 3rd acquiring unit 30 and query unit 40.
First acquisition unit 10, for obtaining the first dimension table in the first database, the first database, which is used to store, to be tieed up
Spend all data in table.
Second acquisition unit 20, for obtaining the second dimension table created in the second database, wherein, the second database is
The database inquired about for data processing.
3rd acquiring unit 30, for obtaining the dynamic condition added for the first dimension table, dynamic condition makes the second dimension
Degree table preserves the data of the nearest dimension processing time period stored in the first dimension table.
Query unit 40, the data for inquiring about a nearest dimension processing time period by the second dimension table.
The data query arrangement of the database provided in embodiments of the invention, the device includes:First acquisition unit 10
The first dimension table in the first database is obtained, the first database is used to store all data, second acquisition unit in dimension table
The second dimension table created in 20 the second databases of acquisition, wherein, the second database is the database inquired about for data processing,
3rd acquiring unit 30 obtains the dynamic condition added for the first dimension table, and dynamic condition makes the second dimension table preserve the first dimension
The data of the nearest dimension processing time period stored in degree table, query unit 40 inquires about nearest one by the second dimension table
The data of individual dimension processing time period.Solve and a nearest processing time period is inquired about to big dimension table in analytical database
Data when, the problem of slow efficiency comparison of inquiry velocity is low has reached the effect for accelerating inquiry velocity, improving search efficiency
Really.
Fig. 5 is the schematic diagram of the second embodiment of the data query arrangement of the database according to the present invention.The database
Data query arrangement includes:First acquisition unit 10, second acquisition unit 20, the 3rd acquiring unit 30 and query unit 40.Its
Middle query unit 40 includes:Second acquisition module 401, the enquiry module 403 of creation module 402 and first.
First acquisition unit 10, second acquisition unit 20, the effect of the 3rd acquiring unit 30 and query unit 40 with it is above-mentioned
Act on identical in embodiment, will not be repeated here.
Second acquisition module 401, for obtaining the index in true table, wherein, true table stores all achievement datas.
Creation module 402, for by the second dimension table and the Index Establishment mapping relations in true table.
First enquiry module 403, when being handled for by mapping relations, a nearest dimension to be inquired about by the second dimension table
Between the cycle data, obtain Query Result.
Fig. 6 is the schematic diagram of the 3rd embodiment of the data query arrangement of the database according to the present invention.The database
Data query arrangement includes:First acquisition unit 10, second acquisition unit 20, the 3rd acquiring unit 30 and query unit 40.Its
Middle query unit 40 includes:3rd detection module 404, the enquiry module 406 of sending module 405 and second.
First acquisition unit 10, second acquisition unit 20, the effect of the 3rd acquiring unit 30 and query unit 40 with it is above-mentioned
Act on identical in embodiment, will not be repeated here.
3rd detection module 404, a nearest dimension processing time period is inquired about for detecting by the second dimension table
The Query Result of data.
Sending module 405, for Query Result to be sent to inquiry Distributor, wherein, inquiry Distributor is used
In all inquiry request information of collection and Query Result.
Second enquiry module 406, sends Query Result information to client for inquiring about Distributor.
The data query arrangement of the database provided in embodiments of the invention, the device includes:First acquisition unit 10
The first dimension table in the first database is obtained, the first database is used to store all data, second acquisition unit in dimension table
The second dimension table created in 20 the second databases of acquisition, wherein, the second database is the database inquired about for data processing,
3rd acquiring unit 30 obtains the dynamic condition added for the first dimension table, and dynamic condition makes the second dimension table preserve the first dimension
The data of the nearest dimension processing time period stored in degree table, query unit 40 inquires about nearest one by the second dimension table
The data of individual dimension processing time period, the second acquisition module 401 obtains the index in true table, wherein, true table stores institute
There is achievement data;Creation module 402 is by the second dimension table and the Index Establishment mapping relations in true table;First enquiry module
403, by mapping relations, the data of a nearest dimension processing time period are inquired about by the second dimension table, obtain inquiry knot
Really.Solve to when big dimension table inquires about the data of a nearest processing time period in analytical database, inquiry velocity is imitated slowly
Rate than it is relatively low the problem of, reached the effect for improving search efficiency and being capable of feedback query result in time.
Obviously, those skilled in the art should be understood that above-mentioned each module of the invention or each step can be with general
Computing device realize that they can be concentrated on single computing device, or be distributed in multiple computing devices and constituted
Network on, alternatively, the program code that they can be can perform with computing device be realized, it is thus possible to they are stored
Performed in the storage device by computing device, either they are fabricated to respectively each integrated circuit modules or by they
In multiple modules or step single integrated circuit module is fabricated to realize.So, the present invention is not restricted to any specific
Hardware and software is combined.
The preferred embodiments of the present invention are the foregoing is only, are not intended to limit the invention, for the skill of this area
For art personnel, the present invention can have various modifications and variations.Within the spirit and principles of the invention, that is made any repaiies
Change, equivalent substitution, improvement etc., should be included in the scope of the protection.