I have a view in my sqlserver database,but now,I want to build a data cube instead of the view,aim to more select efficiency.
the view design picture.
two tables connect and select many column in this view.NOW,the trouble is in data cube, you have to have at least one measure table, But I just hope regards the two fact table as dimension table,so that I can get the similar output as the view.
Is there any help or other way? thanks!
It's not recommended, and I suggest you to keep an eye on star schema modelisation.
https://en.wikipedia.org/wiki/Star_schema
But If you want to add your tables in a cube you will need to duplicate it.
two tables will be used to create your measures (Aggregation, Sum, Count, Comparison, ...)
two other tables will be used to create your dimensions (Attributes, filters, ...)
I drew a small model for you
From Table1 (Dimension) and Table1 (Fact) your key will be facttable1.ID
and From Table1 (Dimension) and Table1 (Fact) your key will be your Foreign key
Does it help you?
Regards,
Arnaud
You need to create at least 1 dimension: for your case you can create New Named Query based on your view using ID as Key-Attribute for Dimension.
Related
I have three tables and they have a total of 2 million rows.
I'm creating a SQL query with inner join with two , sometimes three tables together. Sometimes I'm just creating a SQL query for one table.
I want to create index for it, but I'm not sure how can I create. How should I do it ? Three columns (all ID columns in tables) together or seperated. And which index will works fine ?
The last question is about DB relations. This three tables doesn't have a PF-FK relationship. Can it effect for my query time ?
If you can help me, thanks for it :)
With so little data about your model I can suggest this:
Create an index for each column on each table that is used in a join
If you want more suggestions you need to give more information.
I have a fact table that has 4 date columns CreatedDate, LoginDate, ActiveDate and EngagedDate. I have a dimension table called DimDate whose primary key can be used as foreign key for all the 4 date columns in fact table. So the model looks like this.
But the problem is, when I want to do sub-filtering for the measures based on the date column. For ex: Count all users who were created in the last month and are engaged in this month. This is not possible to do with this design, coz when I filter the measure with create date , I can’t further filter for a different time window for engaged date. Since all the connected to same dimension, they are not working independently.
However, If I create a separate date dimension table for each of the columns, and join them like this then it works.
But this looks very cumbersome when I have 20 different date columns in fact table in real world scenario, where I have to create 20 different dimensions and connect them one by one. Is there any other way I can achieve my scenario w/o creating multiple duplicated date dimensions?
This concept is called a role-playing dimension. You don't have to add the table to the DSV or the actual dimensions one time for each date. Instead add the date once, then go to the dimension usage tab. Click Add Cube Dimension, and then choose the date dim. Right-click and rename it. Then update the relationship to use the correct fields.
There's a good article on MSSQLTips.com that covers this topic.
Can Dimension Table became a fact table as well? For instance, I have a Customer dimension table with standard attributes such as name, gender, etc.
I need to know how many customers were created today, last month, last year etc. using SSAS.
I could create faceless fact table with customer key and date key or I could use the same customer dimension table because it has both keys already.
Is it normal to use Customer Dimension table as both Fact & Dimension?
Thanks
Yes, you can use a dimension table as fact table as well. In your case, you would just have a single measure which would be the count - assuming there is one record per customer in this customer table. In case you would have more than one record per customer, e. g. as you use a complex slowly changing dimension logic, you would use a distinct count.
Given your example, it is sufficient to run the query directly against the Customer dimension. There is no need to create another table to do that, such as a fact table. In fact it would be a bad idea to do that because you would have to maintain it every day. It is simpler just to run the query on the fly as long as you have time attributes in the customer table itself. In a sense you are using a dimension as a fact but, after all, data is data and can be queried as need be.
I have these 2 tables and I need to create a relationship between them so that I can import them into SSAS Tabular and run some analysis.
The first table has RollingQuarter(Moving Quarter) data. The second is a basic Date table with Date as PK.
Can anyone suggest ways to create a relationship with these?
Ill be using SQL Server 2012.
I could re-create a new date table also.
I think you may have a rough time finding a relationship with these tables.
Your top data table is derived data. It's an average over three months, reported monthly. The Quantity column applies to that window, not to a particular date like all of the stuff in the second table. So what would any relationship really mean?
If you have the primary data that were used to calculate your moving average, then use those instead. Then you can relate dates between the two tables.
But if your analysis is such that you don't need the primary data for the top table, then just pick the middle of each quarter (March 15th 2001 for the first record) and use that as your independent variable for your time series on the top. Then you can relate them by that.
Hi i m new to SSAS 2005/08. I want to create Cube from 1 table , Stored in OLTP Database. Table containg billions of records.
how to select dimension and Fact from this alone table.
Please help me.
A dimension derived from data in the fact table is known as a degenerate dimension:
http://en.wikipedia.org/wiki/Degenerate_dimension
Here's a link discussing how to model an data as both a dimension and fact attribute, if that's what you're wanting to do:
http://www.ralphkimball.com/html/07dt/KU97ModelingDataBothFactDimen.pdf