一种多维数据查询方法及装置Multidimensional data query method and device
技术领域Technical field
本发明涉及大数据分析技术领域,尤其涉及一种多维数据查询方法及装置。The present invention relates to the technical field of big data analysis, in particular to a multi-dimensional data query method and device.
背景技术Background technique
在多维数据分析处理中,基于OLAP引擎的业务逻辑模型建模是目前很常用的一种解决方案,即通过实现一个“数据立方体”对数据仓库中的数据按不同的维度组合进行建模聚合,并在数据分析师进行实际业务查询时,根据查询的指标和维度组合对逻辑模型进行汇总聚合返回结果,从而实现对业务数据多维分析的有力支撑。In multi-dimensional data analysis and processing, business logic model modeling based on OLAP engine is a very commonly used solution at present, that is, by implementing a "data cube" to model and aggregate data in the data warehouse according to different dimensional combinations, And when data analysts conduct actual business queries, they will summarize and aggregate the logical models to return results according to the queried indicators and dimension combinations, thereby achieving strong support for multi-dimensional analysis of business data.
然而,随着具体业务领域的细分发展,单一业务逻辑模型中维度数量过多、维值基数过大的场景越来越多,某类分析维度、特别是数据定义近似但业务定义有所差别的维度组在同一分析模型中出现的频率也越来越高。在保证实际多维分析的目标下,如果在维度定义上基于所有的业务场景做细分定义,会导致维度存在过度重复定义、占据过多物理存储空间、维度***的隐患,对维度的管理也会造成很大的挑战。However, with the development of specific business areas, there are more and more scenarios in a single business logic model with too many dimensions and too large dimensional value base. Certain types of analysis dimensions, especially data definitions, are similar but business definitions are different. The frequency of dimensional groups appearing in the same analysis model is also increasing. Under the goal of ensuring the actual multi-dimensional analysis, if the dimension definition is defined based on all business scenarios, it will lead to the hidden dangers of excessive repetition of the definition, occupying too much physical storage space, and dimension explosion. The management of the dimension will also Cause great challenges.
发明内容Summary of the invention
本发明的目的在于提供一种多维数据查询方法及装置,能够在减少数据模型物理存储空间的同时实现对近似维度数据的精确查询。The purpose of the present invention is to provide a multi-dimensional data query method and device, which can realize accurate query of approximate dimensional data while reducing the physical storage space of the data model.
为了实现上述目的,本发明的一方面提供一种多维数据查询方法,包括:In order to achieve the above objective, one aspect of the present invention provides a multi-dimensional data query method, including:
基于数据仓库中的维度表构建原子维度数据,所述原子维度数据包括维度编码、维度名称、维值编码和维值名称;Constructing atomic dimension data based on the dimension table in the data warehouse, the atomic dimension data including dimension code, dimension name, dimension value code and dimension value name;
基于数据仓库中的事实表训练物理模型,所述物理模型中存储有明细事实数据及对应的指标字段和度量字段;Training a physical model based on the fact table in the data warehouse, the physical model stores detailed fact data and corresponding index fields and metric fields;
针对所述原子维度数据进行维度拓展,对应生成与之相关的多个衍生维度数据;Perform dimension expansion for the atomic dimension data, and correspondingly generate multiple derivative dimension data related thereto;
将所述物理模型与所述衍生维度数据映射匹配构建逻辑模型,所述逻辑模型中存储有所述衍生维度数据与对应指标字段及度量字段的映射关系;Mapping and matching the physical model with the derived dimension data to construct a logical model, and the logical model stores the mapping relationship between the derived dimension data and corresponding indicator fields and metric fields;
获取查询指令,从所述逻辑模型中调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出。The query instruction is obtained, and the derived dimension data corresponding to the mapping relationship and the statistical output of the index field and the measurement field are retrieved from the logical model.
优选地,在基于数据仓库中的事实表训练物理模型之前还包括:Preferably, before training the physical model based on the fact table in the data warehouse, the method further includes:
根据原子维度数据的维度编码,对所述原子维度数据进行查询权限的配置。According to the dimension code of the atomic dimension data, the configuration of the query authority for the atomic dimension data is performed.
较佳地,所述查询权限的配置规则采用角色和/或工号对应设定范围维值编码的方案。Preferably, the configuration rule of the query authority adopts a scheme in which the role and/or the job number correspond to the dimension value encoding of the set range.
优选地,针对所述原子维度数据进行维度拓展,对应生成与之相关的多个衍生维度数据的方法包括:Preferably, performing dimension expansion for the atomic dimension data, and correspondingly generating multiple derivative dimension data related thereto includes:
所述衍生维度数据由衍生字段和相关原子维度数据中的维值编码组成,所述衍生字段代表业务场景。The derived dimension data is composed of a derived field and dimension value codes in related atomic dimension data, and the derived field represents a business scenario.
优选地,所述衍生维度数据包括单一业务场景的衍生维度数据和多元业务场景的衍生维度数据;Preferably, the derived dimensional data includes derived dimensional data of a single business scenario and derived dimensional data of multiple business scenarios;
所述单一业务场景的衍生维度数据中的衍生字段为空;The derivative field in the derivative dimension data of the single business scenario is empty;
所述多元业务场景的衍生维度数据中的衍生字段为非空,且各所述衍生字段与每种业务场景一一对应。The derivative fields in the derivative dimension data of the multiple business scenarios are not empty, and each of the derivative fields corresponds to each business scenario one-to-one.
优选地,将所述物理模型与所述衍生维度数据映射匹配构建逻辑模型的方法包括:Preferably, the method of mapping and matching the physical model with the derived dimension data to construct a logical model includes:
设置所述逻辑模型的字段构成,所述字段构成包括维度字段、度量字段和指标字段;Setting the field composition of the logical model, the field composition including a dimension field, a metric field, and an index field;
清洗所述物理模型的字段数据,仅保留与所述逻辑模型字段构成一致的字段数据;Clean the field data of the physical model, and only retain the field data that is consistent with the logical model field composition;
获取所述衍生维度数据与所述物理模型中度量字段及指标字段的映射关 系,构建所述逻辑模型。Obtain the mapping relationship between the derived dimension data and the measurement field and the index field in the physical model, and construct the logical model.
优选地,获取查询指令,从所述逻辑模型中调取对应映射关系的所述衍生维度数据及指标字段输出的方法包括:Preferably, the method of obtaining the query instruction and retrieving the derived dimension data and index field output corresponding to the mapping relationship from the logical model includes:
从查询指令中解析角色和/或工号信息,基于对应的控制权限调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出。The role and/or job number information is parsed from the query instruction, and the derived dimension data of the corresponding mapping relationship and the statistical output of the indicator field and the measurement field are retrieved based on the corresponding control authority.
与现有技术相比,本发明提供的多维数据查询方法具有以下有益效果:Compared with the prior art, the multi-dimensional data query method provided by the present invention has the following beneficial effects:
本发明提供的多维数据查询方法中,根据数据仓库中的维度表定义并创建原子维度数据,然后用户根据需要的业务定义及目标查询场景确定业务模型,并基于该业务模型从数据仓库中调取相关事实表训练物理模型,其中,该物理模型中存储有明细事实数据及对应的指标字段和度量字段,为了提升维度的丰富度,本发明还需根据业务场景的定义对原子维度数据进行维度拓展,生成与之相关的多个衍生维度数据,之后将上述物理模型与衍生维度数据映射匹配构建逻辑模型,得到衍生维度数据与对应指标字段及度量字段的映射关系,在逻辑模型建成之后,基于用户的查询指令从逻辑模型中调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出,推送给报表端展示给用户。In the multidimensional data query method provided by the present invention, atomic dimensional data is defined and created according to the dimension table in the data warehouse, and then the user determines the business model according to the required business definition and target query scenario, and retrieves it from the data warehouse based on the business model Relevant fact table training physical model, where detailed fact data and corresponding index fields and metric fields are stored in the physical model. In order to enhance the richness of dimensions, the present invention also needs to expand the atomic dimension data according to the definition of business scenarios. , Generate multiple derivative dimension data related to it, and then map and match the above physical model with the derivative dimension data to construct a logical model to obtain the mapping relationship between the derivative dimension data and the corresponding indicator fields and measurement fields. After the logical model is built, based on the user The query instructions retrieve the derived dimension data corresponding to the mapping relationship and the statistical output of the index field and the measurement field from the logical model, and push it to the report side for display to the user.
可见,相比较于现有技术中利用单一原子维度数据与物理模型构建逻辑模型而言,在实现相同维度数据查询需求的情况下,使用本发明提供的多维数据查询方法能够减少维度***带来的人为建设管理成本及硬件存储技术成本。It can be seen that compared with the use of single atomic dimension data and physical model to construct a logical model in the prior art, the use of the multi-dimensional data query method provided by the present invention can reduce the impact of dimensional explosion under the condition of achieving the same dimensional data query requirements. Man-made construction management costs and hardware storage technology costs.
本发明的另一方面提供一种多维数据查询装置,应用于上述技术方案提到的多维数据查询方法中,该装置包括原子维度构建单元,用于基于数据仓库中的维度表构建原子维度数据,所述原子维度数据包括维度编码、维度名称、维值编码和维值名称;Another aspect of the present invention provides a multi-dimensional data query device, which is applied to the multi-dimensional data query method mentioned in the above technical solution. The device includes an atomic dimension construction unit for building atomic dimension data based on a dimension table in a data warehouse, The atomic dimension data includes dimension code, dimension name, dimension value code and dimension value name;
物理模型建模单元,用于基于数据仓库中的事实表训练物理模型,所述物理模型中存储有明细事实数据及对应的指标字段和度量字段;The physical model modeling unit is used to train the physical model based on the fact table in the data warehouse, and the physical model stores detailed fact data and corresponding index fields and measurement fields;
维度拓展单元,用于针对所述原子维度数据进行维度拓展,对应生成与 之相关的多个衍生维度数据;The dimension expansion unit is used to expand the dimension of the atomic dimension data, and correspondingly generate multiple derivative dimension data related to it;
逻辑模型建模单元,用于将所述物理模型与所述衍生维度数据映射匹配构建逻辑模型,所述逻辑模型中存储有所述衍生维度数据与对应指标字段及度量字段的映射关系;A logical model modeling unit, configured to map and match the physical model with the derived dimensional data to construct a logical model, and the logical model stores the mapping relationship between the derived dimensional data and corresponding indicator fields and metric fields;
查询输出单元,用于获取查询指令,从所述逻辑模型中调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出。The query output unit is used to obtain a query instruction, and retrieve the derived dimension data of the corresponding mapping relationship and the statistical output of the index field and the measurement field from the logic model.
优选地,在原子维度建模单元和物理模型建模单元之间还包括Preferably, between the atomic dimension modeling unit and the physical model modeling unit further includes
权限配置单元,用于根据原子维度数据的维度编码,对所述原子维度数据进行查询权限的配置。The authority configuration unit is used to configure the query authority for the atomic dimension data according to the dimension code of the atomic dimension data.
与现有技术相比,本发明提供的多维数据查询装置的有益效果与上述技术方案提供的多维数据查询方法的有益效果相同,在此不做赘述。Compared with the prior art, the beneficial effects of the multi-dimensional data query device provided by the present invention are the same as the beneficial effects of the multi-dimensional data query method provided by the above technical solutions, and will not be repeated here.
本发明的第三方面提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器运行时执行上述多维数据查询方法的步骤。A third aspect of the present invention provides a computer-readable storage medium on which a computer program is stored, and when the computer program is run by a processor, the steps of the above-mentioned multi-dimensional data query method are executed.
与现有技术相比,本发明提供的计算机可读存储介质的有益效果与上述技术方案提供的多维数据查询方法的有益效果相同,在此不做赘述。Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present invention are the same as the beneficial effects of the multi-dimensional data query method provided by the above technical solutions, and will not be repeated here.
附图说明Description of the drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本发明的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described here are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments and descriptions of the present invention are used to explain the present invention, and do not constitute an improper limitation of the present invention. In the attached picture:
图1为本发明实施例一中多维数据查询方法的流程示意图;FIG. 1 is a schematic flowchart of a multi-dimensional data query method in Embodiment 1 of the present invention;
图2为本发明实施例一中订单指标维度建设示例图。Figure 2 is an example diagram of order indicator dimension construction in Embodiment 1 of the present invention.
具体实施方式Detailed ways
为使本发明的上述目的、特征和优点能够更加明显易懂,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。 显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动的前提下所获得的所有其它实施例,均属于本发明保护的范围。In order to make the above objectives, features, and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be described clearly and completely in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
实施例一Example one
请参阅图1,本实施例提供一种多维数据查询方法,包括:基于数据仓库中的维度表构建原子维度数据,原子维度数据包括维度编码、维度名称、维值编码和维值名称;基于数据仓库中的事实表训练物理模型,物理模型中存储有明细事实数据及对应的指标字段和度量字段;针对原子维度数据进行维度拓展,对应生成与之相关的多个衍生维度数据;将物理模型与衍生维度数据映射匹配构建逻辑模型,逻辑模型中存储有衍生维度数据与对应指标字段及度量字段的映射关系;获取查询指令,从逻辑模型中调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出。Referring to Fig. 1, this embodiment provides a multi-dimensional data query method, including: constructing atomic dimension data based on a dimension table in a data warehouse. The atomic dimension data includes dimension codes, dimension names, dimension value codes, and dimension value names; based on data The fact table in the warehouse trains the physical model. The physical model stores detailed fact data and corresponding indicator fields and measurement fields; expands the dimension of the atomic dimension data, and generates multiple derivative dimension data related to it correspondingly; combines the physical model with Derived dimension data mapping and matching to construct a logical model. The logical model stores the mapping relationship between the derived dimension data and the corresponding indicator field and measurement field; obtains query instructions, and retrieves the derived dimension data, indicator field and measurement of the corresponding mapping relationship from the logical model Field statistics output.
本实施例提供的多维数据查询方法中,根据数据仓库中的维度表定义并创建原子维度数据,然后用户根据需要的业务定义及目标查询场景确定业务模型,并基于该业务模型从数据仓库中调取相关事实表训练物理模型,其中,该物理模型中存储有明细事实数据及对应的指标字段和度量字段,为了提升维度的丰富度,本实施例还需根据业务场景的定义对原子维度数据进行维度拓展,生成与之相关的多个衍生维度数据,之后将上述物理模型与衍生维度数据映射匹配构建逻辑模型,得到衍生维度数据与对应指标字段及度量字段的映射关系,在逻辑模型建成之后,基于用户的查询指令从逻辑模型中调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出,推送给报表端展示给用户。In the multidimensional data query method provided in this embodiment, atomic dimensional data is defined and created according to the dimension table in the data warehouse, and then the user determines the business model according to the required business definition and target query scenario, and adjusts from the data warehouse based on the business model Take the relevant fact table to train the physical model. The physical model stores detailed fact data and corresponding index fields and measurement fields. In order to enhance the richness of the dimensions, this embodiment also needs to perform the atomic dimension data according to the definition of the business scenario. Dimension expansion, generate multiple derivative dimensional data related to it, and then match the above physical model with the derivative dimensional data to build a logical model, and obtain the mapping relationship between the derivative dimensional data and the corresponding indicator fields and measurement fields. After the logical model is built, Based on the user's query instruction, the derived dimension data of the corresponding mapping relationship and the statistical output of the index field and the measurement field are retrieved from the logical model, and then pushed to the report side and displayed to the user.
可见,相比较于现有技术中利用单一原子维度数据与物理模型构建逻辑模型而言,在实现相同维度数据查询需求的情况下,使用本实施例提供的多维数据查询方法能够减少维度***带来的人为建设管理成本及硬件存储技术成本。It can be seen that, compared with the use of single atomic dimension data and physical models to construct logical models in the prior art, in the case of achieving the same dimension data query requirements, using the multi-dimensional data query method provided in this embodiment can reduce dimensional explosions. The cost of man-made construction management and hardware storage technology.
优选地,上述实施例中在基于数据仓库中的事实表训练物理模型之前还 包括:Preferably, before training the physical model based on the fact table in the data warehouse in the above embodiment, the method further includes:
根据原子维度数据的维度编码,对原子维度数据进行查询权限的配置。其中,查询权限的配置规则采用角色和/或工号对应设定范围维值编码的方案。示例性地,上述基于维度的权限控制采用角色+工号+维值编码的方案,即每个角色+工号在某一维度上对应的可以查看的维值编码范围是预先配置的,其中角色可以指职位、工种等。According to the dimension code of the atomic dimension data, the configuration of the query authority for the atomic dimension data is performed. Among them, the configuration rule of the query authority adopts a scheme in which the role and/or job number correspond to the dimension value encoding of the set range. Exemplarily, the above-mentioned dimension-based permission control adopts a role+work ID+dimension value encoding scheme, that is, the dimension value encoding range that can be viewed corresponding to each role+work ID in a certain dimension is pre-configured, where the role Can refer to position, type of work, etc.
上述实施例中针对原子维度数据进行维度拓展,对应生成与之相关的多个衍生维度数据的方法包括:衍生维度数据由衍生字段和相关原子维度数据中的维值编码组成,衍生字段代表业务场景。In the above embodiment, the dimension expansion is performed for the atomic dimension data, and the corresponding method for generating multiple derivative dimension data related thereto includes: the derivative dimension data is composed of the derivative field and the dimension value code in the related atomic dimension data, and the derivative field represents the business scenario .
具体实施时,当逻辑模型建设中需要的衍生维度为“业务场景+原子维度”时,则***会基于物理模型中对应的字段名+原子维度编码,组成新的衍生维度编码,如基于“城市”这个原子维度,根据业务场景需要区分“收货城市”、“发货城市”,从而生成不同的衍生维度编码。In specific implementation, when the derived dimension required in the construction of the logical model is "business scenario + atomic dimension", the system will form a new derived dimension code based on the corresponding field name + atomic dimension code in the physical model, such as based on "city "This atomic dimension" distinguishes "receiving city" and "shipping city" according to business scenarios, thereby generating different derived dimension codes.
可以理解的是,上述实施例中的衍生维度数据包括单一业务场景的衍生维度数据和多元业务场景的衍生维度数据;单一业务场景的衍生维度数据中的衍生字段为空;多元业务场景的衍生维度数据中的衍生字段为非空,且各衍生字段与每种业务场景一一对应。换句话说,对于如“流量访问城市”这种单一业务场景的衍生维度数据,可视作衍生维度数据等同于原子维度数据,也即衍生字段为空,对于如“收货城市”、“发货城市”这种多元业务场景的衍生维度数据中的衍生字段为非空,若“城市”的原子维度数据的维值编码为WD0001,则“收货城市”的衍生维度数据的维值编码为receivecity WD0001,“发货城市”的衍生维度数据的维值编码为delivercity WD0001。It is understandable that the derived dimension data in the above embodiment includes the derived dimension data of a single business scenario and the derived dimension data of multiple business scenarios; the derived field in the derived dimension data of a single business scenario is empty; the derived dimensions of multiple business scenarios The derived fields in the data are not empty, and each derived field corresponds to each business scenario one-to-one. In other words, for the derived dimensional data of a single business scenario such as "traffic visiting city", the derived dimensional data can be regarded as equivalent to the atomic dimensional data, that is, the derived field is empty. The derivative field in the derivative dimension data of the multi-business scenario of "delivery city" is not empty. If the dimension value code of the atomic dimension data of "city" is WD0001, then the dimension value code of the derivative dimension data of "receiving city" is receivecity WD0001, the dimension code of the derived dimension data of "shipping city" is delivercity WD0001.
需要说明的是,上述实施例中的基于同一个原子维度数据生成的衍生维度数据,完全继承原子维度数据中的维值编码,即维度编码源自同一张物理表;基于同一个原子维度数据生成的衍生维度数据,在血缘分析上可追溯至同一原子维度数据,且可以指定为不同指标间的公共维度,便于跨域分析使用。It should be noted that the derived dimension data generated based on the same atomic dimension data in the above embodiment completely inherits the dimension value code in the atomic dimension data, that is, the dimension code originates from the same physical table; it is generated based on the same atomic dimension data The derived dimension data can be traced to the same atomic dimension data in blood relationship analysis, and can be designated as a common dimension between different indicators, which is convenient for cross-domain analysis.
进一步地,上述实施例中的将所述物理模型与所述衍生维度数据映射匹配构建逻辑模型的方法包括:Further, the method for mapping and matching the physical model and the derived dimension data to construct a logical model in the foregoing embodiment includes:
设置逻辑模型的字段构成,字段构成包括维度字段、度量字段和指标字段;清洗物理模型的字段数据,仅保留与逻辑模型字段构成一致的字段数据;获取衍生维度数据与物理模型中度量字段及指标字段的映射关系,构建逻辑模型。Set the field composition of the logical model, including dimension fields, metric fields, and index fields; clean the field data of the physical model, and only keep the field data consistent with the logical model field composition; obtain the derived dimension data and the metric fields and indicators in the physical model The mapping relationship of the fields builds a logical model.
需要补充的是,对于同一个原子维度数据生成的衍生维度数据,在构建逻辑模型时该衍生维度数据虽然继承了原子维度数据的权限配置,但在训练逻辑模型时还可增加衍生维度数据的权限控制开关,例如逻辑模型中包括衍生维度数据A和衍生维度数据B,当在训练逻辑模型中选择打开衍生维度数据A的权限控制开关时,其权限配置与原子维度数据的权限配置相同,当在训练逻辑模型中未选择打开衍生维度数据B的权限控制开关时,其权限配置处于关闭状态即等同于未设置权限配置。可见,本实施例通过增设衍生维度数据的权限控制开关,能够进一步保证逻辑模型应用的灵活性。What needs to be added is that for the derived dimension data generated by the same atomic dimension data, although the derived dimension data inherits the permission configuration of the atomic dimension data when constructing the logical model, it can also increase the permission of the derived dimension data when training the logical model. Control switches. For example, the logic model includes derived dimension data A and derived dimension data B. When the permission control switch of derived dimension data A is selected in the training logic model, its permission configuration is the same as that of atomic dimension data. When the permission control switch of the derived dimension data B is not selected in the training logic model, the permission configuration is turned off, which is equivalent to not setting the permission configuration. It can be seen that this embodiment can further ensure the flexibility of logic model application by adding a permission control switch for derived dimension data.
上述实施例中,获取查询指令,从逻辑模型中调取对应映射关系的衍生维度数据及指标字段输出的方法包括:从查询指令中解析角色和/或工号信息,基于对应的控制权限调取对应映射关系的衍生维度数据及指标字段和度量字段统计输出。In the above embodiment, the method of obtaining query instructions, invoking derived dimension data corresponding to the mapping relationship and output of index fields from the logical model includes: parsing role and/or job number information from the query instructions, and invoking based on the corresponding control authority The derived dimension data corresponding to the mapping relationship and the statistical output of indicator fields and measurement fields.
为了便于理解,请参阅图2,本实施例以订单相关数据分析举例说明:For ease of understanding, please refer to Figure 2. This embodiment uses order-related data analysis as an example:
根据数据仓库中的城市维度表,在维度管理***中定义“城市”维度,以WD0001作为该维度的唯一编码标识,维值存放形式例如“025—南京市”,并进行相应的权限配置工作;According to the city dimension table in the data warehouse, define the "city" dimension in the dimension management system, use WD0001 as the unique code identifier of the dimension, and store the dimension value in the form of "025—Nanjing City", and carry out the corresponding authority configuration work;
基于数据仓库中的订单明细表,建设订单过程的物理模型;Build a physical model of the order process based on the order schedule in the data warehouse;
由于订单明细表中包含“收货城市”“发货城市”“下单城市”三个与“城市”原子维度数据相关的分析维度字段,因此在建设订单逻辑模型时,***自动根据物理表中的字段名称,生成三个衍生维度数据,分别为receivecity WD0001、delivercity WD0001、submitcity WD0001,且这三个衍生 维度数据的原始维度数据定义与维值数据均继承城市维度,无需人为重复建设管理;Since the order detail table contains three analytical dimension fields related to the atomic dimension data of "city", "receiving city", "shipping city" and "order city", the system will automatically follow the physical table when building the order logic model Generate three derived dimension data, namely receivecity WD0001, delivercity WD0001, and submitcity WD0001, and the original dimension data definition and dimension value data of these three derived dimension data inherit the city dimension, without the need for human repeated construction management;
建设逻辑模型,同时建设指标(含维度信息);Build a logical model and at the same time build indicators (including dimension information);
根据业务需要,“发货城市”delivercity_WD0001保留“城市”维度所有的权限配置信息并生效、“收货城市”和“下单城市”均不需要做数据权限控制,在指标建设时做好相应的勾选配置;According to business needs, "delivery city" delivercity_WD0001 retains all the authority configuration information of the "city" dimension and takes effect. Both "receiving city" and "order city" do not need to control data authority, and make corresponding measures during indicator construction Check the configuration;
报表可以查看付款金额指标+收货城市/发货城市/下单城市三个维度,且发货城市做权限控制、另外两个无权限控制。The report can view three dimensions of payment amount indicator + receiving city/shipping city/order city, and the shipping city is subject to authority control, and the other two have no authority control.
通过上述实施过程可知,本实施例通过多维数据查询方法能够解决维度的过度人为近似定义的问题,利用衍生维度数据规则自动生成不同的衍生维度编码,可以继承同一原子维度的数据及血缘信息;此外,通过将衍生维度数据进行差异化的数据权限控制,避免了因继承原子维度数据而将衍生维度数据全部按照同样的范围控制权限的问题,也即可以解耦固化衍生维度数据的控制权限,实现根据不同的业务场景对衍生维度数据权限的差异化控制。Through the above implementation process, it can be seen that this embodiment can solve the problem of excessive artificial approximate definition of dimensions through the multi-dimensional data query method, and automatically generate different derived dimension codes by using derived dimension data rules, which can inherit data and blood relationship information of the same atomic dimension; in addition, , By performing differentiated data authority control on derived dimension data, the problem of inheriting atomic dimension data and controlling authority of all derived dimension data in the same scope is avoided, and the control authority of derived dimension data can be decoupled and solidified to achieve Differentiated control of data permissions for derived dimensions according to different business scenarios.
实施例二Example two
本实施例提供一种多维数据查询装置,包括原子维度构建单元,用于基于数据仓库中的维度表构建原子维度数据,所述原子维度数据包括维度编码、维度名称、维值编码和维值名称;This embodiment provides a multi-dimensional data query device, including an atomic dimension construction unit for building atomic dimension data based on a dimension table in a data warehouse, the atomic dimension data including dimension codes, dimension names, dimension value codes, and dimension value names ;
物理模型建模单元,用于基于数据仓库中的事实表训练物理模型,所述物理模型中存储有明细事实数据及对应的指标字段和度量字段;The physical model modeling unit is used to train the physical model based on the fact table in the data warehouse, and the physical model stores detailed fact data and corresponding index fields and measurement fields;
维度拓展单元,用于针对所述原子维度数据进行维度拓展,对应生成与之相关的多个衍生维度数据;The dimension expansion unit is used to expand the dimension of the atomic dimension data, and correspondingly generate multiple derivative dimension data related thereto;
逻辑模型建模单元,用于将所述物理模型与所述衍生维度数据映射匹配构建逻辑模型,所述逻辑模型中存储有所述衍生维度数据与对应指标字段及度量字段的映射关系;A logical model modeling unit, configured to map and match the physical model with the derived dimensional data to construct a logical model, and the logical model stores the mapping relationship between the derived dimensional data and corresponding indicator fields and metric fields;
查询输出单元,用于获取查询指令,从所述逻辑模型中调取对应映射关 系的衍生维度数据及指标字段和度量字段统计输出。The query output unit is used to obtain a query instruction, and retrieve the derived dimension data corresponding to the mapping relationship and the statistical output of the index field and the measurement field from the logical model.
优选地,在原子维度建模单元和物理模型建模单元之间还包括Preferably, between the atomic dimension modeling unit and the physical model modeling unit further includes
权限配置单元,用于根据原子维度数据的维度编码,对所述原子维度数据进行查询权限的配置。The authority configuration unit is used to configure the query authority for the atomic dimension data according to the dimension code of the atomic dimension data.
与现有技术相比,本发明实施例提供的多维数据查询装置的有益效果与上述实施例一提供的多维数据查询方法的有益效果相同,在此不做赘述。Compared with the prior art, the beneficial effects of the multi-dimensional data query device provided by the embodiment of the present invention are the same as the beneficial effects of the multi-dimensional data query method provided in the first embodiment, and will not be repeated here.
实施例三Example three
本实施例提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,计算机程序被处理器运行时执行上述多维数据查询方法的步骤。This embodiment provides a computer-readable storage medium on which a computer program is stored, and when the computer program is run by a processor, the steps of the above-mentioned multi-dimensional data query method are executed.
与现有技术相比,本实施例提供的计算机可读存储介质的有益效果与上述技术方案提供的多维数据查询方法的有益效果相同,在此不做赘述。Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this embodiment are the same as the beneficial effects of the multi-dimensional data query method provided by the above technical solutions, and will not be repeated here.
本领域普通技术人员可以理解,实现上述发明方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,上述程序可以存储于计算机可读取存储介质中,该程序在执行时,包括上述实施例方法的各步骤,而的存储介质可以是:ROM/RAM、磁碟、光盘、存储卡等。Those of ordinary skill in the art can understand that all or part of the steps in the above-mentioned inventive method can be implemented by a program instructing relevant hardware. The above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it includes For each step of the method in the foregoing embodiment, the storage medium may be: ROM/RAM, magnetic disk, optical disk, memory card, etc.
以上,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited to this. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, and they shall cover Within the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.