SSAS OLAP create a dimension with dynamic attributes - olap

It is possible to create a dimension in a OLAP cube where the attibutes of this dimension are dynamic?
For instance, today I can have the attibutes A | B | C | D and tomorrow I can have the attibutes A | B | C | D | E.
Thanks in advance!

Related

Levensthein logic to get all the string with minimum difference

Suppose i have a datframe with values
Mtemp:
-----+
code |
-----+
Ram |
John |
Tracy|
Aman |
i want to compare it with dataframe
M2:
------+
code |
------+
Vivek |
Girish|
Rum |
Rama |
Johny |
Stacy |
Jon |
i want to get result so that for each value in Mtemp i will get maximum 2 possible match in M2 with Levensthein distance 2.
i have used
tp<-as.data.frame(amatch(Mtemp$code,M2$code,method = "lv",maxDist = 2))
tp$orig<-Mtemp$code
colnames(tp)<-c('Res','orig')
and i am getting result as follow
Res |orig
-----+-----
3 |Ram
5 |John
6 |Tracy
4 |Aman
please let me know a way to get 2 values(if possible) for every Mtemp string with Lev distance =2

What database schema to use for storing survey answers

I'm required for designing a survey system for our customer.
It's based on asp.net, and the database used is oracle.
I've no experience here so I'd like to ask for advice about:
What database schema to use for storing user answers, I'm afraid my current design is likely to have performance issue...
About the survey:
There'll be two or more surveys going on at the same time.
Surveys may be triggered once a year or more frequently, so I think I need a Survey Period table.
Surveys are targeting different products, so there'll be a mapping between products and surveys
Currently my design:
Survey Category table
+------------+--------------+
| CatageryId | CatageryName |
+------------+--------------+
| 1 | cat1 |
| 2 | cat2 |
+------------+--------------+
Survey Category version table
+-----------+------------+--------------------+
| VersionId | CatageryId | VersionDescription |
+-----------+------------+--------------------+
| 1 | 1 | 'cat1 version1' |
| 2 | 1 | 'cat1 version2' |
| 3 | 2 | 'cat2 version1' |
+-----------+------------+--------------------+
Survey Period Table
+----------+--------------------+
| PeriodId | PeriodDescription |
+----------+--------------------+
| 1 | 'cat1 period2016' |
| 2 | 'cat1 period2017' |
| 3 | 'cat2 period2016' |
+----------+--------------------+
Survey Period-Version map table
+----------+-----------+
| PeriodId | VersionId |
+----------+-----------+
| 1 | 1 |
| 1 | 2 |
| 2 | 1 |
| 3 | 3 |
+----------+-----------+
A Version-Question map table
+--------------+------------+
| VersionId | | QuestionId |
+--------------+------------+
| 1 | 1 |
| 1 | 2 |
| 1 | 3 |
| 2 | 1 |
| 2 | 2 |
| 3 | 1 |
+--------------+------------+
A Version-Product map table
+-----------+-----------+
| VersionId | ProductId |
+-----------+-----------+
| 1 | 'prodA' |
| 1 | 'prodB' |
| 1 | 'prodC' |
| 2 | 'prodA' |
+-----------+-----------+
And to Store the survey result data, I have to put lots of duplicated information between rows of record:
User Answer table
+----------+------------+----------+-----------+-----------+--------+-----------+
| AnswerId | QuestionId | PeriodId | UserId/Ip | ProductId | Answer | VersionId |
+----------+------------+----------+-----------+-----------+--------+-----------+
| 1 | 1 | 1 | 'adam' | 'prodA' | 'Yes' | 2 |
| 2 | 2 | 1 | 'Joe' | 'prodA' | 'Yes' | 2 |
| 3 | 1 | 2 | 'adam' | 'prodB' | 'A' | 3 |
+----------+------------+----------+-----------+-----------+--------+-----------+
We're expecting tens of products and thousands of users for this system.
So assume 30 products, 5000 users, 50 questions per survey and 4 surveys per year
in the current design, there'll be 5000 * 4 * 50 * 30 = 30 millions of records added in the User Answer Table per year,
I'm really afraid if it could still work properly..., so any suggestions for optimizing?
Edit 1:
Add VersionId column in user answer table as suggested.
This looks like a case of premature optimization. You should probably worry more about correctness and flexibility than performance.
30 million rows per year, especially in these skinny tables, is a small amount of data for any Oracle system. Don't worry too much about indexes and partitioning yet, those can be added later if necessary.
Your solution is similar to the Entity Attribute Value (EAV) model. It's worth knowing that term since much has been written about it. There are 2 common problems with EAV models you want to avoid:
Avoid extremes. Don't use EAV for everything, but don't completely avoid it either. EAV is slow and inconvenient compared to a normal table structure. It should not be used for every interesting columns, otherwise you have created a database within a database. For example, if virtually every survey has fields like a username and a date created, store those as regular columns and not in a generic column. It's OK to have a column that is only populated 99% of the time. On the other hand, it's a bad idea to always avoid the EAV and try to hack something together with 1,000 column tables or object-relational types.
Always use the correct type. Always, always, always store data as the correct type. Store numbers as numbers, dates as dates, and strings as strings. Your queries will be easier, faster, and safer, if you have at least three columns for the data: ANSWER_NUMBER, ANSWER_STRING, ANSWER_DATE. I explain the type safety problem more in this answer. Those extra columns may look bad in the model diagram, but they are a life-saver when you're querying the data.

sql server compare rows in one table

i want to keep track of the changes of a system setup and also to display them in a web application ASP.net VB.
the setup information/data is stored in a table like this:
TABLE 1
| SNR | LENSE | CAMERA | SYS |
|-----|-------|--------|-----|
| 1 | 55mm | rcd30 | 5 | (initial setup sys 5)
| 2 | 80mm | ph1 | 4 | (initial setup sys 4)
| 3 | 80mm | ph1 | 4 | (new setup sys 4)
| 4 | 55mm | ph1 | 5 | (new setup sys 5)
| 5 | 80mm | rcd30 | 5 | (new setup sys 5)
what i want is to compare for both systems (4 and 5) if and which changes occur between setups of the same system and to create a table where i keep the results and from here to display them every time i load the list of setups.
for example if i compare setup's for the sys nr 5, comparing row 1 and 4 there is a difference on camera; between 4 and 5 both the camera and the lense changes. this works if considering the first record for each system as the initial setup.
CHANGES
| SNR | LENSE | CAMERA | SYS |
|-----|-------|--------|-----|
| 1 | n | n | 5 | (initial setup sys 5)
| 2 | n | n | 4 | (initial setup sys 4)
| 3 | n | n | 4 | (new setup sys 4)
| 4 | n | y | 5 | (new setup sys 5)
| 5 | y | y | 5 | (new setup sys 5)
is it possible to do this using SQL? any ideas how? SQL has never been my strongest point :(
edit: using SQL server 2012
If you're using SQL Server 2012 or newer, you can use LAG to find the previous value, and just use a CASE on whether the old and new value differ;
WITH cte AS (
SELECT snr, sys,
lense, LAG(lense) OVER (PARTITION BY sys ORDER BY snr) old_lense,
camera, LAG(camera) OVER (PARTITION BY sys ORDER BY snr) old_camera
FROM table1
)
SELECT snr, sys,
CASE WHEN lense <> old_lense THEN 'y' ELSE 'n' END lense,
CASE WHEN camera <> old_camera THEN 'y' ELSE 'n' END camera
FROM cte
ORDER BY snr;
An SQLfiddle to test with.

Access 2010 trying to create pie chart by 1 row data

I have data looks like this
Sum Of a | Sum Of b | Sum Of C | Sum Of d
100 | 200 | 300 | 400
In order to create a pie chart I need to change it to format something like this
Sum Of | Value
a | x
c | y
d | z
Question how can I create new table that from the first table by query or any suggestion?
I was able to find this link that I found useful on creating chats from ms-access
Here we see that the trick is to create a saved UNION query named [SometingDataForPieChart]...
SELECT "DONE" AS PieCategory, [DONE] AS PieValue, [AREA] FROM [TABLE]
UNION ALL
SELECT "REMAIN" AS PieCategory, [REMAIN] AS PieValue, [AREA] FROM [TABLE]
...returning...
PieCategory | PieValue | AREA
----------- | -------- | -----
DONE | 100 | AREA1
DONE | 200 | AREA2
DONE | 200 | AREA3
REMAIN | 200 | AREA1
REMAIN | 300 | AREA2
REMAIN | 700 | AREA3
...and this is how you start to do pie chart.
Please read How to add a pie chart to my Access report as it has many images and step by steps.
Credit to: Gord Thompson for this answer

Drupal business listing a-z indexing requirements

I want to render something like below in a view.
==================================================================
View: Car parts (Content type)
A | [B] | C | D | E | [F] | [G] | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
BONNET
FRONT BUMPER
FRONT BAR REINFORCEMENT
GUARD LEFT
GUARD RIGHT
==================================================================
How do you create the top A – Z index. The letters in [ ] are anchor links.
I think this discussion could help you:
https://drupal.org/node/403012

Resources