Dimension Hierarchies
Dimension HierarchiesThe hierarchy, which can be seen as a navigational path, is the primary means of access to the multidimensional model. It consists of attributes arranged in descending (or ascending, depending on the way you look at it) levels, with each level containing attribute members. Efficient use of hierarchies significantly increases the effectiveness of the multidimensional model from the point of view of both the client (the way the user can manipulate the data) and of the server (in making the necessary calculations). The task of defining a hierarchy is simply to define the hierarchy object itself, and to specify the collection of all the levels and all their properties. Levels have two important properties:
Types of HierarchiesThe definition of a hierarchy is typically very simple. However, hierarchies can differ from each other, depending on the type of attributes they contain and the relationships between them. Figure 5.4 shows an example of a simple geography-based hierarchy, based on the attributes of our Customer dimension. Figure 5.4. Customer dimension and Geography hierarchy.
Natural Hierarchies and Their LevelsIn the Customer dimension, dependencies exists between attributes. Because country is a dependent attribute of the state, if you know the state, you can unambiguously determine what country it belongs to. The same is true for city and state. Because the state is a related attribute for the city, if you know the city you can unambiguously say what state it belongs to. In this hierarchy, the presence of a key attribute changes nothing. The entire structure of the hierarchy is determined by the relationships between the attributes that are used as levels in the hierarchy. Such hierarchy is called a natural hierarchy. All levels of a natural hierarchy are built from related attributes, and the levels are located in correspondence with the direction of the relationships of attributes. As its name suggests, it is the most effective form of hierarchy. In Analysis Services 2000, this was the only possible type of hierarchy. Analysis Services 2005 introduced a new type of hierarchy, the unnatural hierarchy. We’ll use an example that has two attributes, Marital Status and Gender, which are not related to each other. If you used an earlier version of Analysis Services to create a two-level hierarchy that includes these two attributes, you would have to perform a whole series of crafty manipulations with the data. With the current version of Analysis Services, it is just as easy to create this type of hierarchy as it was in earlier versions to create a natural hierarchy. The unnatural hierarchy differs from the natural hierarchy in the way it defines which members belong to which parents. Whereas the natural hierarchy defines its parent/child relationships by the relationships between members, the unnatural hierarchy defines its parent/child relationships by the relationships of the members to the key attribute. Let’s look at the Customers dimension in terms of an unnatural hierarchy. We’ll use the attributes Marital Status and Gender. The key attribute in the dimension is Customer ID. Let’s say you have two groups of customers that are (1) male and married and (2) male and unmarried. Your hierarchy will contain a member “male” that has two children, “married” and “unmarried.” If you add some female members, some married and some unmarried, your hierarchy will change. For unnatural hierarchies, depending on what the key attribute contains, the view of the hierarchy can change. Another difference between the two types of hierarchies is that the unnatural hierarchy can support many-to-many relationships (as well as one to many) among the members from different levels of the hierarchy. The natural hierarchy, in contrast, can support only a one-to-many relationship. So, in the Customer dimension, with an unnatural hierarchy the attribute member with Marital Status “married” could have two parents, Male and Female, as could the attribute member “unmarried.” At first glance, natural and unnatural hierarchies appear to have the same look and same behavior. And they do—in many cases, they do look and behave the same. However, it’s best to use natural hierarchy unless you really need an unnatural hierarchy. Because of the types of relationships between attributes, you could see a drop in performance. Note When you define a dimension, you need to be careful when you’re defining relationships between attributes and building hierarchies based on them. You want to avoid unnatural hierarchies and to be careful that, in natural hierarchies, the direction of the level follows the relationships between attributes. Business Intelligence Development Studio 2008 warns you when you create an unnatural hierarchy. Hierarchy Member ReferenceWhen you use hierarchies in a client application, it’s important to know how to reference the hierarchy members. The most general and reliable way is to reference a member through every level of the hierarchy by using the keys. Because each member key is unique within the parent, the full path of the keys is the unique identifier for each hierarchy member. But using keys isn’t always that easy. Sometimes it makes more sense to define a full path using the names of the members. This way is easier, but it doesn’t always unambiguously identify a member if the member name isn’t unique. Two different members with the same name and same parent would have same path. Using the full path (either names or keys) to reference members is not always effective. Analysis Services provides the Unique Name property, which gives each member of the hierarchy a unique name generated by the system. This Unique Name should be considered an internal system identifier; we don’t recommend that you to parse or generate unique names in your application. Note We strongly advise against any attempt to design or to reverse-engineer unique names and the way they are generated. The rules can change from version to version. In a natural hierarchy, the key of the member is a unique identifier within the level of the hierarchy. In most cases, the system will attempt to use the member key as the member unique name. In an unnatural hierarchy, because it can support a many-to-many relationship, such a member could be used multiple times in the same level for different parents. In an unnatural hierarchy, therefore, you would get a unique identifier with the combination of the parent’s unique name and the key of current member. This is one more difference between natural and unnatural hierarchies, which is essential to understand when you use hierarchies in applications. All Level and Key LevelAn important characteristic of any hierarchy is the presence or absence of the All level and the Key level. The All level is a level that unites all the members of the hierarchy in one member at the top of the hierarchy. Omitting the All level can sometimes seem convenient (for example, it doesn’t make sense to aggregate currencies), but might make it harder for the system to support the hierarchy. When the All level is omitted, the upper level of the hierarchy has a group of members rather than one member. In this case, understanding which member is the default one is not always easy. (For a detailed explanation about default members, see Chapter 10.) The Key level is a level based on the key attribute of the dimension. Including it doesn’t change the hierarchy, because internally every hierarchy contains a Key level, even though it might not be visible. If you do include the Key level in the hierarchy, the user can drill down to all elements of the Key level from the previous levels. If the key attribute is large, containing a large number of members, including the Key level can cause a burden on the system, and the drill down can even crash the user application. An additional reason not to include the Key level is that the system needs to determine the order of the members in the hierarchy. If the operation to determine the order is performed over many members, it can require significant resources. We recommend that you do include the All level in your hierarchy and do not include a very large Key level. Attribute HierarchiesIf you didn’t build a user-defined hierarchy, or when you need to reference a member outside the hierarchy, you can use an attribute hierarchy. Each attribute in the model has an attribute hierarchy. Attribute hierarchy is defined by two levels: the ALL level and the level that is based on the source attribute. The name of the attribute hierarchy is the same as the name of the source attribute. If you include an attribute hierarchy, you can reference any member of the attribute without creating user-defined hierarchies. You don’t have a specific DDL object called an attribute hierarchy; the attribute properties include a property for the attribute hierarchy. Attribute hierarchies can seem small. For example, in the hierarchy for the attribute Gender, we see only two members: both genders, male and female. However, in reality the hierarchy includes the Key level, which for the Customer dimension, for example, can contain an enormous number of members. Building such hierarchies can consume a lot of resources, and if the user uses them, thinking that they’re small, an operation can considerably decrease system performance. You can disable attribute hierarchies to avoid this problem, but then the attribute hierarchy would not be created at all. Alternatively, you can define the attribute hierarchy as unordered, in which case the members would not be sorted but would appear in the order defined by the system. Or you can define the attribute hierarchy as not optimized—it will be accessible for browsing, but the performance of browsing such attribute will still be suboptimal because the number of structures required for effective work will not be created. The following list contains attribute properties that define the behavior of the attribute hierarchy:
|
手机版|小黑屋|BC Morning Website ( Best Deal Inc. 001 )
GMT-8, 2025-12-13 22:15 , Processed in 0.016805 second(s), 16 queries .
Supported by Best Deal Online X3.5
© 2001-2025 Discuz! Team.