Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

Sunday, March 11, 2012

Dynamic formulas driven by table

I'm working with a DB design that seems to me to be rather complex.

This is a very slimmed down version of what I'm doing, but I believe it
is enough to get my question resolved.

Here is my layout.

These 4 tables are used to generate a questionaire.

Survey OrderID
========= ==========
SurveyID OrderID
OrderID QuestionGrpID

QGrp Questions
============= =============
QuestionGrpID QuestionID
QuestionID QuestionText

The following two tables are used to calculate a report that is sent to
the customer.

RawData
=========================
OrderID
QuestionID
Value is string but is Cast as decimal for numeric formulas

Metrics
==============================================
QuestionGroupID | ReportText | Formula | MetID
==============================================
2 | % Support Staff of Total | OP21/(OP21+OP22+OP23) | 1

The OP references are questionIDs

Now to calculate the result for the report we programatically parse the
formula creating a temp table (table name = Temp & orderID & _ &
QuestionID) with OrderID and OPxx as the field names. We create one
table for each question.

We then use dynamic SQL again to calculate the result using the above
formula

SELECT OP21/(OP21+OP22+OP23) FROM Temp5_21, Temp5_22, Temp5_23 WHERE
Temp5_21.OrderID = Temp5_22.orderID AND Temp5_22.OrderID =
Temp5_23.OrderID

This select is used to create a single table of calculated values.
This table is in turn used to tell the customer how they compare to
other customers. Percentile, Mean, Median, Std Dev, and a few others. I
don't claim this part of the project, but I'm not sure how I might have
done it, had it been assigned to me.

MY PROBLEM!!!
Sometimes a 0 is valid data and is the denominator of a devision
calculation. Since this is so dynamic and it might be difficult to
determine when division is used. I need a way to default divide by 0
execptions to NULL. This DB is on a hosted server.
Thanks for bearing with me,

Greg Kelley"yzarc" <yzarcman@.gmail.com> wrote in message
news:1105629819.876049.179950@.c13g2000cwb.googlegr oups.com...
> I'm working with a DB design that seems to me to be rather complex.
> This is a very slimmed down version of what I'm doing, but I believe it
> is enough to get my question resolved.
> Here is my layout.
> These 4 tables are used to generate a questionaire.
> Survey OrderID
> ========= ==========
> SurveyID OrderID
> OrderID QuestionGrpID
> QGrp Questions
> ============= =============
> QuestionGrpID QuestionID
> QuestionID QuestionText
>
> The following two tables are used to calculate a report that is sent to
> the customer.
> RawData
> =========================
> OrderID
> QuestionID
> Value is string but is Cast as decimal for numeric formulas
>
> Metrics
> ==============================================
> QuestionGroupID | ReportText | Formula | MetID
> ==============================================
> 2 | % Support Staff of Total | OP21/(OP21+OP22+OP23) | 1
> The OP references are questionIDs
> Now to calculate the result for the report we programatically parse the
> formula creating a temp table (table name = Temp & orderID & _ &
> QuestionID) with OrderID and OPxx as the field names. We create one
> table for each question.
> We then use dynamic SQL again to calculate the result using the above
> formula
> SELECT OP21/(OP21+OP22+OP23) FROM Temp5_21, Temp5_22, Temp5_23 WHERE
> Temp5_21.OrderID = Temp5_22.orderID AND Temp5_22.OrderID =
> Temp5_23.OrderID
> This select is used to create a single table of calculated values.
> This table is in turn used to tell the customer how they compare to
> other customers. Percentile, Mean, Median, Std Dev, and a few others. I
> don't claim this part of the project, but I'm not sure how I might have
> done it, had it been assigned to me.
> MY PROBLEM!!!
> Sometimes a 0 is valid data and is the denominator of a devision
> calculation. Since this is so dynamic and it might be difficult to
> determine when division is used. I need a way to default divide by 0
> execptions to NULL. This DB is on a hosted server.
> Thanks for bearing with me,
> Greg Kelley

Check out SET ANSI_WARNINGS, SET ARITHABORT and "Behavior if Both ARITHABORT
and ARITHIGNORE Are Set ON" in Books Online - this will do what you want.
But, it's not a recommended solution, because it means you can't use
features like distributed queries and indexed views, and it may create
problems with other code.

Alternatively, you might be able to store your formulae with a NULLIF around
the divisor:

OP21/NULLIF((OP21+OP22+OP23), 0)

If that's not possible, and you can't be sure what the divisor will be, then
you would probably have to look at solving it outside the database, either
by parsing the formulae to insert a NULLIF dynamically, or perhaps by doing
some calculations externally.

Simon|||Thanks,
I appreciate the reply. I'm using a fairly basic parser to divide the
OP codes out and creat the table. I may look at tagging the OP codes so
that I can strip anything out that is not an OP code for creating my
tables.

Thanks again,
Greg

Dynamic Form Letters

I would like to design a 'mail merge' type of letter, whereby some of the paragraphs will be conditional on parameters. Can anyone direct me to example of mail merger letters using reporting services?

thanks

ken

Did you ever find out any info about this? I am needing to do the same thing.

Thanks,

Scott

Dynamic Form Letters

I would like to design a 'mail merge' type of letter, whereby some of the paragraphs will be conditional on parameters. Can anyone direct me to example of mail merger letters using reporting services?

thanks

ken

Did you ever find out any info about this? I am needing to do the same thing.

Thanks,

Scott

Sunday, February 26, 2012

Dynamic data elements for a data collection application

What is the better table design for a data collection application.
1. Vertical model (pk, attributeName, AttributeValue)
2. Custom columns (pk, custom1, custom2, custom3...custom50)

Since the data elements collected may change year over year, which
model better takes of this column dynamicness(mittal.pradeep@.gmail.com) writes:
> What is the better table design for a data collection application.
> 1. Vertical model (pk, attributeName, AttributeValue)
> 2. Custom columns (pk, custom1, custom2, custom3...custom50)
> Since the data elements collected may change year over year, which
> model better takes of this column dynamicness

The vertical model is certainly cleaner from a relational perspective.
It also requires less maintenance.

But admittedly queries can be more complex. If attributes can be of
different data types, you need some triggers to check this. A tip
is that the sql_variant data type is good in this case.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||1. But the data collection and reporting is in horizontal format. If
collected data is edited vertically, won't there be a extra steps of
converting horizontally obtained data to vertical and then vertical to
horizontal reports. In custom column model data always remains
horizontal. Won;t performance not be a issue in taking care of two
extra steps required in vertical model.
2. Won;t the concurrency be a issue, considering the fact that a
logical single horizontal row is edited as say 10 rows. Two people
might be changing same Primary key's different attributes at the same
time.

Erland Sommarskog wrote:
> (mittal.pradeep@.gmail.com) writes:
> > What is the better table design for a data collection application.
> > 1. Vertical model (pk, attributeName, AttributeValue)
> > 2. Custom columns (pk, custom1, custom2, custom3...custom50)
> > Since the data elements collected may change year over year, which
> > model better takes of this column dynamicness
> The vertical model is certainly cleaner from a relational perspective.
> It also requires less maintenance.
> But admittedly queries can be more complex. If attributes can be of
> different data types, you need some triggers to check this. A tip
> is that the sql_variant data type is good in this case.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||(mittal.pradeep@.gmail.com) writes:
> 1. But the data collection and reporting is in horizontal format. If
> collected data is edited vertically, won't there be a extra steps of
> converting horizontally obtained data to vertical and then vertical to
> horizontal reports. In custom column model data always remains
> horizontal. Won;t performance not be a issue in taking care of two
> extra steps required in vertical model.

If you are to present ten of those custom values as columns in a report,
you get a 10-way self-join. Certainly bulky in code. Performance is
probably not top-notch, but I don't see that it would be absymal.

> 2. Won;t the concurrency be a issue, considering the fact that a
> logical single horizontal row is edited as say 10 rows. Two people
> might be changing same Primary key's different attributes at the same
> time.

Good point. This can be handled fairly easily, but it requires more
careful programming than the horizontal method.

Overall, there certainly is a tradeoff. If the set of custom fields are
faily stable, only change once per year or so, you might be prepared to
take the extra maintenance cost. But if users asks for new fields every
week, then the horizontal method could be a nightmare.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Thanks a lot for the reply.
1. I am not able to understand why i require a 10 way join though. If i
have a mapping between custom column and actual column, all i need is a
dyanamic sql generated from the mapping.

E.g.
table
--
pk, custom1, custom2, custom3...custom10

map
--
customColName ActualColName
custom1 ActualName1
custom2 ActualName2
...

Now I can generate dynamic sql using map.

2. As long as number of custom columns is enough to take care data
element additions which happen in a year. All that is needed is
addition of new elements to mapping table to decifer newly assigned
custom columns

Erland Sommarskog wrote:
> (mittal.pradeep@.gmail.com) writes:
> > 1. But the data collection and reporting is in horizontal format. If
> > collected data is edited vertically, won't there be a extra steps of
> > converting horizontally obtained data to vertical and then vertical to
> > horizontal reports. In custom column model data always remains
> > horizontal. Won;t performance not be a issue in taking care of two
> > extra steps required in vertical model.
> If you are to present ten of those custom values as columns in a report,
> you get a 10-way self-join. Certainly bulky in code. Performance is
> probably not top-notch, but I don't see that it would be absymal.
> > 2. Won;t the concurrency be a issue, considering the fact that a
> > logical single horizontal row is edited as say 10 rows. Two people
> > might be changing same Primary key's different attributes at the same
> > time.
> Good point. This can be handled fairly easily, but it requires more
> careful programming than the horizontal method.
> Overall, there certainly is a tradeoff. If the set of custom fields are
> faily stable, only change once per year or so, you might be prepared to
> take the extra maintenance cost. But if users asks for new fields every
> week, then the horizontal method could be a nightmare.
>
> --
> Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techin.../2000/books.asp|||Neither. The design flaw you are calling a vertical model is actually
known as "EAV" or "Entity-Attribute-Value" because it is a common
newbie mistake. I have no idea what your #2 means.

As your data elements change, you need to re-design the schema --
constraints, keys, data types, etc. Learn RDBMS and do it right.

I found an old "cut & paste". Someone like you posted this:

CREATE TABLE EAV -- no key declared
(key_col VARCHAR (10) NULL,
attrib_value VARCHAR (50) NULL);

INSERT INTO EAV VALUES ('LOCATION','Bedroom');
INSERT INTO EAV VALUES ('LOCATION','Dining Room');
INSERT INTO EAV VALUES ('LOCATION','Bathroom');
INSERT INTO EAV VALUES ('LOCATION','courtyard');
INSERT INTO EAV VALUES ('EVENT','verbal aggression');
INSERT INTO EAV VALUES ('EVENT','peer');
INSERT INTO EAV VALUES ('EVENT','bad behavior');
INSERT INTO EAV VALUES ('EVENT','other');

CREATE TABLE EAV_DATA -note lack of constraints, defaults, DRI
(id INTEGER IDENTITY (1,1) NOT NULL,
bts_id INTEGER NULL,
key_col VARCHAR (10) NULL,
attrib_value VARCHAR (50) NULL );

INSERT INTO EAV_DATA VALUES (1, 'LOCATION', 'Bedroom');
INSERT INTO EAV_DATA VALUES (1, 'EVENT', 'other');
INSERT INTO EAV_DATA VALUES (1, 'EVENT', 'bad behavior');
INSERT INTO EAV_DATA VALUES (2, 'LOCATION', 'Bedroom');
INSERT INTO EAV_DATA VALUES (2, 'EVENT', 'other');
INSERT INTO EAV_DATA VALUES (2, 'EVENT', 'verbal aggression');
INSERT INTO EAV_DATA VALUES (3, 'LOCATION', 'courtyard');
INSERT INTO EAV_DATA VALUES (3, 'EVENT', 'other');
INSERT INTO EAV_DATA VALUES (3, 'EVENT', 'peer');

Ideally, the result set of the query would be Location Event count
(headings if possible)

Bedroom verbal aggression 1
Bedroom peer 0
Bedroom bad behavior 0
Bedroom other 2
Dining Room verbal aggression 0
Dining Room peer 0
Dining Room bad behavior 0
Dining Room other 0
Bathroom verbal aggression 0
Bathroom peer 0
Bathroom bad behavior 0
Bathroom other 0
courtyard verbal aggression 0
courtyard peer 1
courtyard bad behavior 0
courtyard other 1

Also, if possible, another query would return this result set. (I think
I know how to do this one.)

Location Event count
Bedroom verbal aggression 1
Bedroom other 2
courtyard peer 1
courtyard other 1

Here is a From: Thomas Coleman

SELECT Locations.locationvalue, Events.eventvalue,
(SELECT COUNT(*)
FROM (SELECT LocationData.locationvalue, EventData.eventvalue

FROM (SELECT TD1.bts_id, TD1.value AS locationvalue
FROM eav_data AS TD1
WHERE TD1.key = 'location') AS LocationData
INNER JOIN
(SELECT TD2.bts_id, TD2.value AS eventvalue
FROM eav_data AS TD2
WHERE TD2.key = 'event'
) AS EventData
ON LocationData.bts_id = EventData.bts_id
) AS CollatedEventData
WHERE CollatedEventData.locationvalue = Locations.locationvalue
AND CollatedEventData.eventvalue = Events.eventvalue
FROM (SELECT T1.value AS locationvalue
FROM EAV AS T1
WHERE T1.key = 'location') AS Locations,
(SELECT T2.value AS eventvalue
FROM EAV AS T2
WHERE T2.key = 'event') AS Events
ORDER BY Locations.locationvalue, Events.eventvalue ,
SELECT Locations.locationvalue, Events.eventvalue
(SELECT COUNT(*)
FROM (SELECT LocationData.locationvalue, EventData.eventvalue

FROM (SELECT TD1.bts_id, TD1.value AS locationvalue
FROM eav_data AS TD1
WHERE TD1.key = 'location') AS LocationData
INNER JOIN
(SELECT TD2.bts_id, TD2.value AS eventvalue
FROM eav_data AS TD2
WHERE TD2.key = 'event') AS EventData
ON LocationData.bts_id = EventData.bts_id)
AS CollatedEventData
WHERE CollatedEventData.locationvalue = Locations.locationvalue
AND CollatedEventData.eventvalue = Events.eventvalue)
FROM (SELECT T1.value AS locationvalue
FROM EAV AS T1
WHERE T1.key = 'location') AS Locations,
(SELECT T2.value AS eventvalue
FROM EAV AS T2
WHERE T2.key = 'event') AS Events;

Is the same thing in a proper schema as:

SELECT L.locationvalue, E.eventvalue, COUNT(*)
FROM Locations AS L, Events AS E
WHERE L.btd_id = E.btd_id
GROUP BY L.locationvalue, E.eventvalue;

The reason that I had to use so many subqueries is that those entities
are all lopped into the same table. There should be separate tables for
Locations and Events.

The column names are seriously painful. Beyond the fact that I
personally hate underscores in column names, using underscores at the
end of the column name is really non-intuitive. I removed them for my
example and came across the next column name faux pas. Don't use "key"
and "value" for column names. It means that the developer *has*
surround the column name with square brackets for everything which is a
serious pain.

There is such a thing as "too" generic. There has to be some structure
or everything becomes nothing more than a couple of tables called
"things". The real key (no pun intended) is commonality. Is there a
pattern to the data that they want to store? It may not be possible to
create one structure to rule them all and in the darkness bind them.

"To be is to be something in particular; to be nothing in particular is
to be nothing." --Aristole

All data integrity is destroyed. Any typo becomes a new attribute or
entity. Entities are found missing attributes, so all the reports are
wrong.

ry to write a single CHECK() constraint that works for all the
attributes of those 30+ entities your users created because you were
too dumb or too lazy to do your job. It can be done! You need a case
expression almost 70 WHEN clauses for a simple invoice and order system
when I tried it as an exercise.

ry to write a single DEFAULT clause for 30+ entities crammed into one
column. Impossible!

Try to set up DRI actions among the entities. If you thought the WHEN
clauses in the single CASE expression were unmaintainable, wait until
you see the "TRIGGERs from Hell" -- Too bad that they might not fit
into older SQL Server which had some size limits. Now maintain it.

For those who are interested, there are couple of links to articles I
found on the net:

Generic Design of Web-Based Clinical Databases
http://www.jmir.org/2003/4/e27*/

The EAV/CR Model of Data Representation
http://ycmi.med.yale.edu/nadka*rni/eav_CR_contents.htm

An Introduction to Entity-Attribute-Value Design for Generic
Clinical Study Data Management Systems
http://ycmi.med.yale.edu/nadka*rni/...%20*systems.htm

Data Extraction and Ad Hoc Query of an Entity- Attribute- Value
Database
http://www.pubmedcentral.nih.g*ov/a...l=pub*med&pubme...

Exploring Performance Issues for a Clinical Database Organized Using
an Entity-Attribute-Value Representation
http://www.pubmedcentral.nih.g*ov/a...l=pub*med&pubme...|||(mittal.pradeep@.gmail.com) writes:
> Thanks a lot for the reply.
> 1. I am not able to understand why i require a 10 way join though. If i
> have a mapping between custom column and actual column, all i need is a
> dyanamic sql generated from the mapping.
> E.g.
> table
> --
> pk, custom1, custom2, custom3...custom10
>
> map
> --
> customColName ActualColName
> custom1 ActualName1
> custom2 ActualName2
> ...
> Now I can generate dynamic sql using map.

When I said 10-way join I was thinking of the vertical solution. For the
horisontal solution it's a simple join - once you have gone through all
that SQL building. To me, this sounds more complex to implement. Then
again, if the user selects dynamically which columns he wants to see,
the horizontal solution would require dynamic SQL as well.

> 2. As long as number of custom columns is enough to take care data
> element additions which happen in a year. All that is needed is
> addition of new elements to mapping table to decifer newly assigned
> custom columns

I didn't realise that you had this mapping table. One could say that
this is a kind of compromise between the horizonal model and an entirely
static vertical model.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||CELKO,

If I change the data elements 10 times during the year, I cannot change
the front end 10 to accomodate the same. I need to come up with a
dyanamic solution to take care of same. Vertical approach is the best
way to get the same. Using custom columns is a compromise, as vertical
approach is harder to implement.

--CELKO-- wrote:
> Neither. The design flaw you are calling a vertical model is actually
> known as "EAV" or "Entity-Attribute-Value" because it is a common
> newbie mistake. I have no idea what your #2 means.
> As your data elements change, you need to re-design the schema --
> constraints, keys, data types, etc. Learn RDBMS and do it right.
> I found an old "cut & paste". Someone like you posted this:
> CREATE TABLE EAV -- no key declared
> (key_col VARCHAR (10) NULL,
> attrib_value VARCHAR (50) NULL);
> INSERT INTO EAV VALUES ('LOCATION','Bedroom');
> INSERT INTO EAV VALUES ('LOCATION','Dining Room');
> INSERT INTO EAV VALUES ('LOCATION','Bathroom');
> INSERT INTO EAV VALUES ('LOCATION','courtyard');
> INSERT INTO EAV VALUES ('EVENT','verbal aggression');
> INSERT INTO EAV VALUES ('EVENT','peer');
> INSERT INTO EAV VALUES ('EVENT','bad behavior');
> INSERT INTO EAV VALUES ('EVENT','other');
> CREATE TABLE EAV_DATA -note lack of constraints, defaults, DRI
> (id INTEGER IDENTITY (1,1) NOT NULL,
> bts_id INTEGER NULL,
> key_col VARCHAR (10) NULL,
> attrib_value VARCHAR (50) NULL );
> INSERT INTO EAV_DATA VALUES (1, 'LOCATION', 'Bedroom');
> INSERT INTO EAV_DATA VALUES (1, 'EVENT', 'other');
> INSERT INTO EAV_DATA VALUES (1, 'EVENT', 'bad behavior');
> INSERT INTO EAV_DATA VALUES (2, 'LOCATION', 'Bedroom');
> INSERT INTO EAV_DATA VALUES (2, 'EVENT', 'other');
> INSERT INTO EAV_DATA VALUES (2, 'EVENT', 'verbal aggression');
> INSERT INTO EAV_DATA VALUES (3, 'LOCATION', 'courtyard');
> INSERT INTO EAV_DATA VALUES (3, 'EVENT', 'other');
> INSERT INTO EAV_DATA VALUES (3, 'EVENT', 'peer');
> Ideally, the result set of the query would be Location Event count
> (headings if possible)
> Bedroom verbal aggression 1
> Bedroom peer 0
> Bedroom bad behavior 0
> Bedroom other 2
> Dining Room verbal aggression 0
> Dining Room peer 0
> Dining Room bad behavior 0
> Dining Room other 0
> Bathroom verbal aggression 0
> Bathroom peer 0
> Bathroom bad behavior 0
> Bathroom other 0
> courtyard verbal aggression 0
> courtyard peer 1
> courtyard bad behavior 0
> courtyard other 1
> Also, if possible, another query would return this result set. (I think
> I know how to do this one.)
> Location Event count
> Bedroom verbal aggression 1
> Bedroom other 2
> courtyard peer 1
> courtyard other 1
> Here is a From: Thomas Coleman
> SELECT Locations.locationvalue, Events.eventvalue,
> (SELECT COUNT(*)
> FROM (SELECT LocationData.locationvalue, EventData.eventvalue
> FROM (SELECT TD1.bts_id, TD1.value AS locationvalue
> FROM eav_data AS TD1
> WHERE TD1.key = 'location') AS LocationData
> INNER JOIN
> (SELECT TD2.bts_id, TD2.value AS eventvalue
> FROM eav_data AS TD2
> WHERE TD2.key = 'event'
> ) AS EventData
> ON LocationData.bts_id = EventData.bts_id
> ) AS CollatedEventData
> WHERE CollatedEventData.locationvalue = Locations.locationvalue
> AND CollatedEventData.eventvalue = Events.eventvalue
> FROM (SELECT T1.value AS locationvalue
> FROM EAV AS T1
> WHERE T1.key = 'location') AS Locations,
> (SELECT T2.value AS eventvalue
> FROM EAV AS T2
> WHERE T2.key = 'event') AS Events
> ORDER BY Locations.locationvalue, Events.eventvalue ,
> SELECT Locations.locationvalue, Events.eventvalue
> (SELECT COUNT(*)
> FROM (SELECT LocationData.locationvalue, EventData.eventvalue
> FROM (SELECT TD1.bts_id, TD1.value AS locationvalue
> FROM eav_data AS TD1
> WHERE TD1.key = 'location') AS LocationData
> INNER JOIN
> (SELECT TD2.bts_id, TD2.value AS eventvalue
> FROM eav_data AS TD2
> WHERE TD2.key = 'event') AS EventData
> ON LocationData.bts_id = EventData.bts_id)
> AS CollatedEventData
> WHERE CollatedEventData.locationvalue = Locations.locationvalue
> AND CollatedEventData.eventvalue = Events.eventvalue)
> FROM (SELECT T1.value AS locationvalue
> FROM EAV AS T1
> WHERE T1.key = 'location') AS Locations,
> (SELECT T2.value AS eventvalue
> FROM EAV AS T2
> WHERE T2.key = 'event') AS Events;
> Is the same thing in a proper schema as:
> SELECT L.locationvalue, E.eventvalue, COUNT(*)
> FROM Locations AS L, Events AS E
> WHERE L.btd_id = E.btd_id
> GROUP BY L.locationvalue, E.eventvalue;
> The reason that I had to use so many subqueries is that those entities
> are all lopped into the same table. There should be separate tables for
> Locations and Events.
> The column names are seriously painful. Beyond the fact that I
> personally hate underscores in column names, using underscores at the
> end of the column name is really non-intuitive. I removed them for my
> example and came across the next column name faux pas. Don't use "key"
> and "value" for column names. It means that the developer *has*
> surround the column name with square brackets for everything which is a
> serious pain.
> There is such a thing as "too" generic. There has to be some structure
> or everything becomes nothing more than a couple of tables called
> "things". The real key (no pun intended) is commonality. Is there a
> pattern to the data that they want to store? It may not be possible to
> create one structure to rule them all and in the darkness bind them.
> "To be is to be something in particular; to be nothing in particular is
> to be nothing." --Aristole
> All data integrity is destroyed. Any typo becomes a new attribute or
> entity. Entities are found missing attributes, so all the reports are
> wrong.
> ry to write a single CHECK() constraint that works for all the
> attributes of those 30+ entities your users created because you were
> too dumb or too lazy to do your job. It can be done! You need a case
> expression almost 70 WHEN clauses for a simple invoice and order system
> when I tried it as an exercise.
> ry to write a single DEFAULT clause for 30+ entities crammed into one
> column. Impossible!
> Try to set up DRI actions among the entities. If you thought the WHEN
> clauses in the single CASE expression were unmaintainable, wait until
> you see the "TRIGGERs from Hell" -- Too bad that they might not fit
> into older SQL Server which had some size limits. Now maintain it.
> For those who are interested, there are couple of links to articles I
> found on the net:
> Generic Design of Web-Based Clinical Databases
> http://www.jmir.org/2003/4/e27*/
> The EAV/CR Model of Data Representation
> http://ycmi.med.yale.edu/nadka*rni/eav_CR_contents.htm
> An Introduction to Entity-Attribute-Value Design for Generic
> Clinical Study Data Management Systems
> http://ycmi.med.yale.edu/nadka*rni/...20*systems..htm
>
> Data Extraction and Ad Hoc Query of an Entity- Attribute- Value
> Database
> http://www.pubmedcentral.nih.g*ov/a...l=pub*med&pubme...
>
> Exploring Performance Issues for a Clinical Database Organized Using
> an Entity-Attribute-Value Representation
> http://www.pubmedcentral.nih.g*ov/a...l=pub*med&pubme...

Friday, February 24, 2012

dynamic columns/aliases - Continue

Hi
Following my previous question. Here is the implemetation.
I have to design a report which display monthes as columns.
The number of columns in the report depends on the range paramters.
For example : if the Range is from 01/02/05 to 30/06/05 there ara 6 columns
shown.
01/05,02/05....06/05. (column alias) .
if the range of dates are 8 monthes range there are 8 dynamic columns, etc'
1) My first major problem is to write a SP or a function that return a
dynamic number of columns.
2) Second,(This is not a must) to change column alias (Heading) according to
the parameters.
thanksWhat reporting tool do you use? This is called a cross tab report and
any decent reporting tool will render it for you client-side with no
programming required. Otherwise you'll have to use dynamic SQL, which
is not much fun.
David Portas
SQL Server MVP
--|||>> 1) My first major problem is to write a SP or a function that return a dy
namic number of columns. <<
NO, your **first** problem is that you missed the basic concepts of
RDBMS. A query returns a table; a table has a fixed number of columns.
A query is not a report; a query sends information to a front end
which can have a reporting tool in it.
This is definitions, not anything fancy.
\If you want to be a bad SQL programmer, this can be done with dynamic
SQL and a ton of procedural code that will be a XXXXX to maintain.|||Yes. My Big Problem is indeed the Reporting tool which is Custom Reporting
tool of an ERP software that simply translate
the resulted query to a GUI look alike Report.
Unfortunately , There's Nothing I can do about it.
What are my options with dynamic sql ?
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:1126806242.941597.208120@.g44g2000cwa.googlegroups.com...
> What reporting tool do you use? This is called a cross tab report and
> any decent reporting tool will render it for you client-side with no
> programming required. Otherwise you'll have to use dynamic SQL, which
> is not much fun.
> --
> David Portas
> SQL Server MVP
> --
>

Dynamic Columns Report

Hi,
I am trying to design a report with has data for the past 12 months. i.e.
user parameters are Month = 4 & Year = 2005, the report should have columns
from 05/2004 to 04/2005 i.e. past 12 months.
I have managed to get the data using a stored proc, how can get the column
headings to be dynamic ?
something like this
May 2004, June 2004 ........... April 2005
Thanksyou need to use a matrix.
The concept is pretty much easy after you get you head around how a
matrix works. Try a tutorial on how to design a matrix and then give a
go using your data.|||Did you get this to work? I am having the same problem... I don't
understand the matrix suggestion... From what I can tell Matrix
reports still require that you use the Column Headings returned in a
dataset... and they don't change as your data changes.
I guess for a Matrix report you have to flip your time into rows
instead of columns... is that right?
Let me know if you get this working. I am about to pull my hair out.|||I dont think the matrix report is as simple as they make it sound. I would
rather have someone post and tell me how to "simulate" a matrix but the
headings have to be dynamic since I wont know what input parms the user will
enter for the start and end dates - I have to do the past 12 months as well
just like the initial post.
Another issue with matrix is that the columns you use for groups dont have
headers which is strange (at least not when I did the wizard)
"JoelBarish" wrote:
> Did you get this to work? I am having the same problem... I don't
> understand the matrix suggestion... From what I can tell Matrix
> reports still require that you use the Column Headings returned in a
> dataset... and they don't change as your data changes.
> I guess for a Matrix report you have to flip your time into rows
> instead of columns... is that right?
> Let me know if you get this working. I am about to pull my hair out.
>|||hey man, put this in your stored procedure...
DECLARE @.abbrev TABLE(monthid INT, monthname VARCHAR(3))
INSERT INTO @.abbrev
VALUES(1,'Jan')
INSERT INTO @.abbrev
VALUES(2,'Feb')
INSERT INTO @.abbrev
VALUES(3,'Mar')
INSERT INTO @.abbrev
VALUES(4,'Apr')
INSERT INTO @.abbrev
VALUES(5,'May')
INSERT INTO @.abbrev
VALUES(6,'Jun')
INSERT INTO @.abbrev
VALUES(7,'Jul')
INSERT INTO @.abbrev
VALUES(8,'Aug')
INSERT INTO @.abbrev
VALUES(9,'Sep')
INSERT INTO @.abbrev
VALUES(10,'Oct')
INSERT INTO @.abbrev
VALUES(11,'Nov')
INSERT INTO @.abbrev
VALUES(12,'Dec')
and then join the table to your query like:
INNER JOIN @.abbrev a
ON LEFT([yourmonthcolumnname],3) = a.monthname
then in the report for the column header properties - visibility code in
[expression]:
=IIF((Parameters!{yourmonthcolumnname].Value)=0,True,False)
peace out...
"Vishal" wrote:
> Hi,
> I am trying to design a report with has data for the past 12 months. i.e.
> user parameters are Month = 4 & Year = 2005, the report should have columns
> from 05/2004 to 04/2005 i.e. past 12 months.
> I have managed to get the data using a stored proc, how can get the column
> headings to be dynamic ?
> something like this
> May 2004, June 2004 ........... April 2005
> Thanks
>
>

Dynamic columns in RS reports

I have to design a report that will have a dynamic number of columns, in a
dynamic order.
For example: items and a selection from their attributes
ITEM Attr 1 Attr 2
Attr3 Attr 4
I1 5 Realy large text
........................................ Short text
12305
etc...
I know the matrix is used to obtain dynamic number of columns, but the
problem is that the columns in matrix have the same width
and i need different column widths (for text attributes and numeric
attributes for example), and the column width can have only numeric
(and fixed) values - i mean you can put there a function call..
Is there any way other than generating the rdl at run time to obtain such
dynamic table ?
Thanks in advance for any advice.This is not really feasible as far as I can tell, in the way you are
asking.
You can't set column width dynamically, which sounds like a big problem
for you.
But you may be able to get some way towards it if you compromise a
little.
In terms of no. of columns, you'd need to set a maximum number, make
sure you always return that number in the dataset even if they contain
nulls you can then allow for the maximum in your report and just hide
or show them as needed. You'd have to do it this way because you will
be referring to the columns with a field name and the report validates
that those fields will be returned when it renders.
You can then hide table columns or text boxes in a list control based
on the number of columns you're expecting that scenario. You could have
several table columns geared to one dataset column, all set differently
according to data type, then hide the columns that you don't need based
on whats returned in the query.
Chris
Razvan Popov wrote:
> I have to design a report that will have a dynamic number of columns,
> in a dynamic order.
> For example: items and a selection from their attributes
> ITEM Attr 1 Attr 2
> Attr3 Attr 4
> I1 5 Realy large text
> ........................................ Short text
> 12305
> etc...
> I know the matrix is used to obtain dynamic number of columns, but
> the problem is that the columns in matrix have the same width
> and i need different column widths (for text attributes and numeric
> attributes for example), and the column width can have only numeric
> (and fixed) values - i mean you can put there a function call..
> Is there any way other than generating the rdl at run time to obtain
> such dynamic table ?
> Thanks in advance for any advice.|||Thank you for your suggestion. But my problem is a little worse than that:
I don't have a maximum number of columns (the user can add attributes and
select them into the report at runtime).
And if i set a maximum number of X columns as constraint. I don't know which
will be the X attributes the user selected to
be displayed into report and for that I have no way of presetting the width
of the columns (which should be dependent on attribute type)..
I have as the last option to generate dinamically the RDL (or parts of it)
but this is prety complex solution and i would like to be sure that there is
no
simpler solution before i start coding such scenario...
Thx
"Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
news:u%23XoXUncFHA.2436@.TK2MSFTNGP10.phx.gbl...
> This is not really feasible as far as I can tell, in the way you are
> asking.
> You can't set column width dynamically, which sounds like a big problem
> for you.
> But you may be able to get some way towards it if you compromise a
> little.
> In terms of no. of columns, you'd need to set a maximum number, make
> sure you always return that number in the dataset even if they contain
> nulls you can then allow for the maximum in your report and just hide
> or show them as needed. You'd have to do it this way because you will
> be referring to the columns with a field name and the report validates
> that those fields will be returned when it renders.
> You can then hide table columns or text boxes in a list control based
> on the number of columns you're expecting that scenario. You could have
> several table columns geared to one dataset column, all set differently
> according to data type, then hide the columns that you don't need based
> on whats returned in the query.
> Chris|||Razvan,
You've got a pretty complex scenario, I think you're going to need a
complex solution!
It sounds like you're developing a form of end-user report builder?
Have you taken a look at Cizer (www.cizer.com) or Report Builder in
SQL2005?
Chris
Razvan Popov wrote:
> Thank you for your suggestion. But my problem is a little worse than
> that: I don't have a maximum number of columns (the user can add
> attributes and select them into the report at runtime).
> And if i set a maximum number of X columns as constraint. I don't
> know which will be the X attributes the user selected to
> be displayed into report and for that I have no way of presetting the
> width of the columns (which should be dependent on attribute type)..
> I have as the last option to generate dinamically the RDL (or parts
> of it) but this is prety complex solution and i would like to be sure
> that there is no
> simpler solution before i start coding such scenario...
> Thx
>
> "Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
> news:u%23XoXUncFHA.2436@.TK2MSFTNGP10.phx.gbl...
> > This is not really feasible as far as I can tell, in the way you are
> > asking.
> > You can't set column width dynamically, which sounds like a big
> > problem for you.
> >
> > But you may be able to get some way towards it if you compromise a
> > little.
> > In terms of no. of columns, you'd need to set a maximum number, make
> > sure you always return that number in the dataset even if they
> > contain nulls you can then allow for the maximum in your report and
> > just hide or show them as needed. You'd have to do it this way
> > because you will be referring to the columns with a field name and
> > the report validates that those fields will be returned when it
> > renders.
> >
> > You can then hide table columns or text boxes in a list control
> > based on the number of columns you're expecting that scenario. You
> > could have several table columns geared to one dataset column, all
> > set differently according to data type, then hide the columns that
> > you don't need based on whats returned in the query.
> >
> > Chris|||Thank you for your help..
If i find any solution simpler than generating rdls dynamically i'll post it
here..
Razvan

Sunday, February 19, 2012

Dynamic columns in RS reports

I have to design a report that will have a dynamic number of columns, in a
dynamic order.
For example: items and a selection from their attributes
ITEM Attr 1 Attr 2
Attr3 Attr 4
I1 5 Realy large text
........................................ Short text
12305
etc...
I know the matrix is used to obtain dynamic number of columns, but the
problem is that the columns in matrix have the same width
and i need different column widths (for text attributes and numeric
attributes for example), and the column width can have only numeric
(and fixed) values - i mean you can put there a function call..
Is there any way other than generating the rdl at run time to obtain such
dynamic table ?
Thanks in advance for any advice.This is not really feasible as far as I can tell, in the way you are
asking.
You can't set column width dynamically, which sounds like a big problem
for you.
But you may be able to get some way towards it if you compromise a
little.
In terms of no. of columns, you'd need to set a maximum number, make
sure you always return that number in the dataset even if they contain
nulls you can then allow for the maximum in your report and just hide
or show them as needed. You'd have to do it this way because you will
be referring to the columns with a field name and the report validates
that those fields will be returned when it renders.
You can then hide table columns or text boxes in a list control based
on the number of columns you're expecting that scenario. You could have
several table columns geared to one dataset column, all set differently
according to data type, then hide the columns that you don't need based
on whats returned in the query.
Chris
Razvan Popov wrote:
> I have to design a report that will have a dynamic number of columns,
> in a dynamic order.
> For example: items and a selection from their attributes
> ITEM Attr 1 Attr 2
> Attr3 Attr 4
> I1 5 Realy large text
> ........................................ Short text
> 12305
> etc...
> I know the matrix is used to obtain dynamic number of columns, but
> the problem is that the columns in matrix have the same width
> and i need different column widths (for text attributes and numeric
> attributes for example), and the column width can have only numeric
> (and fixed) values - i mean you can put there a function call..
> Is there any way other than generating the rdl at run time to obtain
> such dynamic table ?
> Thanks in advance for any advice.|||Thank you for your suggestion. But my problem is a little worse than that:
I don't have a maximum number of columns (the user can add attributes and
select them into the report at runtime).
And if i set a maximum number of X columns as constraint. I don't know which
will be the X attributes the user selected to
be displayed into report and for that I have no way of presetting the width
of the columns (which should be dependent on attribute type)..
I have as the last option to generate dinamically the RDL (or parts of it)
but this is prety complex solution and i would like to be sure that there is
no
simpler solution before i start coding such scenario...
Thx
"Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
news:u%23XoXUncFHA.2436@.TK2MSFTNGP10.phx.gbl...
> This is not really feasible as far as I can tell, in the way you are
> asking.
> You can't set column width dynamically, which sounds like a big problem
> for you.
> But you may be able to get some way towards it if you compromise a
> little.
> In terms of no. of columns, you'd need to set a maximum number, make
> sure you always return that number in the dataset even if they contain
> nulls you can then allow for the maximum in your report and just hide
> or show them as needed. You'd have to do it this way because you will
> be referring to the columns with a field name and the report validates
> that those fields will be returned when it renders.
> You can then hide table columns or text boxes in a list control based
> on the number of columns you're expecting that scenario. You could have
> several table columns geared to one dataset column, all set differently
> according to data type, then hide the columns that you don't need based
> on whats returned in the query.
> Chris|||Razvan,
You've got a pretty complex scenario, I think you're going to need a
complex solution!
It sounds like you're developing a form of end-user report builder?
Have you taken a look at Cizer (www.cizer.com) or Report Builder in
SQL2005?
Chris
Razvan Popov wrote:
> Thank you for your suggestion. But my problem is a little worse than
> that: I don't have a maximum number of columns (the user can add
> attributes and select them into the report at runtime).
> And if i set a maximum number of X columns as constraint. I don't
> know which will be the X attributes the user selected to
> be displayed into report and for that I have no way of presetting the
> width of the columns (which should be dependent on attribute type)..
> I have as the last option to generate dinamically the RDL (or parts
> of it) but this is prety complex solution and i would like to be sure
> that there is no
> simpler solution before i start coding such scenario...
> Thx
>
> "Chris McGuigan" <chris.mcguigan@.zycko.com> wrote in message
> news:u%23XoXUncFHA.2436@.TK2MSFTNGP10.phx.gbl...
> > This is not really feasible as far as I can tell, in the way you are
> > asking.
> > You can't set column width dynamically, which sounds like a big
> > problem for you.
> >
> > But you may be able to get some way towards it if you compromise a
> > little.
> > In terms of no. of columns, you'd need to set a maximum number, make
> > sure you always return that number in the dataset even if they
> > contain nulls you can then allow for the maximum in your report and
> > just hide or show them as needed. You'd have to do it this way
> > because you will be referring to the columns with a field name and
> > the report validates that those fields will be returned when it
> > renders.
> >
> > You can then hide table columns or text boxes in a list control
> > based on the number of columns you're expecting that scenario. You
> > could have several table columns geared to one dataset column, all
> > set differently according to data type, then hide the columns that
> > you don't need based on whats returned in the query.
> >
> > Chris|||Thank you for your help..
If i find any solution simpler than generating rdls dynamically i'll post it
here..
Razvan

Dynamic Columns & Dynamic Grouping ?

Hi,

We need to design more than 500 Reports for our ongoing project and we are dealing with MS SQL Server Reporting Services first time. We are currently confused in 2 things

1) How to manage Reports? I mean we should store entire report in database and load at runtime or simply store as a report file

2) Most Important is Dynamic Columns & Dynamic Grouping.

We need something like Microsoft Office Accounting 2007 Reports. Header part of form has some parameters for filter and right part has some parameters for showing or hiding and reordering columns and groups.


We are not getting clue for this dynamic stuff. Can any one post working sample or at least necessary basic code with some idea?

Reply on Urgent Basis

Thanks lot

Someone Please Help

If I have posted in wrong forum then suggest the correct one.

Wednesday, February 15, 2012

DW/DSS Schema design

I know a data warehouse stores historical data and the fact and dimension
tables could be huge with billion rows and could be more than 100s of GB in
size for just one table. Can someone share some design tips on whether they
partition those fact tables based upon time and then maybe use some
partitioned views to access it.
Im just looking at it from performance and also scalability.. and if we do
create those multiple partitioned tables on different filegroups stored on
different drive.. This is just one way I can see it done.. Is this approach
right and do people use it ? Also, what other ways can we scale and have
better performance. Any good DW design URLs i can refer to..
Thanks a lot in advance..
Hi
http://www.microsoft.com/sql/techinf...calability.asp
"VLDB's"
http://www.microsoft.com/sql/evaluation/bi/default.asp "Implementation
Considerations"
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#gnvjMMLFHA.2120@.TK2MSFTNGP10.phx.gbl...
> I know a data warehouse stores historical data and the fact and dimension
> tables could be huge with billion rows and could be more than 100s of GB
in
> size for just one table. Can someone share some design tips on whether
they
> partition those fact tables based upon time and then maybe use some
> partitioned views to access it.
> Im just looking at it from performance and also scalability.. and if we do
> create those multiple partitioned tables on different filegroups stored on
> different drive.. This is just one way I can see it done.. Is this
approach
> right and do people use it ? Also, what other ways can we scale and have
> better performance. Any good DW design URLs i can refer to..
> Thanks a lot in advance..
>

DW/DSS Schema design

I know a data warehouse stores historical data and the fact and dimension
tables could be huge with billion rows and could be more than 100s of GB in
size for just one table. Can someone share some design tips on whether they
partition those fact tables based upon time and then maybe use some
partitioned views to access it.
Im just looking at it from performance and also scalability.. and if we do
create those multiple partitioned tables on different filegroups stored on
different drive.. This is just one way I can see it done.. Is this approach
right and do people use it ? Also, what other ways can we scale and have
better performance. Any good DW design URLs i can refer to..
Thanks a lot in advance..Hi
http://www.microsoft.com/sql/techinfo/administration/2000/scalability.asp
"VLDB's"
http://www.microsoft.com/sql/evaluation/bi/default.asp "Implementation
Considerations"
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#gnvjMMLFHA.2120@.TK2MSFTNGP10.phx.gbl...
> I know a data warehouse stores historical data and the fact and dimension
> tables could be huge with billion rows and could be more than 100s of GB
in
> size for just one table. Can someone share some design tips on whether
they
> partition those fact tables based upon time and then maybe use some
> partitioned views to access it.
> Im just looking at it from performance and also scalability.. and if we do
> create those multiple partitioned tables on different filegroups stored on
> different drive.. This is just one way I can see it done.. Is this
approach
> right and do people use it ? Also, what other ways can we scale and have
> better performance. Any good DW design URLs i can refer to..
> Thanks a lot in advance..
>

DW/DSS Schema design

I know a data warehouse stores historical data and the fact and dimension
tables could be huge with billion rows and could be more than 100s of GB in
size for just one table. Can someone share some design tips on whether they
partition those fact tables based upon time and then maybe use some
partitioned views to access it.
Im just looking at it from performance and also scalability.. and if we do
create those multiple partitioned tables on different filegroups stored on
different drive.. This is just one way I can see it done.. Is this approach
right and do people use it ? Also, what other ways can we scale and have
better performance. Any good DW design URLs i can refer to..
Thanks a lot in advance..
Hi
http://www.microsoft.com/sql/techinf...calability.asp
"VLDB's"
http://www.microsoft.com/sql/evaluation/bi/default.asp "Implementation
Considerations"
Regards
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#gnvjMMLFHA.2120@.TK2MSFTNGP10.phx.gbl...
> I know a data warehouse stores historical data and the fact and dimension
> tables could be huge with billion rows and could be more than 100s of GB
in
> size for just one table. Can someone share some design tips on whether
they
> partition those fact tables based upon time and then maybe use some
> partitioned views to access it.
> Im just looking at it from performance and also scalability.. and if we do
> create those multiple partitioned tables on different filegroups stored on
> different drive.. This is just one way I can see it done.. Is this
approach
> right and do people use it ? Also, what other ways can we scale and have
> better performance. Any good DW design URLs i can refer to..
> Thanks a lot in advance..
>

DW/DSS Schema design

I know a data warehouse stores historical data and the fact and dimension
tables could be huge with billion rows and could be more than 100s of GB in
size for just one table. Can someone share some design tips on whether they
partition those fact tables based upon time and then maybe use some
partitioned views to access it.
Im just looking at it from performance and also scalability.. and if we do
create those multiple partitioned tables on different filegroups stored on
different drive.. This is just one way I can see it done.. Is this approach
right and do people use it ? Also, what other ways can we scale and have
better performance. Any good DW design URLs i can refer to..
Thanks a lot in advance..Hi
http://www.microsoft.com/sql/techin...scalability.asp
"VLDB's"
http://www.microsoft.com/sql/evaluation/bi/default.asp "Implementation
Considerations"
Regards
--
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
IM: mike@.epprecht.net
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"Hassan" <fatima_ja@.hotmail.com> wrote in message
news:#gnvjMMLFHA.2120@.TK2MSFTNGP10.phx.gbl...
> I know a data warehouse stores historical data and the fact and dimension
> tables could be huge with billion rows and could be more than 100s of GB
in
> size for just one table. Can someone share some design tips on whether
they
> partition those fact tables based upon time and then maybe use some
> partitioned views to access it.
> Im just looking at it from performance and also scalability.. and if we do
> create those multiple partitioned tables on different filegroups stored on
> different drive.. This is just one way I can see it done.. Is this
approach
> right and do people use it ? Also, what other ways can we scale and have
> better performance. Any good DW design URLs i can refer to..
> Thanks a lot in advance..
>

DW design question - Dimension for currency

Hi everybody,
I struggle with a DW design issue that I hope somebody can provide a
solution for?
I have a traditional Star Schema, and are building an OLP cube on top. The
development is taken place using SQL Server 2005.
For the purpose of this question, the layout is the following:
Dimension tables:
Time: Transaction date, week, month, etc.
Product: Product Category, Product Line, Product.
Customer: Customer, Customer Segment, etc.
Fact table:
Sales: Transaction date, Customer, Product, Price, Currency, price in
currency, Exchange rate.
Requirement:
I am looking for sales by product by customer/product etc. (This is not a
problem). However, each of the sales transactions is made in a particular
currency. For example is sales transaction 1 in Euro and transaction 2 is in
British Pounds. Both transactions are for Product A. On top of the existing
dimensions, I need to see each of the sales transactions in a given currency
and exchange rate (for example Actual or budgeted exchange rate).
One scenario could be to see the value of sales by product (Product A) in
Euro. In this case will transaction 2 that was made in GBP have to be
converted to EUR, so I can see total sales for product A in Euro.
Solution so far:
So far, have I have added the combination of exchange rate and currency to
the fact table. For example, the transaction in currency "GBP" and "EUR" for
both the exchange rate "Actual" and "Budget2005". This gives 4 entries for
each sales transaction in the fact table. This does NOT work... Selecting on
the dimension tables, for example on the product lead to the value of the 4
transactions to be added together. :-( Where in fact I only want the unique
transaction based on dimension and chosen Currency and Exchange rate.
I have considered making another dimension for Currency and Exchange rate,
but it is not possible to create a relationship to the fact table as the
values Currency and Exchange rate can not make a unique relation to the fact
table.
So far my best bet is only to have one unique entry of the sales transaction
in the original currency in the Fact table. But how do I then make it
possible to see the sales transaction by relevant dimension in the chosen
Currency and Exchange rate?
Look forward to hearing from you.
Best Regards,
Bigalexx
Hi Bigalexx,
Thanks for your post.
This question appears to be consulting in nature. We would also like to
introduce you to the CSS Advisory Services team.
Advisory Services is a remotely delivered, hourly fee-based, consultative
support option that provides a comprehensive result beyond your break-fix
product maintenance needs. It is an hourly fee-based, consultative
support option that provides proactive support beyond your break-fix
product maintenance needs. This support option includes working with the
same technician for assistance with issues like product migration, code
review, or new program development.
For more info in the US and Canada:
http://support.microsoft.com/default...dvisoryService
Outside of the US/Canada:
http://support.microsoft.com/default...rnational.aspx
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.
|||Hi Bigalexx,
>From your question I am guessing you are a beginner....
I have a beginners page on my web site www.peternolan.com with links on
the books to read to learn data modeling for BI systems......if you
are struggling with the multi-country, multi-currency pieces of a model
you would greatly improve your skills by reading some of ralphs books
and looking at the databases on the CD in the back.....
My personal home page is intended as a resource for beginners...so if
you (or others here) have opinions on what else is useful for beginners
I'd be happy for feedback and to put things onto my list of things to
publish...
Good luck!!
Peter
www.peternolan.com

DW design question - Dimension for currency

Hi everybody,
I struggle with a DW design issue that I hope somebody can provide a
solution for?
I have a traditional Star Schema, and are building an OLP cube on top. The
development is taken place using SQL Server 2005.
For the purpose of this question, the layout is the following:
Dimension tables:
Time: Transaction date, week, month, etc.
Product: Product Category, Product Line, Product.
Customer: Customer, Customer Segment, etc.
Fact table:
Sales: Transaction date, Customer, Product, Price, Currency, price in
currency, Exchange rate.
Requirement:
I am looking for sales by product by customer/product etc. (This is not a
problem). However, each of the sales transactions is made in a particular
currency. For example is sales transaction 1 in Euro and transaction 2 is in
British Pounds. Both transactions are for Product A. On top of the existing
dimensions, I need to see each of the sales transactions in a given currency
and exchange rate (for example Actual or budgeted exchange rate).
One scenario could be to see the value of sales by product (Product A) in
Euro. In this case will transaction 2 that was made in GBP have to be
converted to EUR, so I can see total sales for product A in Euro.
Solution so far:
So far, have I have added the combination of exchange rate and currency to
the fact table. For example, the transaction in currency "GBP" and "EUR" for
both the exchange rate "Actual" and "Budget2005". This gives 4 entries for
each sales transaction in the fact table. This does NOT work... Selecting on
the dimension tables, for example on the product lead to the value of the 4
transactions to be added together. :-( Where in fact I only want the unique
transaction based on dimension and chosen Currency and Exchange rate.
I have considered making another dimension for Currency and Exchange rate,
but it is not possible to create a relationship to the fact table as the
values Currency and Exchange rate can not make a unique relation to the fact
table.
So far my best bet is only to have one unique entry of the sales transaction
in the original currency in the Fact table. But how do I then make it
possible to see the sales transaction by relevant dimension in the chosen
Currency and Exchange rate?
Look forward to hearing from you.
Best Regards,
BigalexxHi Bigalexx,
Thanks for your post.
This question appears to be consulting in nature. We would also like to
introduce you to the CSS Advisory Services team.
Advisory Services is a remotely delivered, hourly fee-based, consultative
support option that provides a comprehensive result beyond your break-fix
product maintenance needs. It is an hourly fee-based, consultative
support option that provides proactive support beyond your break-fix
product maintenance needs. This support option includes working with the
same technician for assistance with issues like product migration, code
review, or new program development.
For more info in the US and Canada:
http://support.microsoft.com/defaul...AdvisoryService
Outside of the US/Canada:
http://support.microsoft.com/defaul...ernational.aspx
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know. We are always here to be of
assistance!
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Bigalexx,
>From your question I am guessing you are a beginner....
I have a beginners page on my web site www.peternolan.com with links on
the books to read to learn data modeling for BI systems......if you
are struggling with the multi-country, multi-currency pieces of a model
you would greatly improve your skills by reading some of ralphs books
and looking at the databases on the CD in the back.....
My personal home page is intended as a resource for beginners...so if
you (or others here) have opinions on what else is useful for beginners
I'd be happy for feedback and to put things onto my list of things to
publish...
Good luck!!
Peter
www.peternolan.com