Setting up dimensions with a generation reference
In this recipe, we will build a table in a generation reference format. The SUPPLIER is a geographical dimension. Geographic dimensions are natural hierarchies, which means that the generations are related to each other naturally and there is normally a one-to-many relationship. A generation reference format is common in a relational environment as it can be used to conduct relational reporting as well. The same cannot be said about the parent-child structure.
Getting ready
To get started, open your SQL Server Management Studio, and add a TBC database. Add a SCHEMA using a tool such as TOAD, SQL Developer, or Golden, if you are using Oracle.
How to do it...
Run the following scripts to create the
SUPPLIER
table. We can change the script below to PL/SQL by replacingint
with INTEGER andvarchar()
with VARCHAR2(). Following the scripts is a screenshot of the table:--This is the syntax in T-SQL create table SUPPLIER ( SUPPLIERID int not null, SUPPLIER_ALIAS varchar(50) null , ADDRESS varchar(25) null , CITY varchar(25) null , STATE varchar(25) null , ZIP varchar(20) null , COUNTRY varchar(25) null , constraint PK_SUPPLIER primary key (SUPPLIERID) ) go
Execute the following scripts to add data to the
SUPPLIER
table:INSERT INTO SUPPLIER(SUPPLIERID,SUPPLIER_ALIAS,ADDRESS,CITY,STATE,ZIP,COUNTRY)VALUES (1,'High Tech Drinks','1344 CrossmanAve','Sunnyvale','California','94675','USA'); INSERT INTO SUPPLIER(SUPPLIERID,SUPPLIER_ALIAS,ADDRESS,CITY,STATE,ZIP,COUNTRY)VALUES (2,'East Coast Beverage','900 Long RidgeRd','Stamford','Connecticut','92001','USA'); INSERT INTO SUPPLIER(SUPPLIERID,SUPPLIER_ALIAS,ADDRESS,CITY,STATE,ZIP,COUNTRY)VALUES (3,'Cool Canadian','1250 Boul ReneLevesque','Montreal','New York','H3B-W4B','Canada');
Select from the
SUPPLIER
table to see the results:Select * From SUPPLIER;
How it works...
In step 1, the SUPPLIER
table was created and in step 2 the data was populated. A generation in Essbase begins with generation 1 at dimension because the name of the cube in the outline is generation 0. We can tell from the structure of the table that it is clearly set up in generation reference as depicted in the following grid:
COLUMN |
DESCRIPTION |
---|---|
SUPPLIERID |
The PRIMARY KEY and a FOREIGN KEY |
COUNTRY |
Generation 2 |
STATE |
Generation 3 |
CITY |
Generation 4 |
ZIPCODE |
Generation 5 |
ADDRESS |
Generation 6 |
Tip
The generation reference will allow us to create ragged hierarchies, but requires the handling of null values by your development tool.
See also
For more information on how to build the SUPPLIER dimension using Essbase Studio, refer to the recipe Creating hierarchies using a Generation reference table in Chapter 3.