Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSAS One to Many Dimensional Relationship

Question in SSAS for y'all. I am attempting to define a One to Many relationship in an OLAP SSAS cube environment. However, i'm running into problems with defining a primary key. Example tables are below. Relationships between the first 3 tables are easily defined (TradeDate, NYMEX Trades & NYMEX Contract). However, my goal is to create a one to many relationship between NYMEX Contract and Model Contract. In other words, the data from 1 NYMEX Contract will be utilized multiple times in the Model Contract dataset.

Table: TradeDate

  • TradeDate (PK)
  • Year
  • Month etc...

Table: NYMEX Trades (NO PK)

  • ContractName
  • TradeDate
  • Price

Table: NYMEX Contract

  • ContractName (PK)

Table: Model Contract

  • ModelContractName (PK)
  • ContractName

I need to create a one to many relationship between NYMEX Contract and Model Contract...however my PK is on the wrong column in Model Contract. Any ideas?

To help clarify - i am attempting to define a dimension --> dimension relationship. The Table "Model Contract" is a lookup table.

like image 1000
bmcbee Avatar asked Apr 30 '12 14:04

bmcbee


People also ask

What is a many-to-many dimension relationship?

With a many-to-many dimension, values are distinct summed, which means that they do not aggregate more than once to the All member. In order to support a many-to-many dimension relationship, a primary key-foreign key relationship must be defined in the data source view between all the tables that are involved.

What is an example of a one to many relationship?

Some common examples of one-to-many relationships are: A car maker makes many different models, but a particular car model is built only by a single car maker. One customer may make several purchases, but each purchase is made by a single customer.

How do you handle many-to-many relationship in dimensional model?

Eliminate the many-to-many relationship by collapsing/aggregating multiple rows. Add a row to the many-to-many dimension table: “Multiple rows”. The fact table can then link directly with the dimension.

How do you create a relationship in SSAS tabular model?

Click (and hold) on a column within a table, then drag the cursor to a related lookup column in a related lookup table, and then release. The relationship will be created in the correct order automatically.


1 Answers

What you have is an example of a many-to-many relationship between you fact data (Trades) and your dimension data (Model Contract). have a look at this: dimension relationship . Your case is a rare case since model contracts can only be assigned to one Contract Name but it still falls under the many-to-many case. This is handled using a bridge-table in dimensional modeling and in SSAS they call it an intermidiate fact table. Once you have your DSV setup like this: enter image description here

You would then create your dimensions in your project and then create a measure group for ModelContract to be able to use it as an intermediate fact table. You would then setup the dimension usage for the cube choosing a many-to-many relationship:

enter image description hereenter image description here

As a side note, you should always use surrogate keys for your dimensions. They have several advantages such as storage space in you fact table, slowly changing dimensions, source system decoupling,...

like image 88
Ali_Abadani Avatar answered Nov 04 '22 00:11

Ali_Abadani