问题
I have a table like this:
PersonId Job City ParentId
--------- ---- ----- --------
101 A C1 105
102 B C2 101
103 A C1 102
Then I need to getting the association rules between Person's job and parent's city.
I've used self-referencing and define case/nested tables but at the result of dependency graph there is no difference between person's job or city and parent's job or city!
What is the best solution for this problem in SSAS project?
回答1:
SSAS Hierarchies should address your problem. However, it's tough to say exactly how to use them without knowing more about your particular situation.
回答2:
I've run into a similar need in my own work. So far I have only investigated SQL Server Analysis Services Tabular models. I will update this answer with more information once I have finished looking into Multidimensional models.
Per Relationships (SSAS Tabular), SSAS Tabular models do not support self-joins (see below for the relevant quote). What you end up having to do is break out the group of parent elements and each level of their child elements as separate model tables. Once you have the model tables, you can use the diagram view to draw the relevant relationships.
Self-joins and loops
Self-joins are not permitted in tabular model tables. A self-join is a recursive relationship between a table and itself. Self-joins are often used to define parent-child hierarchies. For example, you could join an Employees table to itself to produce a hierarchy that shows the management chain at a business.
The model designer does not allow loops to be created among relationships in a model. In other words, the following set of relationships is prohibited. +
Table 1, column a to Table 2, column f
Table 2, column f to Table 3, column n
Table 3, column n to Table 1, column a
If you try to create a relationship that would result in a loop being created, an error is generated.
回答3:
Not sure exactly what you are trying to acheive but the following SQL would be a good starting point:
select c.PersonId , p.City
from ptable c, ptable p
where c.ParentId = p.PersonId
来源:https://stackoverflow.com/questions/6607663/self-join-in-ssas