Beruflich Dokumente
Kultur Dokumente
Copyright
2009 SAP BusinessObjects. All rights reserved. SAP BusinessObjects owns the following United States patents, which may cover products that are offered and licensed by SAP BusinessObjects and/or affliated companies: 5,295,243; 5,339,390; 5,555,403; 5,590,250; 5,619,632; 5,632,009; 5,857,205; 5,880,742; 5,883,635; 6,085,202; 6,108,698; 6,247,008; 6,289,352; 6,300,957; 6,377,259; 6,490,593; 6,578,027; 6,581,068; 6,628,312; 6,654,761; 6,768,986; 6,772,409; 6,831,668; 6,882,998; 6,892,189; 6,901,555; 7,089,238; 7,107,266; 7,139,766; 7,178,099; 7,181,435; 7,181,440; 7,194,465; 7,222,130; 7,299,419; 7,320,122 and 7,356,779. SAP BusinessObjects and its logos, BusinessObjects, Crystal Reports, Rapid Mart, Data Insight, Desktop Intelligence, Rapid Marts, Watchlist Security, Web Intelligence, and Xcelsius are trademarks or registered trademarks of Business Objects, an SAP company and/or affiliated companies in the United States and/or other countries. SAP is a registered trademark of SAP AG in Germany and/or other countries. All other names mentioned herein may be trademarks of their respective owners.
C O N T E N T S
About this Course
Course introduction.....................................................................................................xi Course description......................................................................................................xii Course audience..........................................................................................................xii Prerequisites.................................................................................................................xii Level, delivery, and duration....................................................................................xii Applicable certifications and designations..............................................................xii Course success factors...............................................................................................xiii Course setup...............................................................................................................xiii Course materials.........................................................................................................xiii Learning process.........................................................................................................xiii
Lesson 1
Lesson 2
iii
Activity: Setting up aggregate awareness - part 1...........................................20 Activity: Setting up aggregate awareness - part 2...........................................22 Using aggregate awareness to resolve fan traps..............................................23 Outer joins and aggregate awareness...............................................................25 Quiz: Working with aggregate awareness...............................................................28 Lesson summary..........................................................................................................29
Lesson 3
Lesson 4
iv
Conditional joins and running calculations.....................................................78 Activity: Using complex joins.............................................................................80 Quiz: Creating complex predefined conditions and LOVs...................................84 Lesson summary..........................................................................................................85
Lesson 5
Securing Universes
Lesson introduction.....................................................................................................87 Defining connection and user credential parameters.............................................88 About security and universes ............................................................................88 User credentials for the connection ..................................................................88 Working with Central Management Server (CMS) universe security.................90 Organizing universes in secured folder structures ........................................90 Working with table mapping in restriction sets......................................................92 About restriction sets...........................................................................................92 Working with table mapping.............................................................................93 Activity: Working with table mapping in a restriction set.............................96 Quiz: Securing universes............................................................................................99 Lesson summary........................................................................................................100
Lesson 6
Lesson 7
Dynamic SQL parameters.................................................................................126 Adapting dynamic SQL parameters................................................................127 BEGIN_SQL........................................................................................................127 END_SQL............................................................................................................127 ANSI92 and FILTER_IN_FROM .....................................................................128 About ANSI92 SQL syntax ..............................................................................129 The ANSI92 dynamic SQL parameter.............................................................130 Applying the FILTER_IN_FROM functionality to individual classes and objects...................................................................................................................131 The JOIN_BY_SQL parameter..........................................................................135 Activity: Using dynamic SQL parameters......................................................136 Applying index awareness ......................................................................................139 What is index awareness? ................................................................................139 Avoiding joins in tables.....................................................................................140 Multiple foreign key entries.............................................................................141 SQL Editor dialog box ......................................................................................143 Using an index awareness WHERE clause.....................................................143 Applying best practices for universe design.........................................................144 Best practices for designing and optimizing your universe........................144 Quiz: Maintaining and optimizing universes........................................................147 Lesson summary........................................................................................................148
Lesson 8
vi
Appendix A
Appendix B
Appendix C
External Strategies
Using external strategies in Universe Designer....................................................185 Types of strategies.....................................................................................................187
Appendix D
Answer Key
Review: Using universe design concepts...............................................................203 Quiz: Working with aggregate awareness.............................................................207 Quiz: Designing advanced objects..........................................................................208 Quiz: Creating complex predefined conditions and LOVs.................................209 Quiz: Securing universes..........................................................................................210 Quiz: Implementing universe life cycle management..........................................211 Quiz: Maintaining and optimizing universes........................................................212 Quiz: Creating universes from other data sources...............................................213
vii
viii
AgendaLearners Guide
ix
Lesson 7
xi
Course description
This two-day instructor-led advanced course is designed to give you the comprehensive skills and in-depth knowledge needed to design universes in BusinessObjects Universe Designer. The business benefit of this course is that you will learn best-practice methodology for creating universes that respond to your reporting requirements. Through well-designed universes, report designers and business users will be able to create reports without having to know anything about the underlying data source or structure.
Course audience
The target audience for this course is anyone responsible for creating and designing universes using Universe Designer, using BusinessObjects XI 3.0/3.1. The learners who attend the course will be most successful if they have experience in working with Business Objects Universe Designer. New features covered in the XI 3.0/3.1 course that are not applicable to BusinessObjects XI R1/R2 learners include: Creating universes from stored procedures and JavaBeans Creating, modifying, and updating universes from OLAP data sources using the enhanced OLAP functionality in Universe Designer
Prerequisites
To be successful, learners who attend this course should have attended the following offerings: BusinessObjects XI R2: Universe Design, and/or BusinessObjects XI 3.0/3.1: Universe Design BusinessObjects Web Intelligence XI R2: Report Design, and/or BusinessObjects Web Intelligence XI 3.0/3.1: Report Design To be successful, you must be familiar with: The metadata and logical structure of the databases in your organization BusinessObjects Web Intelligence report building Using BusinessObjects Universe Designer Using and working with SQL and relational database management systems concepts and structures The BusinessObjects Central Management Console
xii
Course setup
Refer to the setup guide for details on hardware, software, and course-specific requirements.
Course materials
The materials included with the course materials are: Name card Learners Guide The Learners Guide contains an agenda, learner materials, and practice activities. The Learners Guide is designed to assist students who attend the classroom-based course and outlines what learners can expect to achieve by participating in this course. Evaluation form At the conclusion of this course, you will receive an electronic feedback form as part of our evaluation process. Provide feedback on the course content, instructor, and facility. Your comments will assist us to improve future courses. Additional resources include: Sample files The sample files can include required files for the course activities and/or supplemental content to the training guide. Online Help Retrieve information and find answers to questions using the online Help and/or users guide that are included with the product.
Learning process
Learning is an interactive process between the learners and the instructor. By facilitating a cooperative environment, the instructor guides the learners through the learning framework.
Introduction
Why am I here? Whats in it for me? The learners will be clear about what they are getting out of each lesson.
xiii
Objectives
How do I achieve the outcome? The learners will assimilate new concepts and how to apply the ideas presented in the lesson. This step sets the groundwork for practice.
Practice
How do I do it? The learners will demonstrate their knowledge as well as their hands-on skills through the activities.
Review
How did I do? The learners will have an opportunity to review what they have learned during the lesson. Review reinforces why it is important to learn particular concepts or skills.
Summary
Where have I been and where am I going? The summary acts as a recap of the learning objectives and as a transition to the next section.
xiv
Lesson 1
Instructions
1. What is a universe? 2. Does a universe store data? 3. What are the main advantages of a universe? 4. Describe the connection types and their purposes. 5. What are the types of objects that can be created in a universe? Provide a brief description of each type. 6. What are the different join types allowed in the universe structure. Provide a short description of each type. 7. What are the different types of SQL traps that can be found in a schema? How can each of these types be identified? How can each type be resolved in the universe schema? 8. What are loops and how can they be resolved? 9. Describe how you would test a measure to make sure the aggregation levels are projected correctly. 10.Explain two drawbacks of using restrictions at the object level. 11.Describe the use of the @select function. 12.What is a hierarchy? 13.Describe what a derived table is and how it is generally used in a universe schema. 14.Describe what index awareness is, and how it is used in a universe schema. 15.What are the pros and cons of delegated functionality in a universe-based reporting structure?
Instructions
The project team is asked to design a universe solution for the Island Resorts Company. The project team made the following findings during the preparation, analysis, and planning phases, and are now preparing for the implementation stage. The Island Resorts Company requires an ad-hoc reporting system for their resort locations. There are five holiday destinations; Royal Caribbean, Hawaiian Club, French Riviera, Bahamas Beach, and Australian Reef. Standards Customers and clients are referred to as guests. Database design specifics The database has six years of data: 2004 - 2006 for current bookings, 2007 - 2009 for reservations. Objects and filters Condition objects are required for the three years of guests, the three years for reservations, the location, guests under the age of 30, and guests from the US. Dates are to be reported on as year, quarter, month, week, and invoice or reservation date. Measures are for future guests, current guests, and also for revenue. Customer information for reporting is hierarchical, and should include the customer's age group. Some personal details of customers are also required for reporting. 1. Start a Universe Designer session and log on using the credentials provided by the instructor. 2. Create a new blank universe called TravelClub _xx, where "xx" stands for your initials. 3. Create a new OLE DB connection called ClubOLEDB_xx, where "xx" stands for your initials. a. Select File Parameters Definition, and then click New below the Connection field. b. Click Next. c. Select Secured from the Connection Type drop-down list. d. In the Connection Name field, type ClubOLEDB_xx, where "xx" stands for your initials. e. Expand the Microsoft node, which is the target database for the connection. f. Expand the MS SQL Server 2005 node, which is the target middleware for the connection. g. Select the OLE DB Providers driver name and click Next. h. Select Use specified username and password as the authentication mode. i. In the User name and Password fields enter the database login credentials. Use the SQL Server database server credentials, as provided to you by the instructor.
j. In the Server field, select or enter the appropriate SQL Server name to connect to, as provided to you by the instructor. k. In the Database field, enter Club, the name of the database you are connecting to. l. Click Next twice, and click Finish. m. In the Wizard Connection dialog box, click Test to test the connection. If the connection is valid, a message dialog box appears, indicating that the connection is correct. If you receive an error message, check that you entered all the parameters correctly. n. Click Finish to exit the wizard. 4. Insert the tables outlined in the diagram:
5. Create classes to hold objects for measures, reservations, customers, sales, and resorts. Most objects are dimensions, except for those in the measures class. The use of details is for personal information on the client only. 6. Check for chasm traps, fan traps, and loops, and resolve them accordingly. 7. Save your universe locally. 8. Test your universe by building queries in Web Intelligence Rich Client. a. Launch Web Intelligence Rich Client. Go to Start Programs BusinessObjects XI 3.0/3.1 BusinessObjects Enterprise Web Intelligence Rich Client. b. Log on using the credentials provided by the instructor. c. Select the create a new document based on a data source icon. d. Select Browse for more data sources. e. Select Universe, and click Next. f. Select your TravelClub universe, and click OK.
g. Build a new query using the objects you have created. Drag and drop the objects into the Result Objects pane. h. Click Run Query to view the final results displayed in the report. 9. Run appropriate reports in Web Intelligence Rich Client to: Identify number of guests who have stayed by time period as well as by country of origin. Identify number of guests by each location, listing the services. Determine the revenue generated by time period. Identify whether customers are from the US or whether they are under the age of 30. A requirement exists to identify Americans who are under the age of 30 separately from other guests. Identify the different services available at each location. The services could be accommodation, amenities, or activities. Report on the number of guests by age group for the time period 2004 to 2006. Report on the number of guests by age group for the time period 2007 to 2009.
Assumptions
There has been no inflation over the different years for which data is held. There is no stock data. All manufacturers are able to supply on demand. Users in all countries use the same currency (the US dollar). No new models have been brought out during the period.
In the BusinessObjects XI 3.0/3.1: Universe Design course, the MotorsOLEDB connection was created to connect to the Motors SQL Server 2005 database. The Motors universe file was initially populated only with sales data, and further extended to rental data later on in the course. The rental data was brought in based on a sale alias table. Adding the rental data created loops in the schema that were resolved using contexts and aliases. Dimension and measure objects were created for sales and rental reporting needs. Hierarchies were established to allow end user to drill in reports. To cross reference objects, @functions were used to reuse existing objects, and avoid creating the same object requirements in the universe. Condition objects and restrictions sets were defined to restrict data returned in reports, and to add security to the universe. Primary key indexes were applied and some derived tables were introduced into the universe structure. A Staff universe was developed to comply with reporting needs to report on employee and manager data. To merge the staff and motors data into one universe schema, the Motors and Staff universes were linked. The dynamic link was broken to embed the Staff data into the Motors universe structure.
Instructions
The Motors universe is built throughout the BusinessObjects XI 3.0/3.1: Universe Design course. This course builds on the final universe file from the BusinessObjects XI 3.0/3.1: Universe Design course. If this course is taught separate from the core Universe Design course, the final version of the BusinessObjects XI 3.0/3.1: Universe Design course needs to be deployed using the steps outlined in this activity. 1. In Universe Designer, open the Motors universe file provided in the Activity_Resources Motors_start folder in the course resources. 2. Rename the universe to Motors_xx, where "xx" stands for your initials. 3. Create a new OLE DB connection called MotorsOLEDB_xx, where "xx" stands for your initials. a. Select File Parameters Definition, and then click New below the Connection field. b. Click Next. c. Select Secured from the Connection Type drop-down list. d. In the Connection Name field, type MotorsOLEDB_xx, where "xx" stands for your initials. e. Expand the Microsoft node, which is the target database for the connection. f. Expand the MS SQL Server 2005 node, which is the target middleware for the connection. g. Select the OLE DB Providers driver name and click Next. h. Select Use specified username and password as the authentication mode. i. In the User name and Password fields enter the database login credentials. Use the SQL Server database server credentials, as provided to you by the instructor. j. In the Server field, select or enter the appropriate SQL Server name to connect to, as provided to you by the instructor. k. In the Database field, enter Motors, which is the name of the database you are connecting to. l. Click Next twice, and click Finish. m. In the Wizard Connection dialog box, click Test to test the connection. If the connection is valid, a message dialog box appears indicating that the connection is correct. If you receive an error message, check that you entered all the parameters correctly. n. Click Finish to exit the wizard. 4. Select File Save As to save your Motors universe version locally.
Lesson summary
After completing this lesson, you are now able to: Use your universe design and BusinessObjects Universe Designer knowledge to solve business problems Describe the course universe, database data, and structure
10
Lesson 2
11
Summary tables
Each row in a summary table is made up of columns containing: Aggregated data: Numeric event data aggregated to a higher level. In the example table image, columns containing aggregated data are Annual_Sale_Value, Annual_Sale_Cost, Annual_Sale_Number, Annual_Rent_Value, and Annual_Rent_Number. Dimension data: Attributes defining the level of the aggregated data.
12
In this example, there is only one column containing dimension data: FP_Year. Foreign keys (optional): Joins to other tables. If these exist, queries can be made using summary table aggregated data on the basis of dimension objects held in other tables of the database, as opposed to just those contained within the summary table itself.
Within Business Objects end-user querying tools, columns containing aggregated and dimension data are incorporated into objects using the @function called @aggregate_aware. Foreign keys are used to set joins in the structure of the universe. Note: Aggregate awareness works on all tables, not just fact tables. It can also be applied to all object types with all data types, not just numbers and measures.
You can see in the example diagram that making a query based on event data at a transaction level requires a more complex SELECT statement and the processing of more database rows than one based on summary data. Aggregates of a normalized database are based on event/fact level data:
13
Summary tables can be added to a database that hold data at a higher level of aggregate:
Making use of summary table data speeds up response times because: There are fewer rows to process. Fewer, if any, joins are required.
14
To detect contexts
Step 2 of the aggregate awareness process is to detect contexts.
15
After you add the summary table, several new loops may exist. You need to resolve these using contexts. 1. Click Detect Contexts on the toolbar. 2. Accept the new contexts and rename them if required.
16
Each aggregation level SELECT statement is separated by a comma, and the entire expression is enclosed in brackets. The final SELECT statement must be valid for all queries. The @aggregate_aware function is directing the query engine to use the sum of the measure value taken from the summary table where possible and, where not possible, to use the next segment in the SELECT statement. The last segment in the @aggregate_aware function is always the original SELECT that does not use the summary tables. For example:
@aggregate_aware(sum(ANNUAL_FIGURES.ANNUAL_SALE_COST), sum(SALE_MODEL.SALE_QTY*MODEL.MODEL_COST))
Similarly, for dimension objects in the summary tables, the @aggregate_aware function simply selects the column from the summary tables first (in descending order of aggregation), and then from the normal source. For example:
@aggregate_aware(ANNUAL_FIGURES.FP_YEAR, FINANCE_PERIOD.FP_YEAR)
When you have redefined all the objects, the next step is to set when Web Intelligence or Web Intelligence Rich Client can use the summary tables, by defining which dimension and measure objects are, or are not compatible with the summary tables.
17
All objects that infer columns from tables in the same context as the summary table can automatically be deemed compatible with the summary table. However, a summary table that does not contain any foreign keys cannot be joined to other tables and cannot be part of a context. In that case, any query that contains objects from the summary table and from other tables produces a Cartesian product. Therefore, all objects based on columns from any other table are deemed incompatible. You set incompatible objects using the Aggregate Navigation tool.
18
In the Aggregate Navigation dialog box you can set the objects and conditions identified in step 2 and 3 as incompatible or compatible. 5. Select the summary table in the Universe Tables pane. The right pane shows the list of classes and objects that need to be checked for compatibility for the summary table you selected. 6. Open each class in turn and select the check box adjacent to each object that is incompatible with the summary table and its context.
19
Use your familiarity with the universe to check that objects shown as compatible (that is, not checked) operate correctly and not produce Cartesian products or an incompatible combination of objects. 7. If an object is set incorrectly, clear the object by clicking it. 8. When you are satisfied with all incompatibility settings, click OK to close the Aggregate Navigation dialog box.
Instructions
Prestige Motors management is finding that the annual and quarterly reports take a long time to run. They have requested that these reports be produced without any noticeable processing delay. Insert the ANNUAL_FIGURES and QUARTER_FIGURES summary tables into your Motors universe and make the universe aggregate aware. Note: The steps in the activity represent some of the steps demonstrated by the instructor in the classroom. 1. In Universe Designer, open your Motors universe file. 2. Incorporate the ANNUAL_FIGURES summary table in your Motors universe and apply aggregate awareness as follows: a. Insert the ANNUAL_FIGURES table in the structure of the universe and insert the following joins and set cardinality.
SHOWROOM.SHOWROOM_ID = ANNUAL_FIGURES.SHOWROOM_ID (1:N) MAKER.MAKER_ID = ANNUAL_FIGURES.SHOWROOM_ID (1:N)
b. Detect contexts. Note: In this instance, the new joins and tables do not affect existing contexts. Do not delete or overwrite the existing contexts. c. Redefine the SELECT properties of the objects as indicated below: Rental Revenue
@aggregate_aware(sum(ANNUAL_FIGURES.ANNUAL_RENT_VALUE), sum(RENTAL.DAYS_RENTED * RENTAL_MODEL.SALE_QTY * MODEL.MODEL_DAYRENT *((100 - RENTAL.SALE_DISCOUNT) / 100)))
20
Sales Revenue
@aggregate_aware(sum(ANNUAL_FIGURES.ANNUAL_SALE_VALUE), sum(SALE_MODEL.SALE_QTY * MODEL.MODEL_PRICE * ((100 - SALE.SALE_DISCOUNT) / 100)))
Financial Year
@aggregate_aware(ANNUAL_FIGURES.FP_YEAR,FINANCE_PERIOD.FP_YEAR)
d. Set incompatible objects manually by using Aggregate Navigation and check the results. Note: Define the Franchises object as incompatible. 3. Save the changes and test the annual level of aggregate awareness by making these queries in Web Intelligence Rich Client. Use the following objects in your query: Showroom, Financial Year, Sales Revenue, and Rental Revenue. Model, Financial Year, Sales Revenue, and Rental Revenue. Financial Year, Sales Revenue, and Financial Month. Ensure you view the inferred SQL in each instance. 4. Incorporate the QUARTER_FIGURES summary table in the Motors universe and apply aggregate awareness. Tip: You need to edit the @aggregate_aware syntax in the objects listed in step 2 to include the quarter level. In addition you need to apply the @aggregate_aware function to the Financial Quarter object. 5. Set incompatible objects manually by using Aggregate Navigation and check the results. Note: Define the Franchises object as incompatible. 6. Save the changes and test the quarter level of aggregate awareness by making three more queries in Web Intelligence Rich Client. Use the following objects in your query: Financial Year and Rental Revenue. Financial Year, Financial Quarter, and Rental Revenue. Financial Year, Financial Month, and Rental Revenue. 7. Test that the objects that are incompatible with both the ANNUAL_FIGURES and QUARTER_FIGURES summary tables infer SQL at the fact table level.
21
Instructions
The DBA has created some aggregate tables in SQL Server Management Studio in the form of Views. The Views are to demonstrate the concept of Data Warehouse aggregate tables. Apply an aggregate awareness solution in your Motors universe, using the Views provided. These tables are incorporated into the schema as standalone tables. 1. In Universe Designer, open your Motors universe. 2. Incorporate the three summary tables (Views) in your Motors universe as standalone tables. View table values to verify that data is returned.
3. In the Sales Details class, add a new object called Order Count. Use the select statement:
count(SALE.SALE_ID)
4. Implement aggregate awareness to the objects in the Sales Dates class. Open the Sales Year Object. Modify the SELECT statement, applying the @aggregate_aware function:
@aggregate_aware(YEAR_ORDERCOUNT.Year, YEAR_QUARTER_ORDERCOUNT.Year, YEAR_QUARTER_MONTH_ORDERCOUNT.Year, {fn year( SALE.SALE_DATE )})
5. Parse the Sales Year object to verify the modified SQL syntax.
22
6. Apply aggregate awareness to the Sales Quarter and Sales Month objects. The SQL used reflects similar syntax as applied in the Sales Year object. Parse the modified objects to verify that there are no errors in the SQL syntax. 7. Implement aggregate awareness to the Order Count object created in the Sales Details class. Parse the modified object syntax to ensure that there are no errors. 8. Set incompatibilities. 9. From the Tools menu launch the Query Panel. Run a query with Sales Year and Order Count. 10.Click the SQL icon. What is the result? Is this as expected, and why? 11.Edit the query and add the Sales Quarter object. Check the generated SQL. What is the result? Is this as expected, and why? 12.Edit the query and add the Sales Month object. Check the generated SQL. What is the result? Is this as expected, and why? 13.Run a new query in the Universe Designer Query Panel, using the Sale Date and Order Count objects. Check the generated SQL. What is the result? Is this as expected, and why?
23
24
After you have modified the universe by making one or more objects aggregate aware, as with any universe element, you must always test the results by building queries. To test the universe, build a query that uses the aggregated measures from table A. Use both compatible objects and incompatible objects in different queries to make sure all levels of aggregate awareness are operating correctly.
25
Initially, this appears to be perfectly in order, if the user creates a query using the Region and Client tables, they get back a list of Regions and Clients. The outer join specifies that the query returns all regions, even if there are no clients. The problem arises if the Sale table is included in the query. Effectively, the user asks the query to generate SQL joining an equi-join (from Sale) to a potentially blank row (no Client for an existing Region). The SQL may look correct, but depending on the RDBMS, the BusinessObjects querying tool may generate an error or produce incorrect results. In SQL Server the correct results are returned, however in Oracle no null values are retrieved, and in some databases, MS Access for example, an ambiguous join error is produced at query level. If this issue occurs with the RDBMS used, then there are two ways of solving this: 1. Do not use outer joins in your universe. This would not be practical if the users require blank rows to be returned. 2. Create an alias of the table where the outer join is required, and use aggregate aware in the relevant object(s) to identify which route to take when the user creates the query. Note: Depending on the RDBMS, the outer join placement may be different. In this example, the Client table is aliased, and the outer join is placed between the Region and the Client alias table. The outer join is now at the end of the path. The Region table has an equi-join to the original Client table.
26
This is only half of the solution; the object needs to be changed, so that when the user creates the query and places, for example, the Client name object in the query, Universe Designer knows it has a choice of tables to get the information from - Client or Client2.
@aggregate_aware(CLIENT2.CLIENT_NAME,CLIENT.CLIENT_NAME)
Having told the object that it has two tables to get the same information from, the final step is to tell Universe Designer when to use which table - the Client or the Client2 alias. Using the Aggregate Navigation tool, the Client2 table needs to be made incompatible with any objects from the Sale table. By setting this, whenever a query is created using the Sale Type or Sale Total objects, Universe Designer cannot use the Client2 table (and therefore the outer join). However, if these objects are not included, then the Client2 table (and the outer join) is used.
27
28
Lesson summary
After completing this lesson, you are now able to: Define aggregate awareness Apply aggregate awareness to objects
29
30
Lesson 3
31
When working in Universe Designer, besides from selecting functions from the list, you can add SQL functions directly into the Select field of an object, provided that the underlying data source supports the SQL function used. This section looks at some of the most commonly used numeric and character functions that can be used for complex dimension and detail objects. The list of numeric functions consists of a number of aggregate functions that can be used in measure objects, and several mathematical and statistical functions. The list of character functions consists of several functions that allow you to extract data-parts, and some conversion functions.
32
On their own each function may give limited functionality, but when combining two or more functions in a SELECT statement, they allow designers to construct complex objects that may benefit the end users in their report creation.
Returns a number of character values from the left-hand side of a string. Returns a number of character values from the right-hand side of a string. Returns the position of an expression in a character string. Returns the length of a character string. Returns part of a character string. The substring starts at a specified character position and has a specified length.
Charindex
Fn_Length
Substring
These functions can be used to establish a character string length by using the length function. The substring, left and right functions can allow extracting values of a specified length from either the start or end part of a character string. Charindex can establish the position of a character value in a string. Combining these functions can allow designers to extract string values from any part of a table column. For example, if for a Zoning Improvement Plan (ZIP) code, or Postal Code, only the first group of values, representing the local Area Code are required. For example, "SL6", "W1" or "NW6". However, the group of values can be either two or three characters long ("W1", or "NW6"). This can pose a problem with using the left or substring function as it is unknown how many character values need to be extracted. The common delimiter is the space or hyphen that separates the first part of the ZIP code, or Postal Code, from the second. If the position of the space is known, then this can be the deciding factor of how many values to extract from the left-hand side. Charindex can be used to establish the position of the space in this string:
charindex(' ',CLIENT.CLIENT_AREA_CODE)
You can now define data up to the space from either left or right. The following syntax provides the first digits of the ZIP code, or Postal Code, up to the dividing space:
rtrim(substring(CLIENT.CLIENT_AREA_CODE,1,charindex(' ', CLIENT.CLIENT_AREA_CODE)))
33
Note: The rtrim function is used to remove the space (on the right) from the substring.
Ceiling
Returns the smallest integer greater than or equal to n. It returns the decimal value rounded up to the next integer value. For example, Ceiling(2.3) returns a value of 3. Returns the largest integer less than or equal to n. It returns the decimal value rounded down to the next integer value. For example, Floor(6.987) returns a value of 6. Returns a number rounded to n decimal places. Converts data from one data type to another.
Floor
Round
CAST
Rounding up and rounding down of values can be useful to make sure that number formats do not have unnecessary decimal places. This can be useful for object formatting, and for certain measure calculations. These functions can also be used in creating data range objects. In the Client table there is a value for Client_Age, and the end user likes to be able to run a query showing the customer age and the age range the customer falls into. For example, 10-19, 20-29, 30-39, and so forth. You can use the CAST function to convert and combine the two strings. The formula becomes:
CAST((floor(CLIENT.CLIENT_AGE/10)*10) as varchar)+'-'+ CAST((((floor(CLIENT.CLIENT_AGE/10)+1)*10)-1) as varchar)
This allows end users to run an age range object with a range increment of 10, in their reports.
34
Function element
Description
For example:
CASE CLIENT.CLIENT_LASTNAME
WHEN when_expression
The when_expression is a simple expression to which the input_expression is compared. The data types of input_expression and each when_expression must be the same. For example:
CASE CLIENT.CLIENT_LASTNAME WHEN 'Brent'
THEN result_expression
The result_expression is the expression returned when the input_expression equals when_expression evaluates TRUE, or Boolean_expression evaluates to TRUE. The result_expression is any valid expression. For example:
CASE CLIENT.CLIENT_LASTNAME WHEN 'Brent' THEN 1
ELSE else_result_expression
The else_result_expression is the expression returned if no comparison operation evaluate to TRUE. If this argument is omitted and no comparison operation evaluates to TRUE, CASE returns NULL. The else_result_expression is any valid expression, however the data types of the else_result_expression and any result_expression must be the same or must be an implicit conversion. For example:
CASE CLIENT.CLIENT_LASTNAME WHEN 'Brent' THEN 1 ELSE 0
35
Function element
Description
The END component ends the CASE statement syntax. For example:
CASE CLIENT.CLIENT_LASTNAME WHEN 'Brent' THEN 1 ELSE 0 END
END
Any additional CASE statements can be placed before the END syntax to evaluate a further list of conditions. An END syntax for each additional CASE statement is required. For example:
CASE CLIENT.CLIENT_LASTNAME WHEN 'Brent' THEN 1 ELSE 0 (CASE CLIENT.CLIENT_LASTNAME WHEN 'Cooley' THEN 1 ELSE 0 END) END
The CASE statement can be used in objects, conditions, joins and derived tables allowing for great flexibility in universe design. An example syntax for the CASE statement is:
Note: The CASE statement is not a condition in itself. It is only a value assignment. This means that it allows you to combine as many CASE statements (nested within each other) as you want. On the other hand you need to add extra conditions to ensure the restriction actually works and no empty rows are created.
36
For example, the range object needs to show the lower range value of 40, and the upper range value of 49, when the CLIENT.CLIENT_AGE value is 44. Note: Ensure that the brackets are in the right location to get the correct calculation order. 3. Click Apply and OK to save the object changes. 4. Test the new object in Web Intelligence Rich Client. 5. In Universe Designer create a copy of the Age Range object. Rename the object Dynamic Age Range. 6. Edit the Dynamic Age Range SELECT syntax. Replace the value 10 by the following @prompt function syntax:
(@prompt('Enter Range Increment','N',,,))
Note: Remember that it is useful to add a help text for this type of object to let the end user know what type of value they are expected to fill into the prompt. For example, in this case it can be noted that the end user can enter into the prompt values like 5, 10, 15, 20, and so forth. 7. Click Apply and OK to save the object changes. 8. As the universe has Aggregate Awareness assigned, it is good practice to set any new objects to be either compatible or incompatible with these tables. In this instance, Age Range is a new object in the client class. Ensure that the client class is incompatible with the annual figures, quarter figures, year order count, year quarter order count, and year quarter month order count tables. Save the change to your universe. 9. Test the results in Web Intelligence Rich Client.
37
Function element
Description
analytic_clause
Use OVER analytic_clause to indicate that the function operates on a query result set. That is, it is computed after the FROM, WHERE, GROUP BY, and HAVING clauses. You can specify analytic functions with this clause in the select list or ORDER BY clause.
Note: You cannot specify any analytic function in any part of the analytic_clause. That is, you cannot nest analytic functions.
38
Function element
Description
query_partition_clause
Use the PARTITION BY clause to partition the query result set into groups based on one or more value_expr. If you omit this clause, then the function treats all rows of the query result set as a single group. Valid values of value_expr are constants, columns, non-analytic functions, function expressions. Use the order_by_clause to specify how data is ordered within a partition. you can order the values in a partition on multiple keys, each defined by a value_expr and each qualified by an ordering sequence.
Note: Aggregate analytic (Transact_SQL) functions for SQL Server do not allow the use of the ORDER BY. This may differ with other RDBMS that support these type of functions.
order_by_clause
Analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause. In Universe Designer you can define objects with analytic functions to calculate rankings, cumulative aggregates, and ratios within one or more partitions. Depending on your RDBMS, you can also define the range of rows on which you want to apply the analysis within the partition. Note: For a full description of analytic functions refer to your RDBMS documentation.
ROW_NUMBER
The most basic ranking function is ROW_NUMBER. ROW_NUMBER returns a column as an expression that contains the rows number within the result set. This is only a number used in the context of the result set, if the result changes, the ROW_NUMBER value changes. The ROW_NUMBER expression is used with the following additional clauses: OVER: Determines the partitioning and ordering of the rowset before the associated window function is applied. PARTITION BY: Divides the result set into partitions. The window function is applied to each partition separately and computation restarts for each partition. ORDER BY: Specifies the sort order used on columns returned in a SELECT statement. Note: If you choose the ROW_NUMBER function to run against a non-unique column, it breaks the tie and still produces a running count so no rows have the same number. An example ROW_NUMBER SQL Statement is as follows:
SELECT ROW_NUMBER() OVER (PARTITION BY 1 ORDER BY CLIENT_ID) AS SURROGATE, * FROM CLIENT
39
RANK
RANK works a lot like ROW_NUMBER and uses the same expression clauses as described in the ROW_NUMBER section.
The main difference is that the RANK function does not break ties, you do not get a unique value for ties. The RANK function assigns the same key if the value is the same.
The RISQL functions parameter lists the supported by the database, and this list is different for each RDBMS. The Over Clause parameter allows BusinessObjects products to include aggregate analytic functions (for example, SUM() OVER (PARTITION BY))when generating SQL. Depending on the database used, in the PRM file you may also need to apply parameter rules for the GROUP BY clause. Consult the BusinessObjects XI 3.0/3.1: Designer's Guide for more information on analytic functions and the PRM file.
40
This example returns the values 2003, 2004, and 2005 in numeric format. fn_month: This function returns the month values of a date object. For example:
{fn month(FINANCE_PERIOD.FP_START)}
This example returns the values 1-12 in numeric format. Note: If there is no date value in the database Fp_Start column for a particular month, this month value is not included in the LOV. fn_week: This function returns the week values of a date object. For example:
{fn week(FINANCE_PERIOD.FP_START)}
This returns the values 1-52 in numeric format. Note: If there is no date value in the database Fp_Start column for a particular week, this week value is not included in the LOV. datepart(qq, ): This function returns the quarter values of a date object. For example:
Datepart(qq, FINANCE _PERIOD.FP_START)
41
Note: The datepart function can also be used to extract year, month, week, and day numeric values. You can also use the dateadd and datediff functions to calculate a number of different dates you might need to use in your applications. And for a current date value the function getdate can be used.
Note: If database functions are typed in directly, do ensure that the object parses and run test queries to ensure the object does not cause any errors.
The datediff function calculates the amount of time between two dates, where the time part is based on an interval of time, such as hours, days, weeks, months, or years. The dateadd function calculates a date by taking an interval of time, and adding it to a date, where the interval of time is the same as those used by the datediff function. Combining these two functions and getdate, a SQL Server function that returns the current date and time, can aid retrieving first and last day of the month or year information, for example: First Day of Month:
dateadd(mm,datediff(mm,0,getdate()), 0)
The datediff(mm,0,getdate()) section of the syntax above calculates the number of months between the current date and the date "1900-01-01 00:00:00.000". In SQL Server date and time variables are stored as the number of milliseconds since "1900-01-01 00:00:00.000". This is why you can specify the first date-time expression of the datediff function as "0." The dateadd function adds the number of months between the current date and '1900-01-01". By adding the number of months between our predetermined date '1900-01-01' and the current date it is possible to arrive at the first day of the current month. In addition, the time portion of the calculated date becomes "00:00:00.000." Monday of the Current Week:
dateadd(wk,datediff(wk,0,getdate()),0)
Note: This example assumes Sunday is the first day of the week. First Day of the Year
dateadd(yy,datediff(yy,0,getdate()),0)
By using this simple dateadd and datediff calculation you can come up with many different dates that might be valuable. Here are some examples that add an additional dateadd function to calculate the last day dates for both the current and prior intervals. Last Day of Prior Month
dateadd(ms,-3,dateadd(mm,datediff(mm,0,getdate()),0))
42
Using the sixth day of the month instead of the current date in the formula allows this calculation to return the first Monday of the current month.
getdate()
Date
datepart(yyyy,getdate())
Number
datepart(mm,getdate())
Number
Next Year
dateadd(mm,12,getdate())
Date
Adding date objects based on database date functions to the universe gives end users more flexibility in their reporting requirements.
43
Note: Date function syntaxes can be used in predefined conditions as well as in objects.
@prompt @select
44
Re-use of prompt syntaxes can be handled in the same way. You can create base date prompt objects, that can be hidden to end users if needed, and use these as reference in other objects. For example:
Prompt Object SELECT syntax @prompt('Select date','D','Financial Period\FP Start',mono,free)
For our previous CASE statement example you can use @select to substitute the database column and the prompt syntax if both already exist as objects in the universe:
CASE WHEN @select(Financial Period\Financial Year) = @select(Prompt Objects\Year Prompt) AND @select(Financial Period\Financial Month)= @select(Prompt Objects\Month Prompt) THEN 1 ELSE 0 END
The advantage of the @select function is that it allows you to specify SQL code only once. If you change a database column in the RDBMS you only need to modify the SQL of the base object; Universe Designer automatically updates the SQL for all other objects that use the base column. Tip: When using @select, you can still see the full SQL statement by enabling the check box Show Object SQL in the SQL Editor. When all base syntax components have been constructed, a CASE statement can be used to combine the functions and build boolean "reference" objects, or "flags" that can be used to build relative-time measures objects. Note: You can also construct the CASE statement , using boolean logic, separating statements using an asterisk; the asterisk ensures that both CASE statements return a 1 value:
CASE @select(Financial Period\Financial Year) WHEN @select(Prompt Objects\Year Prompt) THEN 1 ELSE 0 END * CASE @select(Financial Period\Financial Month) WHEN @select(Prompt Objects\Month Prompt) THEN 1 ELSE 0 END
45
Instructions
Prompt objects are constructed using database date functions, to return an input base for end users to enter a year, month, or a full date value. These prompted values are compared to the actual database date column (or datepart), for example SALE.SALE_DATE. A CASE statement can be used to compare the prompted period with the actual database column period, and build boolean "reference" objects, or "flags" that can be used to build relative date-time measures objects. If the prompted period input value matches the actual database column period, the CASE statement returns a 1 value. After creating the boolean flags, the final stage is to build the relative date-time measure objects. For each 1 value of the boolean flag, the relative date-time measure value is returned. Note: This activity uses the @select function to reference already created objects. The @select function is an internal function that allows you, as the designer, to reuse universe objects without forcing you to repeat the entire SQL syntax. The @select syntax used in this activity can be generated by selecting the objects and functions in the Edit Select menu. 1. In Universe Designer, open your Motors universe file. 2. Create a new YTD Date Objects subclass in the Sales class. 3. Create the following sale date prompt objects in the YTD Date Objects subclass. Sales Date Prompt:
@prompt('Select Date or Type Date (dd/mm/yyyy)','D','Sales Dates\Sale Date',mono,free)
SELECT
syntax:
Note: The Sales Date Prompt object contains an @prompt syntax in the SELECT clause. Normally an @prompt is handled in the WHERE clause and the SELECT contains the table.column reference. For the purpose of feeding through the prompted value into other object SELECT clauses using the @select function, the @prompt requires to be placed in the Sales Date Prompt object SELECT clause. The table reference is set via the Tables button. The @prompt syntax only parses when it is set to a Character type. It is viewed as constant, as there is no date column referenced. Setting the object to Character type does not affect the outcome of the activity.
Description:
Prompts the user to choose a sales date from the list of values or manually type in a date value (YYYYMM).
46
syntax:
Description: Type:
Subtracts the year from the entered sales date prompt value. Number
syntax: Description: Type: Subtracts the month from the entered sales date prompt value. Number
4. In the YTD Date Objects subclass, create the following indicator or boolean flag objects that are used to create relative date-time measure objects in the remaining activity steps. Note: The boolean flag objects need to be hidden. They should not be used by end users as objects on their own. Tip: The @select statements shown in the table can be generated by selecting the objects and functions in the Edit Select menu.
Sales Date in Prompt flag SELECT syntax CASE WHEN @select(Sales Dates\Sales Year) = @select(YTD Date Objects\Sales Year Prompt) AND @select(Sales Dates\Sales Month) = @select(YTD Date Objects\Sales Month Prompt) Description
Indicator that returns 1 if both the year and the month of the sales date are equal to the year and month in the entered
47
Description
Sales Month in Prompt flag SELECT syntax CASE WHEN sign(@select(Sales Dates\Sales Year)+1 @select(YTD Date Objects\Sales Year Prompt)) = 0 AND sign(@select(Sales Dates\Sales Month) @select(YTD Date Objects\Sales Month Prompt)) = 0 THEN 1 ELSE 0 END Description
Indicator that returns 1 if the year of the sales date equals the year in the entered prompt date minus one year, and the month of the sales date equals the month of the reference period. Otherwise it returns 0.
Sales Year in Prompt flag SELECT syntax CASE WHEN @select(Sales Dates\Sales Year) = @select(YTD Date Objects\Sales Year Prompt) AND sign(@select(Sales Dates\Sales Month) (@select(YTD Date Objects\Sales Month Prompt)-1) = 1 THEN 1 ELSE 0 END Description
Indicator that returns 1 if the month of the sales date <= sales month prompt, and the year of the sales date is equal to the sales year prompt. Otherwise it returns 0.
Note: The first part of the Sales Year in Prompt flag statement compares the year values. If the year selected in the prompt matches the year value in the date this returns the sale date values for those rows. The second part of the statements subtracts the month value selected in the prompt(-1) from each value in the sale date rows returned. The sign function does the following: if the subtraction value is a minus value it returns -1, if the subtraction value ends in 0 it returns 0, if the subtraction value ends up in a positive value, it returns 1. If a sale date of 4/3/2004 is selected in the prompt, the datepart(mm) changes this to a value of 4. The -1 part of the formula changes this value to 3 as the prompt input value. When the prompted period value (3) is subtracted from the month value (4) a positive value is returned and ends in 1. With the CASE statement this ensures that month 4 is included in the values returned. 5. Hide the entire YTD Date Objects subclass. 6. Create a new YTD Measure Objects subclass in the Sales class. 7. Create the following relative date-time measure objects in the YTD Measure Objects subclass:
48
Tip: The @select statements shown in the table can be generated by selecting the objects and functions in the Edit Select menu.
Measure Object SELECT Syntax sum(SALE.SALE_TOTAL)
Sales Total Total Sales in prompted yyyy-mm period Total Sales in prompted year period Total Sales in prompted year period - 1yr
8. As the universe has aggregate awareness assigned, it is good practice to set any new objects to be either compatible or incompatible with the summary tables used in your schema. Ensure that the YTD Measure Objects and YTD Date Objects are incompatible with the annual figures, quarter figures, year order count, year quarter order count, and year quarter month order count tables. Save the change to your universe. 9. Save the changes and test your universe using Web Intelligence Rich Client. 10.Create a new query using Sale Date, Sales Total, and Total Sales in prompted yyyy-mm period. 11.Select a date from the LOV. The Total Sales in prompted yyyy-mm period object returns only sales data for the month and year values that equal the month and year values entered in the prompt, all other rows return 0. This way end users can compare the total sales revenue for all dates to the sales revenue returned for the selected yyyy-mm period. 12.Run a second query using the Sale Date, Sales Total, and Total Sales in prompted year period objects. 13.Select a date from the LOV. Note: There is no data for 2002, so ensure to select a date from 2004 or 2005 to see the last year values. The Total Sales in prompted year period object returns only sales data for the month and year values that equal the month and year values entered in the prompt. All other rows return 0.
49
14.Run a new query using the Sale Date, Sales Total, and Total Sale - 1yr objects. 15.Select a date from the LOV. Note: There is no data for 2002, so ensure to select a date from 2004 or 2005 to see the last year values. The Total Sales in prompted year period - 1yr object returns only sales data for the month and year values that equal the month and year values entered in the prompt minus 1 year. All other rows return 0.
Moving averages
In statistics, a moving average or rolling average is one of a family of similar techniques used to analyze time series data. A moving average series can be calculated for any time series. In finance it is most often applied to stock prices, returns, or trading volumes. Moving averages are used to smooth out short-term fluctuations, thus highlighting longer-term trends or cycles. The threshold between short-term and long-term depends on the application, and the parameters of the moving average are set accordingly. A moving average through time is the unweighted mean of the previous N data points. For example, a 10-day simple moving average of closing price is the mean of the previous 10 days' closing prices. If those prices are pN,pN 1... pN 9 then the formula is:
This type of average is also referred to as a moving average through time, or MAT. In the Motors universe you do not have a day level of granularity, but can calculate the moving average using the time periods from the Financial Period table, using month as the granularity level. In the example shown, a derived table and an alias have been added to the structure.
50
To create a moving average in a universe you require the following: A derived table with @prompt or @variable. A fact table. An alias of the fact table. A time period (dimension) table. Contexts. The derived table acts as the N time period input via the Start_N_Periods column. This is done using the @prompt function in the table SQL syntax. For example:
SELECT Distinct FINANCE_PERIOD.FP_YEAR, FINANCE_PERIOD.FP_MONTH, dateadd(month,-@prompt('how many periods?','N',,,,),FINANCE_PERIOD.FP_END) as START_N_PERIODS, FINANCE_PERIOD.FP_START, FINANCE_PERIOD.FP_END FROM FINANCE_PERIOD
Note: For some RDBMS the @prompt function needs to be substituted by @variable. For more information on the use of @variable consult the BusinessObjects Designer's Guide. The Sale table alias is the source for the MAT measure data, based on the prompted N time period value that is fed through the join between the alias and the derived table. Contexts are required to separate the Sale and Sale_MAT fact tables, otherwise you would have a potential SQL Trap in your schema. A Sale_MAT context:
A Sale context:
51
The final stage is to create the actual objects that the user can run to display the Sale Total MAT values. In this example the Sale Total MAT object consists of the Sale_Total column from the Sale_MAT table and the @prompt syntax used to get the number of periods:
sum(SALE_MAT.SALE_TOTAL)/@prompt('how many periods?','N',,,,)
When a user runs a query with Financial Year, Financial Month, the Sales Total from the original Sale table, the Sales Total N Period (Sale_Total from the alias table), and Sales Total MAT, the user is prompted for the number of periods required for the moving average.
The report displays the sales total values. The Sales Total N Periods column shows the accumulated values based on the number of periods (in our example 2), and the Sales Total MAT column shows the accumulated values divided by the number of periods.
52
Instructions
1. In your Motors universe create a SALE_MAT alias table. Note: The self-restricting join for the SALE.SALE_TYPE column needs to be manually created for the SALE_MAT alias table. 2. Create a new Derived Table, called DT_Date_N_Periods, using the following syntax:
SELECT Distinct FINANCE_PERIOD.FP_YEAR, FINANCE_PERIOD.FP_MONTH, dateadd(month,-@prompt('How many periods?','N',,,,),FINANCE_PERIOD.FP_END) as START_N_PERIODS, FINANCE_PERIOD.FP_START, FINANCE_PERIOD.FP_END FROM FINANCE_PERIOD
3. Join the DT_Date_N_Periods table to the SALE_MAT table using a theta-join; using the START_N_PERIODS, FP_END, and SALE_DATE columns.
SALE_MAT.SALE_DATE between DT_Date_N_Periods.START_N_PERIODS and DT_Date_N_Periods.FP_END (N:1)
53
4. Join the DT_Date_N_Periods table to the FINANCE_PERIOD table using a complex join; joining month and year columns in both tables.
DT_Date_N_Periods.FP_YEAR = FINANCE_PERIOD.FP_YEAR and DT_Date_N_Periods.FP_MONTH = FINANCE_PERIOD.FP_MONTH (1:1)
5. Join the SALE_MAT table to the CLIENT, SHOWROOM, and SALE_MODEL tables. Set the appropriate cardinalities. (These are the same as the joins from the SALE table. ) 6. Create a SALE_MAT context. Tip: This context mirrors the existing SALES context and should consist of 19 joins. You can make a copy of the SALES context as follows: 1. Open List Mode, and select the SALES context. 2. Right-click the SALES context in the Context zone in List Mode. Select Insert Context. 3. The New Context window appears, with all joins from the original SALES context selected. 4. Name the context SALES_MAT and remove all joins referring to the original SALE table:
CLIENT.CLIENT_ID = SALE.CLIENT_ID SHOWROOM.SHOWROOM_ID = SALE.SHOWROOM_ID SALE.SALE_ID = SALE_MODEL.SALE_ID SALE.SALE_TYPE = 'S' SALE.SALE_DATE between FINANCE.FP_START and FINANCE.FP_END
5. Replace the removed joins with the SALE_MAT alias table joins. Ensure all newly created joins are included in the SALE_MAT context. 7. In the Sales class, create a new Sales MAT subclass. Insert the following objects: Sales Total
sum(SALE.SALE_TOTAL)
Note: A Sales Total object, with the same SELECT syntax, already exists in the YTD Measure Objects subclass, and instead of creating a new object with the same syntax, you can create a new object in the Sales MAT subclass that references the existing Sales Total object using the @select function.
@select(YTD Measure Objects\Sales Total)
54
Note: Either use the syntax shown above, or use the @select function to reference the existing Financial Year object in the Finance Period class.
@select(Finance Period\Financial Year)
Note: Either use the syntax shown above, or use the @select function to reference the existing Financial Month object in the Finance Period class.
@select(Finance Period\Financial Month)
8. As the universe has Aggregate Awareness assigned, it is good practice to set any new objects to be either compatible or incompatible with the summary tables used in your schema. Ensure that the Sale MAT objects are incompatible with the annual figures, quarter figures, year order count, year quarter order count, and year quarter month order count tables. Save the change to your universe. 9. Save your changes and launch Web Intelligence Rich Client. Create a query with all objects in the Sales MAT class, Test the report using different number of periods. Your report should look similar to this:
The report displays the Sales Total column, which references the original SALE table. The Sales Total N Periods column shows the accumulated sales total values based on the number of periods (for example Sales Total from Month 01 and Month 02), the Sales Total MAT column shows the accumulated values divided by the number of periods (for example Sales Total from Month 01 and Month 02, divided by 2). 10.Test the report by adding dimension objects, for example Showroom Country. Apply a section or break, to get a better overview of the results. Your report should look similar to this:
55
56
57
Lesson summary
After completing this lesson, you are now able to: Combine database functions in objects Construct relative date-time objects
58
Lesson 4
59
The maximum Sale Date is the 31st of March 2005, and the Sales Revenue for that date is 17, 505. When adding a new table with =Max([Sale Date]) and another column with Sales Revenue, notice that the Sales Revenue showing for the maximum Sale Date is actually the total revenue for all sale dates. The correct results can be obtained by using a subquery at report level. However, instead of having the end user struggle with the appropriate subquery syntax, this can also be done at universe level as a predefined condition. For example:
SALE.SALE_DATE = ALL ( SELECT max(SALE.SALE_DATE) FROM SALE WHERE
60
(SALE.SALE_TYPE='S') )
The example predefined condition syntax ensures that the result in Web Intelligence Rich Client appears correct. When the end user creates a new Web Intelligence Rich Client document using Sale Date and Sales Revenue in the Result Objects pane, and the new condition in the Query Filter pane, the end result shows the maximum Sale Date and the correct Sales Revenue value of 17,505.
The benefit of using this method is that it allows the end user to combine several objects in a report and get the correct maximum Sale Date and Sales Revenue values.
Using subqueries this way allows designers to use aggregate functions in the WHERE clause. It is also possible to extend this syntax and generate a condition that allows end users to retrieve the maximum Sale Date for each Client together with the corresponding Sales Revenue. In the Motors database there are a number of clients that have more than one sale date record.
Using a predefined condition with a subquery allows end users to return the maximum sale date per client. For example:
( CLIENT.CLIENT_ID=SALE.CLIENT_ID ) AND ( SALE.SALE_DATE = ALL ( SELECT max( SALE.SALE_DATE ) FROM SALE, CLIENT SubAlias__1 WHERE (SubAlias__1.CLIENT_ID=SALE.CLIENT_ID) AND (SALE.SALE_TYPE='S') AND SubAlias__1.CLIENT_LASTNAME + ', ' + SubAlias__1.CLIENT_FIRSTNAME = CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME ) )
61
Note: Universe Designer, uses SubAlias_1, and subsequent numbering, to replace the table names. When the end user creates a new Web Intelligence Rich Client document using Client Name, Sale Date and Sales Revenue in the Result Objects pane, and the new condition in the Query Filter pane, the end result shows the maximum Sale Date and the corresponding Sales Revenue value for each Client Name.
Instructions
1. Open your Motors universe file in Universe Designer. 2. Click the Filter icon at the bottom of the Universe pane. In the Sales Dates subclass, create a new Max Sales Date condition, and add an appropriate description. 3. The subquery to insert into the Where field is as follows:
SALE.SALE_DATE = ALL ( SELECT max(SALE.SALE_DATE) FROM SALE WHERE (SALE.SALE_TYPE='S') )
Note: The syntax for this subquery can be found on the course resources. 4. Click in the Filter icon at the bottom of the Universe pane. In the Sales Dates subclass, create a new Max Sales Date for each Client Name condition, and add an appropriate description. 5. The subquery to insert into the Where field is as follows:
( CLIENT.CLIENT_ID=SALE.CLIENT_ID ) AND ( SALE.SALE_DATE = ALL ( SELECT max( SALE.SALE_DATE ) FROM
62
SALE, CLIENT SubAlias__1 WHERE (SubAlias__1.CLIENT_ID=SALE.CLIENT_ID) AND (SALE.SALE_TYPE='S') AND SubAlias__1.CLIENT_LASTNAME + ', ' + SubAlias__1.CLIENT_FIRSTNAME = CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME ) )
Note: The syntax for this subquery can be found on the course resources. 6. Ensure that the condition objects in the Sale Date sub class are incompatible with the tables used in aggregate awareness. 7. Save the changes in the universe. 8. Launch Web Intelligence Rich Client. Run a query with Sale Date and Sales Revenue in the Result Objects pane, and the new Max Sales Date in the Query Filter pane. The result now shows the maximum Sale Date and the correct Sales Revenue value of 17,505.
The benefit of using a subquery in a condition is that it allows the end user to combine several objects in a report and get the correct maximum Sale Date and Sales Revenue values. 9. Edit the query and add Invoice ID Number, Model and Showroom. The maximum date and corresponding measure and dimension values are correctly shown in the report:
10.In the Motors database there are a number of clients that have multiple sale date rows. Create a new document in Web Intelligence Rich Client, using Sale Date, Client Name and Sales Revenue in the Result Objects pane. Filter on the Client Name for Paul Brent, Howard Hugheston, Paul Penn, and John Smith.
63
11.Run a new query, using Sale Date, Client Name, and Sales Revenue in the Result Objects pane, and the new Max Sales Date for each Client Name condition in the Query Filter pane. The result now shows the maximum Sale Date and the correct Sales Revenue value per Client Name.
64
When the user selects a value from the LOV or enters a value directly in the box, the first part of the condition is valid. The second part is not valid at this point. However, due to the use of the OR statement, the condition is valid if one of the two parts is valid. When the user enters an asterisk (*), the second part of the condition is valid. Due to the use of the OR statement, the condition is always valid (* = *) and all values are returned. 10.Click Parse. 11.Click OK. 12.Save the changes in the universe. 13.When using the new prompt condition in the Query Filter pane in a new report, it allows end users to select one or more values from the list or type * in the Type a value box. This returns all values of the object.
10.Click Parse. 11.Click OK. 12.Save the changes in the universe. Note: Using LIKE as an operator does not work with a list of values. You can in theory get users to select one value or use the pattern, but in reality this does not work out very well in Web Intelligence Rich Client. It is best to ensure that there is no LOV referenced in the @prompt function syntax.
65
4. Enter the condition directly in the Where field or via the Edit Where Clause box by selecting the >> button. The syntax to insert is as follows:
@select(Client\Client Name) IN @prompt('Select value or type * for all values' ,'A','Client\Client Name',multi,free) OR ('*') IN @prompt('Select value or type * for all values' ,'A','Client\Client Name',multi, free)
5. Click Parse, and OK. 6. Save changes and create a new Web Intelligence Rich Client report using Client Name and the new Client ALL values prompt filter. 7. In the Type a value box enter * and click the arrow. 8. Click Run Query. The report returns all Client Name values. 9. Edit the query and re-run. Remove the asterisk and test that the end user can also select multiple values from the LOV. Note: You may need to click on Refresh List if the values are not shown.
66
Enter one or more starting letters followed by the % sign. Enter a pattern like: B%, J% 3. Enter the condition directly in the Where field or via the Edit Where Clause box by selecting the >> button. The syntax to insert is as follows:
@select(Client\Client Name) LIKE (@prompt('Enter a name pattern','A',,,)+'%')
4. Click Parse and OK. 5. Save the changes and create a new Web Intelligence Rich Client report using Region, Client Name, and the new Client Name Pattern Prompt condition. 6. In the prompt box enter B%, J%. 7. Click Run Query. The report returns all clients with a last name starting with "B" and a first name starting with "J".
67
Customizing LOVs
As shown in the predefined conditions unit you can create prompts that allows users to enter an asterisk (*) to return all values. You can also modify the LOV to show an "ALL values" entry. When selecting this it will also return the full list of values of the object.
The same TABLENAME.COLUMN_NAME is referenced in all sections of the CASE statement. This syntax converts each of the column values to a generic 'ALL' value. 3. Click the Properties tab. 4. Click Edit. 5. In the Query Panel select the Combine Queries toolbar icon. This generates a second query tab with the UNION symbol. 6. In the Query 2 tab, remove the newly created ALL values object and drag in the original object used in the ALL values prompt. 7. Click View SQL. The SQL shows the UNION between the ALL values object and the original prompt object.
SELECT Distinct CASE WHEN TABLENAME.COLUMN_NAME = TABLENAME.COLUMN_NAME THEN 'ALL' ELSE TABLENAME.COLUMN_NAME END FROM TABLENAME UNION SELECT Distinct TABLENAME.COLUMN_NAME FROM TABLENAME
68
9. Click Run. 10.Click Display. The LOV contains a list of all individual column values and the value 'ALL'. 11.Click OK twice. 12.Click the Show or Hide Item toolbar icon to hide the ALL values object. 13.Click the Filter icon at the bottom of the Universe pane. 14.Open the previously created ALL values prompt condition. The original SQL syntax for this condition reads:
TABLENAME.COLUMN_NAME IN @prompt('message','type','{Class\Object}',multi, free) OR ('*') IN @prompt('message','type','{Class\Object}',multi, free)
15.The prompt syntax now needs to be altered to reference the LOV of the new ALL values object. Modify the syntax to:
TABLENAME.COLUMN_NAME IN @prompt('message','type','{Class\Object_ALL_Values}',multi, free) OR ('*') IN @prompt('message','type','{Class\Object_ALL_Values}',multi, free)
This syntax ensures that when the 'ALL' value is selected in the LOV it has a 'reference' and the query returns all object values. When used in a query, the end user sees the value ALL as part of the LOV of the prompted object. Selecting this returns all values.
Instructions
1. In Universe Designer, open your Motors universe file. 2. Create a new class called LOV Objects. 3. Create a new Client_ALL object in the LOV Objects class. 4. Click Apply.
69
This syntax converts all Client Name values to 'ALL'. 6. Click the Properties tab. 7. Click Edit. 8. In the Query Panel select the Combine Queries toolbar icon. This generates a second query tab with the UNION symbol. 9. In the Query 2 tab, remove the Client_ALL object and drag in the Client Name object instead. 10.Click View SQL. The SQL shows the UNION between the Client Name object and the Client_ALL object. Click OK to close the SQL Viewer. 11.Click Run. 12.Click Display. The LOV now contains a list of all individual client names and the value 'ALL'. 13.Click OK. 14.Select the Export with universe option. 15.Click OK. 16.Click the Show or Hide Item toolbar icon to hide the LOV Objects class. 17.Click the Filter icon at the bottom of the Universe pane. 18.Open the Client ALL values Prompt condition. 19.The prompt syntax now needs to reference the Client_ALL LOV. Modify the syntax to:
@select(Client\Client Name) IN @prompt('Select value or type * for all values','A','LOV Objects\Client_ALL',multi, free) OR ('*') IN @prompt('Select value or type * for all values' ,'A','LOV Objects\Client_ALL',multi, free)
This syntax ensures that when the 'ALL' value is selected in the LOV it has a 'reference' and the query returns all client name values. The complete modified syntax should read:
@select(Client\Client Name) IN @prompt('Select value or type * for all values','A','LOV Objects\Client_ALL',multi, free) OR ('*') IN @prompt('Select value or type * for all values' ,'A','LOV Objects\Client_ALL',multi, free)
70
21.Save the changes in your universe. 22.Launch Web Intelligence Rich Client. 23.Create a new report using Region and Client Name in the Result Objects pane, and the Client ALL values Prompt condition in the Query Filter pane. 24.Click Run Query. 25.The ALL value now shows up in the available list of values. Select the ALL value and click the arrow. 26.Run the query. This should return all client names. Note: This activity creates an extra object to bring in the ALL value. The UNION statement can also be added directly to the LOV with the Do not regenerate SQL before running option ticked.
In Universe Designer, an LOV can be viewed as tabular, or hierarchical. However, the hierarchical option is not available for Web Intelligence or Web Intelligence Rich Client end users. The same list hierarchy can be achieved in Web Intelligence or Web Intelligence Rich Client by using a cascading LOV.
71
This syntax returns the first letter of the column. 4. Click OK. 5. Click the Show or hide item toolbar icon to hide the object. 6. Select Tools List of Values Create cascading list of values. 7. Add the first letter object to the cascading list of values menu, followed by the original object.
8. Verify that the Hierarchical View check box is selected. 9. Click Generate LOVs. As the selected objects may already contains LOVs, a message appears asking whether you want to overwrite the existing values. 10.Click OK. 11.Save the changes in the universe.
72
Instructions
1. Create a new object called First Letter of Manager Lastname in the hidden LOV Objects class 2. In the Select field enter the following SELECT syntax:
substring(MANAGER.EMP_LASTNAME, 1, 1)
This syntax returns the first letter of the manager's last name. 3. Create a new cascading LOV. 4. Add the First Letter of Manager Lastname object to the cascading list of values menu, followed by the original Manager object. 5. Verify that the Hierarchical View check box is selected. 6. Generate the LOVs. 7. Ensure the LOV Objects class is hidden from the Aggregate awareness tables. 8. Save the changes and test the results in Web Intelligence Rich Client. 9. Return to Universe Designer and restore the Manager LOV using the following steps: Edit the Manager object and select the Properties tab. Click Edit. Remove the cascading LOV generated condition. Click Run to restore the LOV.
73
By including objects in the query that cause the join to be included into the generated SQL you can test whether the prompt in the join definition appears and works correctly. Running the query causes the prompt of the join definition to pop up, just as it would for prompts in objects or predefined conditions. In the Motors universe, the Sale table contains rows for sales and rental data. Instead of using self-restricting joins to filter out the data, an @prompt syntax can be placed on the Sale table. This method could eliminate the requirement for aliases and additional contexts.
74
Note: You cannot use the @select and @where functions in join definitions.
75
The prompt gets end users to select the category they need to query on and depending on the selection the CASE statement links the relevant joins. Note: The above example is not part of the Motors database schema.
200701
161803
76
To achieve this, you need to link the data of 200701 to the month 200801 as the previous year's value, which can be done via a conditional join in the universe. In the Motors universe similar results can be achieved by using the Sale fact table, an alias of the Sale fact table, and the Finance_Period time dimension table. The conditional join is placed between the alias table and the Finance_Period table. The conditional join uses a database date function to extract the year, minus 1 to retrieve the previous year.
Data can, for example, be returned per quarter of the FY04-05 period and per quarter of the previous FY03-04 period.
77
The advantage of this solution is that it is an easier method to handle if you want to create a huge amount of measures for the previous year. Instead of creating several CASE objects, you just need to create the objects directly based on the new alias, and you only need to create one special join condition. The disadvantage of this method is that you need to have a date dimension table in the schema to make it work correctly. Secondly, by using this method, separate SQL queries need to be carried out which can cause performance issues.
78
The disadvantage of this method is that users need to run these running calculation objects together with a time dimension to return the correct results. Secondly, the ">=" join has a negative impact on performance for big amounts of data. A real life database fact table normally contains several million rows of data, and internally the join creates a partial Cartesian product. Therefore, when having to deal with running calculation requirements, consider the following alternatives: Use analytic database functions (Transact_SQL). Note: These functions can also have a performance impact. Ask the ETL person to create extra columns for the running sums and pre-populate them. That saves a lot of complication and is much faster. Use report functionalities. At the end of the day, that is what functions like runningsum are designed for.
79
3. Set the appropriate cardinalities. 4. Join the SALE_PREVIOUS_YEAR (SALE) table to the CLIENT, SHOWROOM, and SALE_MODEL tables. Set the appropriate cardinalities. 5. Add a SALE_PREVIOUS_YEAR context. Tip: This context mirrors the existing SALES context. You can make a copy of the SALES context as follows: a. Open List Mode, and select the SALES context. b. Right-click the SALES context in the Context zone in List Mode. c. Select Insert Context. The New Context window appears, with all joins from the original SALES context selected. d. Name the context SALE_PREVIOUS_YEAR and remove all joins referring to the original SALE table:
CLIENT.CLIENT_ID = SALE.CLIENT_ID SHOWROOM.SHOWROOM_ID = SALE.SHOWROOM_ID SALE.SALE_ID = SALE_MODEL.SALE_ID SALE.SALE_TYPE = 'S' SALE.SALE_DATE between FINANCE.FP_START and FINANCE.FP_END
e. Replace the removed joins with the SALE_PREVIOUS_YEAR alias table joins. Ensure all newly created joins are included in the SALE_PREVIOUS_YEAR context. 6. In the Sales class, create a new Previous Year Sales Figures subclass. Insert the following objects: Sales Total this year:
sum(SALE.SALE_TOTAL)
Note: A Sales Total object, with the same SELECT syntax, already exists in the YTD Measure Objects class (subclass of Sales). Instead of creating a new object with the same
80
syntax, you can create a new object in the Sales MAT subclass that references the existing Sales Total object using the @select function.
@select(YTD Measure Objects\Sales Total)
7. Save your changes and test the new objects in Web Intelligence Rich Client. Your results should look similar to this example:
3. Join the SALE_RUNNING_SUM (SALE) table to the CLIENT, SHOWROOM, and SALE_MODEL tables. 4. Set the appropriate cardinalities.
81
6. In the Sales class, create a new Accumulating Sales Figures subclass. Insert the following objects: Sales Total:
sum(SALE.SALE_TOTAL)
Note: Either use the syntax shown above or use the @select function to reference the existing Sales Total object in the YTD Measure Objects class (subclass of Sales).
@select(YTD Measure Objects\Sales Total)
Month Number:
right(FINANCE_PERIOD.FP_MONTH,2)+0
Note: Either use the syntax shown above or use the @select function to reference the existing Financial Month object in the Finance Period class.
right(@select(Finance Period\Financial Month),2)+0
7. Hide the Month Number object. 8. Save your changes and test the new objects in Web Intelligence Rich Client. Run a report with Financial Month, Sales Total, Sales Total Running Sum, and Sales Total Running Average. The Sales Total Running Sum column displays a cumulative aggregation of each Sales Total cell plus the previous period cell value, so the row at Month 02 displays the Sales Total of Month 01 + Sales Total of Month 02, the row at Month 03 displays the Sales Total of Month 01 + Sales Total of Month 02 + Sales Total of Month 03, and so on. The Sales Total Running Average column calculates a cumulative aggregation of each Sales Total cell plus the previous period cell value, divided by 2, 3, 4, and so on, depending on the number of cells added up. Your results should look similar to this example:
82
83
84
Lesson summary
After completing this lesson, you are now able to: Create complex predefined conditions Work with advanced LOVs Work with advanced join syntaxes
85
86
Lesson 5
Securing Universes
Lesson introduction
Different aspects of universe security can be managed at different levels: in the universe connection; in the Central Management Server (CMS); and directly at universe level. Universe level security, in the form of restriction sets, is covered in the BusinessObjects XI 3.0/3.1: Universe Design course. This lesson looks at security at connection and CMS level, combined with the use of universe restriction sets. After completing this lesson, you will be able to: Define connection and user credential parameters Work with Central Management Server (CMS) universe security Work with table mapping
87
Use specified user name and password: The user name and password for the data source authentication are used. Use Single Sign-On when refreshing reports at view time:
88
When selected, the user name and password used to access the CMS are automatically used as database login parameters. Once users are logged onto BusinessObjects Enterprise, single sign-on to the database enables them to perform actions that require database access, for example, viewing and refreshing Web Intelligence documents without having to provide their logon credentials again. See the Business Objects Enterprise Administration guide for information on setting Single Sign-On (SSO). Use BusinessObjects credential mapping: The user is prompted for a database user password associated with their BusinessObjects account to refresh a report. This is set using the parameters dbuser and dbpass. These are set at the administrative level. Refer to Business Objects Enterprise Administrator's Guide for information on setting up this option. This option is used in a deployment where each Enterprise user is bound to a Database user to enforce Database security and monitoring on all users. When this option is selected for a connection, all users in the CMS that need to use this connection require having their database user credentials set in the CMS. Those credentials are known as dbuser and dbpass variables and can also be used with the @variable function.
89
90
91
Connection
The universe connection to the data source. You can select an alternative connection for the universe. Options to limit the size of the result set and query execution time. Options to control the SQL generated for queries. You can apply column-level security. You can define a WHERE clause that restricts access to row and limits the result set returned by a query. You can replace a table referenced in the universe by another table in the database.
Query controls
Object access
Row access
92
The Available Restrictions pane in the left-hand side of the Manage Access Restrictions dialog box lists all the restriction sets currently available to the universe. The users and groups defined for each restriction set are listed in the Available Groups and Users pane, in the right-hand side of the dialog box. You can create, edit, and delete a restriction set at any time once the universe has been exported to the CMS. You can create multiple restrictions depending on the query needs of a target user group.
93
GROUP BY SHOWROOM.SHOWROOM_NAME
Here is the SQL created for the same simple query after a table mapping restriction has been applied. All references to the Annual_Figures table have been replaced with the Annual_Figures_Euro table.
SELECT SHOWROOM.SHOWROOM_NAME, sum(MotorsEURO.dbo.ANNUAL_FIGURES_EURO.ANNUAL_SALE_VALUE) FROM SHOWROOM INNER JOIN MotorsEURO.dbo.ANNUAL_FIGURES_EURO ON (SHOWROOM.SHOWROOM_ID=MotorsEURO.dbo.ANNUAL_FIGURES_EURO.SHOWROOM_ID) GROUP BY SHOWROOM.SHOWROOM_NAME
Note: All database tables in a universe must be on the same RDBMS platform. For example, you cannot include tables from a SQL Server database and an Oracle database in the same universe.
94
The six tabs in this dialog box allow you to define the type of restriction you want to include in this restriction set. Caution: The Reset button at the lower left corner resets every change made in any tab. It resets all options back to the defaults. 4. In the Restriction Name field, type the name you want to apply to the restriction. 5. In the Edit Restriction dialog box, click the Table Mapping tab.
95
In this tab, you can define the replacement of a table referenced by an object in the universe by another table for a specific user or group of users. 6. Click Add in the Table Mapping tab. The New Table Mapping dialog box appears. 7. If you know the exact names of the tables, you can type them in the text boxes. Otherwise, use the Select button to select the original and replacement tables. 8. When you have selected the tables, click the Check All button to validate the status of the mapping settings. 9. If you have completed your restriction set, click OK to save the changes, otherwise navigate the remaining tabs to apply further restrictions.
Instructions
In this activity you insert tables from the MotorsEURO database, which contain data in Euros instead of US dollars.
96
In addition you use the table mapping feature in a restriction set to substitute four tables from the Motors database with the new tables from the MotorsEURO database. 1. Arrange your structure to be able to add four additional tables. Launch the Table Browser and expand the MotorsEURO (and dbo) node.
2. Insert the following tables into your structure: ANNUAL_FIGURES_EURO QUARTER_FIGURES_EURO SALE_EURO MODEL_EURO Note: These tables remain in your structure as stand-alone tables. 3. Save your universe and export it to the location specified by the instructor. To be able to use the Manage Access Restrictions menu you need to export your universe. A CUID is assigned, when you export your universe, allowing you to apply security to your universe file. 4. Go to Tools Manage Security Manage Access Restrictions and create a table mapping restriction set called Sales_Euro. 5. In the Table Mapping tab click Add. 6. In the Original Table field select ANNUAL_FIGURES. In the Replacement Table field, select ANNUAL_FIGURES_EURO from the MotorsEURO database and click OK. Repeat the for the remaining MotorsEURO tables: QUARTER_FIGURES_EURO SALE_EURO MODEL_EURO 7. Select Check All and click OK. 8. Apply this restriction set to the sales user. Check with the instructor for the exact user name to use. 9. Preview the restriction to check that it is correct. 10.Save your universe and export it to the location specified by the instructor. 11.Log onto Web Intelligence Rich Client with the sales user account. Check with the instructor for the exact user name to use. 12.Create a new report based on your exported Motors universe. 13.Run a query with Client Name and Sales Revenue. 14.View the SQL.
97
The SALE and SALE_MODEL tables are replaced by the SALE_EURO and MODEL_EURO tables. 15.Run the report to view the results returned. The Sales Revenue data is in Euros. You can format the report to Euro currency in Web Intelligence Rich Client. 16.Run a query with Showroom and Sales Revenue. View the SQL. The ANNUAL_FIGURES table is replaced by the ANNUAL_FIGURES_EURO table.
98
99
Lesson summary
After completing this lesson, you are now able to: Define connection and user credential parameters Work with Central Management Server (CMS) universe security Work with table mapping
100
Lesson 6
101
102
Also, if you modify the name and contents of several classes within a single universe that multiple reports are dependent on, you can move the changed universe into production together with all dependant reports.
103
In BusinessObjects Enterprise XI 3.0/3.1 there are new import scenario options, and a feature called incremental importing, which greatly enhance the administrators choices for content promotion.
Import scenarios
When using the Import Wizard to promote an object from one BusinessObjects Enterprise XI 3.0/3.1 deployment to another, the wizard allows you to use either the objects CUID or its name and path to determine whether the object already exists on the destination environment. It also lets you specify what you want the wizard to do when it finds that an object already exists on the destination environment.
When you are matching objects by CUID, and the Import Wizard finds a matching object on the destination environment, you have three options:
Scenario option Description
If the Import Wizard finds an object in the destination environment with the same CUID, it updates the destination's object. If the Import Wizard does not find an object in the destination environment with the same CUID, but it finds an object with the same
104
Scenario option
Description
name, it imports the object from the source environment and then renames that object. If the Import Wizard finds an object in the destination environment with the same CUID, it updates the destination's object. If the Import Wizard finds an object on the destination environment with the same name but different CUID, it does not import the object from the source environment. If Import Wizard finds an object on the destination environment with the same CUID, it does not import the object.
When you are matching objects by name and path, and the Import Wizard finds a matching object on the destination environment, you have three options:
Scenario option Description
Keep the destination object and import a renamed copy of the object.
If Import Wizard finds that an object already exists on the destination environment with the same name and path, it imports the source's object and renames it. If Import Wizard finds that an object already exists on the destination environment with the same name and path, it updates the destination environment's version with the source's. If Import Wizard finds that an object already exists on the destination environment with the same name and path, it does not import the source's version.
Note: Matching objects by name and path is not an option when importing content from a BIAR file. When you import from Business Intelligence Archive Resource (BIAR) files, objects are matched by CUID.
105
Incremental import
By default, the Import Wizard automatically imports dependent objects. For example, when you import report objects, the Import Wizard also imports the universes and universe connections that the reports use. If you are updating objects that already exist on the destination environment, the Incremental import screen appears. This screen prompts you to specify what type of objects and rights to want to overwrite on the destination environment with the objects from the source environment, when there is a match found. These options are safeguards that override what you selected on the Import scenarios screen. The Incremental import screen allows you to import objects without overwriting dependent objects that already exist on the destination environment. If you want to import report objects without importing a universe or connection that would overwrite a universe or connection on the destination environment, you can specify this on the Incremental import screen. Note: An object refers to any type of object except universes, universe connections, and groups.
106
Imports all universes and all connection objects. You cannot select individual universes or connections. Imports all universes, and only connection objects used by those universes. Imports all universes and connections used by the selected documents. This option also enables you to select additional universes to import, even if they are not used by any document.
Import all universes and only connection objects used by these universes.
Import the universes and connections that the selected Web Intelligence and BusinessObjects documents use directly.
107
If you selected the third option, you are asked to choose which universes you want to move to production.
The eFashion and Island Resort Marketing check boxes are grayed out. The import wizard selected these two universes by default, as certain reports use it. Additional universes can be selected, or if you select a Web Intelligence document to import, the Import Wizard automatically selects the associated universes for import. If a universe is a derived universe, then all relevant core universes and their connections are also imported.
108
BIAR files can be used to export BI object content to XML for deployments without network access to the source repository. This can help customers that have stringent firewall requirements around their different development and production deployments, or customers that have separate geographic deployments that do not have connectivity between them. By using a BIAR file, there is no direct contact from one environment to another, and it can help efficiently propagate incremental moves from development to quality assurance, to production. Note: This requires additional steps to move between environments, and BIAR files can be large.
XML files
Essentially the BIAR file is a binary zip file that contains a collection of XML files for individual documents and universes. Every BIAR file has at least one single specific XML file (BusinessObjects.xml) that acts as the root deployment descriptor. This file tells the deployment engine in what order to deploy the object so that the dependency and security model can be deployed correctly. For example, connection objects must be created with the correct CUID before universes can refer to them, and universes must be deployed with the correct CUID before reports can reference them.
Version Control
Using the BIAR file method also provides a file based archive that can be placed in version, or source control system. Universes and reports have an individual XML file representation in the BIAR file, allowing for version control. For example, the content creator creates a set of reports and a universe that are tested in the development system. When the development tests are complete, the reports and universe are exported to a BIAR file. The tester that has direct access to the QA staging area checks in the BIAR file directly, or unzips the BIAR file to a specific folder structure. Note: A BIAR file is a standard zip file and can be unzipped accordingly; it acts similar to a WAR or JAR file. Individual documents and universes can be checked in and out of this structure in a granular fashion. Testers can change the label in the Version Control System to "ready for production" after testing, and the administrator can import the BIAR into the production area. This can be useful in an environment where deployment to quality assurance, to production is done by different people with different security rights, and where there is a requirement that code comes through a version control system prior to going into production. Using the BIAR file functionality in this way can provide an audit history of who changed what and when. Universes and report dependencies in the BIAR file can be granularly, and individually version controlled in your choice of Version Control Systems, for example Perforce, PVCS, or SourceSafe.
109
5. Type in the location and BIAR file name in the BIAR file box. Alternatively select the ellipse button to browse to a location, and enter the name of the BIAR file.
6. Click Next. 7. Specify the objects that you wish to copy from the test environment to production. By default all objects are selected. Each selected option is presented in a later wizard screen. For example, when you select "Import folders and objects" in this step, you are later able to refine your selection to just certain folders or reports. Note: When using a BIAR file as a destination, your selected options are stored into the file, and can be later imported into production. 8. Follow the wizard instructions, making the required selections, and click Next until the Ready to Import screen appears.
110
9. The wizard provides a summary of the elements you intend to import to the BIAR file. If these settings appear correct, click Finish to generate the BIAR file. If your selections appear incorrect, click Back to modify your selections. The Import Progress screen appears. After the import is complete, the dialog box displays a summary of the import. 10.Click Done to close the Import Wizard.
To promote universes and universe connections from a development environment to a production environment
This scenario describes promoting universe objects from one BusinessObjects Enterprise XI 3.0/3.1 deployment to another XI 3.0/3.1 deployment. By default, the Import Wizard imports any universe connections that the universes that you selected rely on. If you want to promote a universe to the destination, and do not want to overwrite the universe connection on the destination environment, ensure that you clear the Overwrite connection contents checkbox on the Incremental import screen.
111
1. Start the Import Wizard. Select Start Programs BusinessObjects XI 3.0/3.1 BusinessObjects Enterprise Import Wizard. 2. Specify the source and destination environments. 3. On the Select objects to import screen, select Import universes. 4. On the Import scenario screen, specify whether you want to match by CUID or name and path, and what you want the Import Wizard to do if it finds an object that already exists on the destination environment. 5. On the Increment import screen: a. If you want to update a universe that already exists on the destination environment, select the Overwrite universe contents check box. b. Specify whether you want to overwrite the universe connections on the destination. If you want to update universe connections that already exist on the destination environment, select the Overwrite connection contents check box. c. To ensure that you don't overwrite any objects or object rights, clear the Overwrite object contents and Overwrite object rights check boxes. d. If the Overwrite group and user membership check box appears, ensure that it is cleared. e. Click Next to continue. 6. On the Import options for universes and connections screen, select Import all universes and only connection objects used by these universes. 7. Complete the import process. The Import Wizard imports the universes that you selected to the destination environment. If you choose to not overwrite universes connections, the connections that the selected universes rely on are not imported, and the universe connections that exist on the destination environment are not touched. The relationships between the universes and the universe connections are maintained.
112
When a user accesses a report, the document looks for the correct data provider using a unique ID assigned to the universe. It looks for the universe initially stored in the Development folder. If the users do not have access to the Development folder, but do have access to the Production folder, then the universe from the Production folder is used. They can edit and refresh the report. It is important to ensure that the designer moves, not copies, the universe from development to production. Copying a universe provides it with its own CUID, and produces two different versions of the universe in production and development. Reports created against the development universe can not be refreshed against the production universe. The end user may receive an error message. Use test folders only if: It is not possible to implement multiple CMS environments. Security to universes is applied at folder level rather than per individual universe file.
113
Use the BIAR file to move all, or incremental loads from one environment to another.
Instructions
Create two new folders: Development and Production. Folders can be created directly in Universe Designer, as well as in the Central Management Console. In this activity the folders are created in Universe Designer. Create a Web Intelligence Rich Client report based on your Motors universe and explore what happens when the universe is moved and/or copied from the development folder to the production folder. 1. In Universe Designer go to File Import to import your Motors universe from the folder it was exported to in the last activity. 2. Click File Export. 3. In the Export Universe menu click Browse. 4. Right-click the folder specified by the instructor and select New Folder. Name the folder Development_xx, where "xx" stands for your initials. 5. Select your new Development folder and click OK twice to export your Motors universe to this new folder. As your universe was exported in the previous activity, a warning message appears. 6. Select Move to ensure there is only one version of your Motors universe. 7. Log into Web Intelligence Rich Client with the sales user. Check with the instructor for the exact user name to use. 8. Create a new Web Intelligence Rich Client document using your Motors universe from your Development folder. 9. Add the Client Name and Sales Revenue objects to the report. 10.Save the report locally as Dev_xx.wid file, where "xx" stands for your initials. 11.Log into Universe Designer with the login name used throughout the course (the same login name used in step 1), and import your Motors universe from your Development folder. 12. Click File Export. 13.In the Export Universe menu click Browse. 14.Right-click the folder specified by the instructor (same location used to create the Development_xx folder) and select New Folder. 15.Name the folder Production_xx, where "xx" stands for your initials.
114
16.Export your universe to your new Production folder. A warning message appears. 17.Select Move to ensure there is still only one version of your Motors universe. 18.Log into Web Intelligence Rich Client with the sales user. Check with the instructor for the exact user name to use. Use the same user name that was used in step 5. 19.Open your Dev.wid file. Refresh the data, and verify that you can edit the query. Although your universe is in a new location the CUID has been retained and your report can refresh correctly. 20.Log into Universe Designer with the login name used throughout the course (the same login name used in step 1 and step 6), and export your universe to your Development folder. 21.Select the Copy option. The original version of your Motors universe file remains in your Production folder, and a copy of the same universe is created in your Development folder. 22.Import your Motors universe from your Production folder. 23. Click File Export. 24.In the Export Universe menu click Browse. 25.Export your Motors universe file (previously located in your Production folder) to the folder location specified by the instructor. Note: The location the original Motors universe is now exported and is not accessible to the sales user. 26.Log into Web Intelligence Rich Client with the sales user. Check with the instructor for the exact user name to use. Use the same user name that was used in step 5 and step 10. 27.Open your Dev.wid file. Refresh the data, and verify that you can edit the query. The copy of your universe in your Development folder has been given a new CUID. The report can not be refreshed against this universe, and the test sales user has no access to the other universe location.
115
116
Lesson summary
After completing this lesson, you are now able to: Move content from development to production
117
118
Lesson 7
119
Optimizing universes
As a designer you can apply several parameters that are universe based or data access specific in order to maximize the potential of a universe. In the BusinessObjects XI 3.0/3.1: Universe Design course you looked at how you can set specific parameters when creating a new universe or via File Parameters menu. This unit looks at a more in depth insight into the parameters that can be set in the Universe Parameters Parameters menu, together with a look at other performance enhancing parameters that can be specified in the BusinessObjects product suite. Describe data access files and connection parameters Set up a trace file Use BusinessObjects dynamic SQL parameters
Note: Refer to the BusinessObjects XI 3.0/3.1 Designer 's Guide and the for more information on the individual data access files (<driver>.stg, <driver>.sbo, <driver>.prm, <driver>.cod).
120
Note: The cs.cfg file is an XML file. The Document Type Definition (DTD) file that relates to each element used in the cs.cfg file is in the same directory. Ensure that, when editing and/or modifying the XML file, the cs.dtd is available.
>> and >= does not capture any SELECT statements. == and <= does capture SELECT statements to data source only (universe connection). << captures everything, including SQL communication with the CMS.
2. Open the cs.cfg file in an XML editor. The cs.cfg file is located in C\Program
Files\Business Objects\BusinessObjects Enterprise 12.0\win32_x86\dataAccess\connectionsServer.
121
3. Navigate to the <Traces> XML element and set <Traces ClassID="csTRACELOG" Active> equal to Yes. Note: You can specify a subset of access drivers that you want to trace. BusinessObjects allows you to filter the SQL statements according to the database type you want to trace. In the following example, Oracle, Teradata, and ODBC access drivers are traced:
<Traces ClassID="csTRACELOG" Active="Yes"> <Trace Name="MiddleWare" Active="Yes"> <Trace Name="Oracle" Active="Yes"/> <Trace Name="Sybase" Active="No"/> <Trace Name="Informix" Active="No"/> <Trace Name="Teradata" Active="Yes"/> <Trace Name="DB2" Active="No"/> <Trace Name="DB2/iSeries" Active="No"/> <Trace Name="ODBC2" Active="Yes"/> <Trace Name="ODBC3" Active="Yes"/> <Trace Name="OLEDB" Active="No"/> </Trace> </Traces>
4. Save the changes. Click Save. 5. Restart the services in the Central Configuration Manager (CCM). When now launching a BusinessObjects client module, you generate a log file that contains information regarding internal functions, and all of the SQL statements that are going to the database. The SQL statements are inserted into the client log file itself.
122
Description
Check this box if you want your connection to disconnect immediately after the transaction is completed. Users have to reconnect each time they want to access data. Check this box if you want your connection to stay active for a defined period of time. You must also enter a value for the number of minutes. This is the default Pool timeout value.
Keep the connection active during the whole session (local mode only)
Check this box if you want your connection to stay active during the entire session of the product. The connection ends when the user exits the application.
Pool timeout
If you select Keep the pool active for in the previous field, this parameter specifies the length of time to keep the connection open.
Login time-out
Specifies the number of seconds that must be spent to establish a connection before an error message is displayed.
123
ConnectInit
This parameter is used to declare database specific session statements when the connection is established. These statements are not parsed and should therefore be carefully set. The syntax is defined in the universe Custom Parameters menu. An example Oracle database syntax is shown below:
ConnectInit ALTER SESSION SET CURRENT_SCHEMA = @variable('BOUSER')
It can also be used with Informix Dynamic Server to add SQL statements to a connection that are executed once the connection is opened. For example:
ConnectInit SET PDQPRIORITY HIGH
For Informix Dynamic Server, the PDQPRIORITY environment variable determines the degree of parallelism that the database server uses and affects how the database server allocates resources, including memory, processors, and disk reads.
ConnectInit = SET OPTIMIZATION FIRST ROWS
The ConnectInit parameter can be useful for: Auditing: Using the ConnectInit parameter, it is possible to send commands to the database when opening a session. This can be used to set database-specific parameters used for auditing purposes, as you can monitor the session_id and user that is accessing the universe. For example you can use a parameter like:
ConnectInit = Begin DBMS_SESSION.SET_IDENTIFYER('@variable('BOUSER')');COMMIT;END;
For auditing purposes, you can set the following variables: BO username: @variable('BOUSER') Universe name: @variable('UNVNAME') Document name: @variable('DOCNAME') Data provider name: @variable('DPNAME') Data provider type: @variable('DPTYPE')
Query Banding: Some Relational Database Management Systems (Teradata for example) can provide a query band (like banding a bird to track its flight path) with each query. The band can contain any
124
number of attributes and values that provide detailed information about the query and may be referenced by workload management rules during the query classification phase. Query banding is especially valuable for applications that send work through pooled sessions, such as traditional session pool applications, analytic applications using pooled sessions, business intelligence (BI) tools and new Web service applications. You can use query banding to aqcuire information useful for workload management or tracking the use of the data warehouse. Setting session specific database parameters: Depending on the RDBMS used you can set session specific database parameters. For example, with Informix Dynamic Server, you can use the SET Database Object Mode statement to change the filtering mode of constraints of unique indexes, or to enable or disable constraints, indexes, and triggers. Enforcing Oracle Virtual Private Database: Oracle Virtual Private Database enforces security, to a fine level of granularity, directly on database tables, views, or synonyms. Because you attach security policies directly to these database objects, and the policies are automatically applied whenever a user accesses data, there is no way to bypass security. Using the ConnectInit parameter, you can specify the number of seconds that must be spent to establish a connection before an error message is displayed.
Some useful hints that you can use are as follows. Consult your Oracle documentation for a full list:
Hint FIRST_ROWS What it does...
Optimizes response time. Use rule-based optimization and not cost. Performs a full table scan on the table. Scans table by rowid.
RULE
FULL
ROWID
125
Hint
What it does...
INDEX_FFS
Perform a fast full scan on the index rather than on the table.
An example of the FIRST_ROWS parameter is outlined below: 1. On the Custom Parameters page, click Hints. 2. Type /* + FIRST_ROWS */ in the values box, and click Finish. 3. The SQL generated in the client tool looks similar to this:
SELECT /* + FIRST_ROWS */ CLIENT.CLIENT_ID FROM CLIENT
126
BEGIN_SQL
SQL statements can be prefixed with the BEGIN_SQL parameter. The BEGIN_SQL parameter can be configured to insert SQL orders that are executed before BusinessObjects-generated SQL statements. This ensures that the orders are executed before all generated SQL statements. This function works with any database that supports passing parameters before the SELECT statement. The following are some examples of use: Terradata: The BEGIN_SQL parameter can be used to monitor and manage database usage based on query origin details provided within the executed SQL. Oracle: The BEGIN_SQL parameter can be used to turn on read-only transactions. Netezza: The BEGIN_SQL parameter can be used to trigger optimization options.
END_SQL
The End_SQL parameter is used to append a string to the SQL sent to the database each time a query is run. This parameter is useful for query banding and auditing. DBAs often need to monitor query usage. The End_SQL parameter allows designers to input variables. By using a parameter like @variable('BOUSER'), the DBA can clearly see who sent the query with what results. This can aid system optimization, and can also be useful in a situation where a long running query must be terminated, or when the system has to be stopped for maintenance reasons. Variables that can be used are: BO username: @variable('BOUSER') Universe name: @variable('UNVNAME') Document name: @variable('DOCNAME') Data provider name: @variable('DPNAME') Data provider type: @variable('DPTYPE')
127
The joins are generated in the FROM clause, but the REGION.REGION_NAME In ('East','North') restriction is placed in the WHERE clause. These types of WHERE clause restrictions can be moved to the FROM clause. This can be achieved be altering the setting for the FILTER_IN_FROM parameter. The FILTER_IN_FROM parameter determines if query conditions are included in the FROM clause. Note: This parameter only works in conjunction with the ANSI92 parameter, either as a dynamic SQL parameter, or set in the PRM file. As with the ANSI92 parameter, the FILTER_IN_FROM parameter has two settings: Yes, and No.
FILTER_IN_FROM: No
As seen in the above example, query filters are still generated in the WHERE clause instead of in the FROM clause:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME, count(CLIENT.CLIENT_ID) FROM CLIENT INNER JOIN REGION ON (REGION.REGION_ID=CLIENT.REGION_ID) WHERE REGION.REGION_NAME In ('East','North') GROUP BY CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME
When set to No, standard SQL is generated, or in case ANSI92 is set, the default ANSI92 SQL generation takes place. All joins are placed in the FROM clause, but any query filters and restrictions remain in the WHERE clause.
FILTER_IN_FROM: Yes
Setting the FILTER_IN_FROM parameter to Yes, moves the WHERE clause conditions seen in the previous section to the FROM clause.
128
When the end user creates a new Web Intelligence Rich Client report using Client Name, Region, with a quick filter applied to Region, the generated SQL looks like this:
With the FILTER_IN_FROM parameter set to Yes, a query with Client Name, Region, and Sales Revenue produces the following SQL, with the Sale_Type = 'S' join restriction placed in the FROM clause:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME, sum(SALE_MODEL.SALE_QTY * MODEL.MODEL_PRICE * ((100 SALE.SALE_DISCOUNT) / 100)) FROM MODEL INNER JOIN SALE_MODEL ON (SALE_MODEL.MODEL_ID=MODEL.MODEL_ID) INNER JOIN SALE ON (SALE.SALE_ID=SALE_MODEL.SALE_ID AND SALE.SALE_TYPE='S') INNER JOIN CLIENT ON (CLIENT.CLIENT_ID=SALE.CLIENT_ID) INNER JOIN REGION ON (REGION.REGION_ID=CLIENT.REGION_ID) GROUP BY CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME)
Note: By changing the FILTER_IN_FROM parameter to Yes, this parameter is applied to the whole universe. The FILTER_IN_FROM functionality can however be applied to individual classes and objects.
129
count(CLIENT.CLIENT_ID) FROM CLIENT INNER JOIN COUNTRY COUNTRY_REGION ON (COUNTRY_REGION.COUNTRY_ID=CLIENT.COUNTRY_ID) GROUP BY CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, COUNTRY_REGION.COUNTRY_NAME
For databases that support ANSI92 SQL syntax, the ANSI92 parameter is automatically applied at data access driver (<driver>.prm) level. The PRM file contains the following parameter that is set to ANSI92:
<Parameter Name="OUTERJOINS_GENERATION">ANSI_92</Parameter>
As the PRM file is accessed via the connection, the ANSI92 setting is applied on all universes that access the same middleware connection. If you want to only apply ANSI92 syntax to selected universes, the option in the PRM file needs to be set to No:
<Parameter Name="OUTERJOINS_GENERATION">NO</Parameter>
The ANSI92 dynamic SQL parameter can instead be set to Yes directly in the universe.
Note: Remember that the PRM file is a system file and should be used/adapted responsibly. Ensure that a backup version is available to restore the defaults if changes have been applied.
ANSI92: No
With the ANSI92 parameter set to No, SQL generation behaves according to the OUTER_JOIN_GENERATION parameter in the PRM file. If in the PRM file, the OUTER_JOIN_GENERATION parameter is set to No, standard SQL output is generated. The SQL output for a query using Client Name, Region, and Number of Clients is as follows:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, COUNTRY_REGION.COUNTRY_NAME, count(CLIENT.CLIENT_ID) FROM CLIENT, COUNTRY COUNTRY_REGION WHERE (COUNTRY_REGION.COUNTRY_ID=CLIENT.COUNTRY_ID) GROUP BY CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, COUNTRY_REGION.COUNTRY_NAME
ANSI92: Yes
By setting the ANSI92 parameter to Yes, join references are moved from the WHERE clause into the FROM clause, and the same query outputs the following SQL statement:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, COUNTRY_REGION.COUNTRY_NAME,
130
count(CLIENT.CLIENT_ID) FROM CLIENT INNER JOIN COUNTRY COUNTRY_REGION ON (COUNTRY_REGION.COUNTRY_ID=CLIENT.COUNTRY_ID) GROUP BY CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, COUNTRY_REGION.COUNTRY_NAME
The structure now shows the join references in the FROM clause using INNER JOIN references.
In the Advanced Join Properties dialog box you can determine which classes and objects are included in the FROM clause in the generated SQL.
131
You can specify the following: Default behavior: When applied, all classes and objects that are associated with this join are greyed out and can not be selected. The standard ANSI92 rules are applied and if a quick filter is used in the query, the generated SQL displays the filter results in the WHERE clause. All objects in FROM: When applied, any condition/quick filter applied to the objects associated with this join are included in the FROM clause. Note: The classes and objects remain greyed out in the Advanced Join dialog box. No objects in FROM: When applied, all classes and objects that are associated with this join are greyed out and can not be selected. The standard ANSI92 rules are applied and if a quick filter is used in the query, the generated SQL displays the filter results in the WHERE clause. Selected objects in FROM: When applied, the classes and objects in the Advanced Join dialog box are activated. You can select the individual classes and objects. If a quick filter is applied to a selected object, the generated SQL displays the filter results for that object in the FROM clause. If a quick filter is applied to an object that was not selected, the generated SQL displays the filter results for that object in the WHERE clause.
132
6. Click the Advanced button. Note: This button is active only if the ANSI92 dynamic SQL parameter is set to Yes or when the PRM file has ANSI92 set as the default. The Advanced Join Properties dialog box opens.
133
134
9. Click OK to apply the changes. 10.Repeat steps for other joins in the schema.
Where string1 is the string to test for a null value and replace_with is the value returned if string1 is null.
135
When the query is based on a MS SQL Server data source, the SQL generated uses COALESCE as NVL is not supported. The end result is the same. The COALESCE function returns the first non-null expression among its arguments. The syntax for COALESCE is:
COALESCE(expression [,...n])
Where expression is an expression of any type and n is a placeholder indicating that multiple expressions can be specified. All expressions must be the same type or must be implicitly convertible to the same type. If all arguments are NULL, COALESCE returns NULL. Note: The COALESCE syntax COALESCE(expression [,...n]) is equivalent to the following CASE statement:
CASE WHEN (expression IS NOT NULL) THEN expression1 ... WHEN (expression IS NOT NULL) THEN expressionN ELSE NULL
136
10.Launch Web Intelligence Rich Client and create a new document based on your Motors universe. 11.Drag the Client Name, Sales Revenue, and Rental Revenue objects into the Result Objects pane. 12.Click View SQL to see the results. What has happened to the results? 13.Log out of Web Intelligence Rich Client.
4. Click Replace. The parameter syntax for END_SQL is now modified. Note: The END_SQL parameter in the universe properties allows you to insert a string at the end of the SQL generated by a query. The variables are stated in a comment field and evaluated when running a query. The query is generated with the explicit sentence. 5. Click OK to close the Parameter dialog box. 6. Save your universe locally. 7. Test the results in Web Intelligence Rich Client. Run a query with Showroom and Sales Revenue. 8. Click the View SQL icon. The generated SQL appears in the SQL Viewer. The last line in the SQL contains the syntax added to the END_SQL parameter in the Parameter dialog box. 9. Run the query and return to the Query Panel by editing the query. 10.View the SQL. The END_SQL was executed at query run time. When viewing the SQL after running the query, you can see that the variable values are populated.
137
4. Click Replace and then OK. 5. Double-click the join between the CLIENT and the REGION tables. 6. Click Advanced. 7. Choose the Selected objects in FROM option. 8. Select the Region and the Client Name objects only. Note: All detail objects below the Client Name are NOT selected. 9. Click OK twice. 10.Save your universe locally. 11.Create a new Web Intelligence Rich Client report with the Client Name and Region objects. Apply a Quick Filter on the Region object and select a few values from the list. 12.View the SQL. Is the Region object condition showing up in the FROM clause? 13.Remove the filter and apply a Quick Filter on the Client Name object and select a few values from the list. 14.View the SQL. Is the Client Name condition showing up in the FROM clause? 15.Remove the filter and drag in the Area Code detail object. 16.Apply a Quick Filter on the Region object and select the East Coast value. 17.Apply a second Quick Filter on the Area Code object and select the values 10011 and 10012. 18.View the SQL. What is happening with the WHERE and FROM clauses? Why is this happening? 19.Return to Universe Designer and open your Motors universe file. 20.Change the FILTER_IN_FROM parameter to Yes. Click Replace. 21.Click OK to close the Parameter dialog box. 22.Launch Web Intelligence Rich Client and create a new report with Client Name, Region, and Sales Revenue. Add a quick filter on Region, and select the values East and North. 23.Click View SQL to see the results. The SQL statement contains the INNER JOIN statements and there is no longer a WHERE clause generated. 24.Log out of Web Intelligence Rich Client. 25.Change all altered parameters in your universe back to their default settings (END_SQL, JOIN_BY_SQL, ANSI92, and FILTER_IN_FROM).
138
139
For example, a query in Web Intelligence Rich Client, with Client Name in the Result Objects pane, and Client Country in the Query Filters pane, restricted on the countries United Kingdom and the United States, produces the following SQL when primary key index has been applied:
SELECT CLIENT.CLIENT_LASTNAME +', '+ CLIENT.CLIENT_FIRSTNAME, FROM CLIENT INNER JOIN REGION ON (CLIENT.REGION_ID=REGION.REGION_ID) INNER JOIN COUNTRY COUNTRY_REGION ON (COUNTRY_REGION.COUNTRY_ID=REGION.COUNTRY_ID) WHERE ( COUNTRY_REGION.COUNTRY_ID In ( 44,1 ) AND (COUNTRY_REGION.COUNTRY_ID=CLIENT.COUNTRY_ID) )
The restricted country name values have been replaced by their respective primary key index value to help increase query performance. Note: If the FILTER_IN_FROM parameter is also set for the universe, the index awareness condition appears in the FROM clause, instead of in the WHERE clause.
The Country_Region table is no longer referenced in the SQL. This table no longer shows up in the FROM clause, nor in the WHERE clause as a join to the Client table or as a table used to retrieve the condition values from.
140
141
When running a query in Web Intelligence Rich Client using Client Name and Region objects in the Result Objects pane, and the Client Country object in the Query Filters pane, the SQL generated is as follows:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME FROM CLIENT INNER JOIN REGION ON (REGION.REGION_ID=CLIENT.REGION_ID) WHERE CLIENT.COUNTRY_ID In (1,44)
The Region table is used to restrict on Country_Region (Country_ID) as it is one of the foreign key entries and the Country_Region table is not used anywhere else in the query and is subsequently dropped from the SQL. Why does BusinessObjects use the Region table and not the Client table? Both tables exist in the FROM clause, however the Region table is used as the Country_ID key replacement. The reason for this is the order in which the foreign keys have been defined. The Country_ID key from the Region table was the last one defined in the list and this is the one that is used in the SQL generation. Rearranging the keys by placing the Country_ID key from the Client table last results in the following SQL instead:
SELECT CLIENT.CLIENT_LASTNAME + ', ' + CLIENT.CLIENT_FIRSTNAME, REGION.REGION_NAME FROM CLIENT INNER JOIN REGION ON (REGION.REGION_ID=CLIENT.REGION_ID) WHERE REGION.COUNTRY_ID In (1,44)
Note: If a shortcut join has been defined between the Country_Region and Client table, this shortcut key takes precedence as the foreign key, even if the last foreign key defined is the Region key.
142
143
144
Do not normalize. Use Multi-Dimensional Modeling instead. Always check integrity. If the universe is bigger than 1MB, divide it into multiple universes. Note: When you select File Open, you load the universe into RAM. If the universe is 1.39 MB, then it uses 1.5MB RAM. This could have an impact on the RAM available to your system. Use aggregate awareness, which speeds up query time by using special tables containing pre-calculated data. Do all aggregation on the server side instead of in the document (this can result in huge time savings). Define aggregate SQL functions on universe measures. Fewer rows get returned from the database thus making reports smaller and the calculation of variables, ranks and alerters quicker. Database connections for a universe should be set to disconnect after each transaction. This ensures that the SQL is terminated cleanly and that the are no treads left open to the database which are inactive. Note: A number of databases are licensed on the number of concurrent connections and if a connection is left open for a period of time when the keep connection active for x minutes is enabled, then end users could experience difficulties in accessing the database. Optimize universe performance and database tuning. Remove unnecessary lists of values, such as on dates and measure objects. Base lists of values on lookup tables. Add any other elements to the universe such as predefined conditions and hierarchies. Test the universe by building queries in BusinessObjects end user querying tools.
145
This prevents users having to spend valuable time formatting data from within the reporting tool every time they create a report.
146
147
Lesson summary
After completing this lesson, you are now able to: Optimize universes Apply foreign key index awareness Apply best practices for universe design
148
Lesson 8
149
150
In the Metadata Exchange panel, you can: Select the data source format to build the universe. This is the source XML file or database view that you use to build a universe. A universe creation wizard takes you through steps to select a connection for the data source, selecting the data components that you want to be mapped to the universe, and finally the generation of the universe. Update an existing universe with data from a data source that has been updated. This is the data source that has been used to create the universe. The source has been updated, and now you want to update the universe with the same modification. A universe update wizard takes you through the steps needed to update the universe. Export a universe to a data source format. You select a data source format to which you can export the universe. The default option available is DB2 Cube Views 8.1, then save the universe in that format. The Metadata Exchange panel takes you through a three-step process to create the universe: Specify the location of the data source file. Select the tables you want to include in the universe. Define the connection to the original data source.
151
3. Select the CWM Relational 1.0/1.1 Metadata format. 4. Click OK. 5. The CWM Relational 1.0 Universe Builder wizard appears. 6. Click Next to continue. 7. In the Universe creation - Step 1/5 wizard page, browse to the location of your XML metadata file.
8. Click Next to continue. The Universe creation - Step 2/5 wizard page displays:
152
9. Select Database1 to highlight it and click Next. The Universe creation - Step 3/5 wizard page displays.
This wizard page displays all the tables and columns in this metadata file. 10.Click the + box next to a table to view the columns in this table. 11.You can select individual tables or columns in the list and use the > button to move them individually into the list in the right-hand side of the wizard box. Or you can use the >> button to move all the contents of the file at once. 12.Click Next to continue. The Universe creation - Step 4/5 wizard page displays. The Universe creation - Step 4/5 wizard page allows you to select the connection the universe uses to connect to the data source. For the purposes of this course, you will not actually connect the universe to a data source, so it is not important which connection is selected here. 13.Type a name for the new universe in the Universe name field. The universe name must be eight characters or less. 14.Select the Advanced button. The Options dialog box displays. In the General tab of the Options dialog box, you can specify the location where trace files can be stored. 15.Click the File Locations tab.
153
The File Locations tab allows you to specify default locations for storing the source XML files and the parameter files associated with the metadata. 16.Click OK to close the Options dialog box. Click Next to continue The Universe creation - Step 5/5 wizard page appears. This page summarizes the connection and file information that are used to create the universe. 17.Click Finish. The universe displays with classes, objects, and joins automatically defined:
Note: You cannot actually check the integrity of this universe, or export the universe to the CMS, because you have not defined a connection to the original data source. 18.Save the universe and close Universe Designer.
154
155
156
You can create a universe based on stored procedures that requires one or more input parameters. Depending on the entered value, the procedure returns the fact data of the value from the appropriate fact table. 1. In Universe Designer, click the Quick Design Wizard button on the toolbar. The Welcome dialog box appears. 2. Click the Click here to choose stored procedures universe check box at the bottom of the dialog box. 3. Click Begin. The Define the Universe Parameter panel appears. 4. Type in a universe name in the Enter the universe name field. 5. Choose the database connection from the Select the database connection list or click New to create a new connection. 6. Click Next. The Create initial classes and objects panel appears. 7. Expand the database node and the database owner node (for example dbo) to select a stored procedure. 8. Click Add. When the stored procedure requires input parameters, the Stored Procedures Editor appears. 9. Select a parameter from the list of parameters. 10.Enter a value for the parameter in the Value field or type in a prompt. 11.Select Use this value or Prompt me for a value. When you enter a value, and when the procedure is executed, the parameter retrieves the columns and the result set structure. This value is passed on to the procedure. 12.If you have selected Prompt me for a value, type in the prompt. You can enter a prompt message or browse to select an existing object (for example, list of subscriber IDs from a table). 13.Click OK. 14.Click Next. 15.Click Finish. The Congratulations dialog box appears.
157
Changes to the database schema affect the source code in only one place, the stored procedure. Any schema changes become a database administration task rather than code revision. Since the stored procedures reside on the server, you can set tighter security restrictions. This saves more trusted permissions for the well-protected stored procedure themselves. Because stored procedures are compiled and stored outside the client application, they can use more sensitive variables within the SQL syntax, such as passwords or personal data. Using stored procedures reduces network traffic. The stored procedure universe feature is useful for customers who already have many programs that cannot be duplicated easily in straight SQL. If the customer is designing a new project, it's better to build a universe or simply add a derived table to an existing universe. Note the following restrictions apply to stored procedures universes: No joins are permitted between objects in stored procedures universes. Filters cannot be used on the stored procedure universe. You cannot link a stored procedure universe to a standard universe. Not all RDBMSs support stored procedures. Consult your database guide to see if yours does. COMPUTE, PRINT, OUTPUT, or STATUS statements contained in stored procedures are not executed. If the stored procedure uses input parameters, they are converted as prompts in a Web Intelligence document. If you want to link the stored procedure to a list of values, you need to create an additional object in the universe to house the LOVs returned.
158
The required .jar files. Any other files that the JavaBean requires. Any specific configuration details that the JavaBeans driver requires. Within a JavaBeans driver, data-retrieval procedures are configured as stored procedures. When configuring a JavaBeans connection, on the Database Middleware Selection screen, of the New Connection Wizard you must select the Filter Stored Procedures Network Layers check-box. If you do not, the New Connection Wizard does not display the JavaBeans drivers that are available.
159
</Parameter> <Parameter Name="URL Format">$DATASOURCE$ </Parameter> </JavaBean> <Parameter Name="Family">Java Beans </Parameter> <Parameter Name="Description File"> bean_excel</Parameter> <Parameter Name="Authentication Mode"> Bypass</Parameter> <Parameter Name="Extensions">bean_excel, javabean</Parameter> </DataBase> </DataBases>
3. Save and close the javabeans.sbo file. 4. Perform any other configuration tasks specified by the JavaBeans developer. 5. Run the Connection Wizard. The JavaBeans datasource that you have configured should appear in the list of available connections. Select the JavaBeans datasource and use the Wizard to configure the connection. When you complete this task, the connection is available for use with a BusinessObjects application.
Instructions
There are two stored procedures available in the Motors database: TenMostExpensiveModels
CustomerOrderHistory
160
Tip: The CustomerOrderHistory stored procedure contains an input parameter for the Client ID 1001. 1. Using the TenMostExpensiveModels stored procedure, create a new universe called SimpleSP_xx (where "xx" stands for your initials). Use your MotorsOLEDB_xx (where "xx" stands for your initials) connection to connect to the Motors database. 2. Using the CustomerOrderHistory stored procedure, create a new universe called ParamSP_xx (where "xx" stands for your initials). Use your MotorsOLEDB_xx (where "xx" stands for your initials) connection to connect to the Motors database. 3. Save your universes locally and test them in Web Intelligence Rich Client.
161
Using OLAP, a user can quickly narrow or expand the scope of a business question. For example, in the scenario illustrated above, the sales for a single product, a group of products, or many products can be displayed. In a traditional relational reporting system, each of these questions would require a separate relational query to summarize historical data which, when the volume of transactions is high, can take a long time to produce the desired results. By comparison, comparable queries in an OLAP database can deliver answers with a better response time. The power of an OLAP database is its ability to quickly and dynamically summarize data by a variety of dimensions. In addition, an OLAP database provides a powerful calculation engine which supports ad hoc analysis to extend the value of the information beyond the data physically stored in the OLAP database.
162
Dimensions
An OLAP database is constructed from multiple components.
In the example shown above, Location, Product, and Time are the "Dimensions". Dimensions define the numerical data under analysis. For example, knowing that there are $1 million in sales is not meaningful until you put this amount in context with one or more dimensions. Is this sales amount for one month or for one product or is it the annual sales for all products in a single city? A dimension is comprised of representative values, or "Members". Atlanta is a member of the Location dimension in the example above. When you query an OLAP database, you select one or more members of a dimension or you can choose to summarize all members of a dimension. For example, you can select a particular location or you can summarize all locations. When the design of a dimension allows this type of summarization, a special type of member known as the "All Member" is available to provide a summarized value for the members of that dimension. Members can be organized into multiple "levels". Time is a dimension which commonly contains many levels, often Year, Quarter, and Month. Depending on analytical requirements, this dimension can also include Week, Day, and even Hour and Minutes. Levels organize a dimension into a hierarchy with the most summarized values at the top and the most detailed values at the bottom. In the example above, Q1, Q2, Q3, and Q4 are all members of the Quarter level of the Time dimension, while Jan and Feb are members of the Month level of the same dimension. When you query an OLAP database, levels allow you to drill up or down a dimension to view summary or detailed data.
Measures
Dimensions form the sides, or axes, of a cube. The cube cells represent the intersection of each dimension member with members of all other dimensions. Contained within each cell is the "Measure", which is the numerical data being analyzed and summarized. A cube can contain one or more measures.
163
164
13. Create a new universe. Click File New. 14.Give the universe a name and a description. 15.Select the OLAP data source connection from the Connection drop-down menu, and click OK. The OLAP universe gets generated. This may take a few minutes depending on the cube size. OLAP structures are mapped directly to classes, measures, dimensions, details, and filters in the universe. The universe structure appears in the Universe pane.
165
Create predefined conditions/filters. Define optional prompts. The following Universe Designer features are not supported for OLAP universes: You cannot set row-level security authorizations in an OLAP universe. You cannot edit a list of values in an OLAP universe. You cannot view and edit the universe entity-relationship schema as no schema is generated for OLAP universes.
Delegated measures
OLAP cube aggregation is supported in Universe Designer with delegated smart measures. A delegated measure is a measure that delegates its aggregation calculation to the database. For OLAP universes, this allows the universe designer to use the cube aggregation calculated in the OLAP source. Web Intelligence reporting and layout workflows now work seamlessly on OLAP sources regardless of the nature of the measure. This greatly eases the user experience by simplifying workflows and reducing inconsistent results. Note: For MSAS 2000, MSAS 2005, and Essbase, by default, all measures generated in OLAP universes are defined as delegated measures. For SAP BW, the universe designer must set this option manually for each measure.
Note: Expressions for calculated measures cannot include the @aggregate_aware function. The check integrity validates the XML syntax and any of the Universe Designer functions. Universe Designer also supports constants in the expression such as: "10", "ABC", @prompt, and so forth. This is important to support constants as it could be used (like in relational universes) to pass dynamic values to the report: ratio, percentage, and so forth.
166
differentiate generated objects from objects added or modified manually, allowing you to preserve the manual changes made in Universe Designer. It allows you to choose which strategy to adopt: Business Name Keep Replace. Object Type Keep Replace. LOV options Keep Replace. Deleted objects Delete from the Universe Keep and Hide: objects and add "/##/" as prefix to the Object name. A LOG file is generated at the end of the update process and can been saved on a hard disk to be reviewed later. In Universe Designer, designers can now run the Check Integrity tool after the update process. Note: The wizard does not update objects added manually in Universe Designer.
167
Instructions
1. Open Universe Designer. Create a new OLAP_xx connection, where "xx" stands for your initials, with the following parameters: Connection Type: Secured Connection Name: OLAP_xx (where "xx" stands for your initials) Database middleware: Microsoft MS Analysis Services 2005 OLE DB for OLAP Providers 2. In the connection Login Parameters window enter the following parameters: Use specified username and password. For user name and password, use the credentials as provided by the instructor. Enter the server name as provided by the instructor. 3. Click Next. The Catalog/Database parameters window displays the available OLAP cubes. 4. Select OLAP Cubes Motors (Motors) Motors (Motors), and click Test Connection. 5. Create a new MotorsOLAP_xx universe, (where "xx" stands for your initials), using your created secured OLAP connection. 6. Save your universe locally and test it in Web Intelligence Rich Client.
168
169
Lesson summary
After completing this lesson, you are now able to: Create a universe from an XML metadata file Create stored procedure and JavaBeans universes Work with OLAP universes
170
Appendix A
3. Create a new Monthly Figures class to contain the following monthly figures objects, based on the DT_Monthly_Figures table: Month Year Monthly Sales Revenue 4. Join the derived table with the MAKER and SHOWROOM tables using the appropriate foreign keys and update the Sales context as required. 5. Update the existing Sales Revenue measure SQL syntax to include a month value aggregation level.
171
Tip: Check other objects that reference the monthly aggregate, for example year object in the Financial Period class. 6. Set incompatibilities where required. 7. Test the aggregation level generations by running test queries in the Universe Designer Query Panel. Use the View SQL button to verify if the generated SQL is correct. Alternatively save the universe and test in Web Intelligence Rich Client. 8. Create a new class called Current Dates and insert the following objects:
Date Object Current Date Current Year Current Month SELECT syntax getdate() Description Returns the current date and time. Returns the current year. Type Date
datepart(yyyy,getdate())
Number
datepart(mm,getdate())
Number
Note: These objects are not based on any database columns and do not parse as they are lacking a reference table. To check if the syntax is correct click Tables, select the SALE table, apply the changes and click Parse. 9. There are no current date values in the Motors database. To ensure that you can create YTD objects, create a new derived table. Select Insert Derived Tables from the toolbar menu. 10.Name the table DT_Sale_YTD. 11.Add the following syntax to the derived table SELECT statement:
SELECT CLIENT_ID,SALE_ID, FROM SALE WHERE CLIENT_ID = (1089) UNION SELECT CLIENT_ID,SALE_ID, FROM SALE WHERE CLIENT_ID = (1088) UNION SELECT CLIENT_ID,SALE_ID, FROM SALE WHERE CLIENT_ID = (1087) UNION SELECT CLIENT_ID,SALE_ID, FROM SALE SALE_TOTAL, getdate() as SALE_DATE
172
12.Check the syntax and click OK. 13.As you need to ensure that all tables are part of a context you need to join the DT_Sale_YTD table to the CLIENT table via the CLIENT_ID. 14.Detect the cardinality and create a new context for the join between the DT_Sale_YTD and CLIENT tables. Name the context SALE_YTD. 15.Create a YTD Objects class, and add the following objects based on the SALE_YTD derived table:
Object Sales Total (SALE_YTD table) Sale Date (SALE_YTD table) SELECT Syntax sum(DT_Sale_YTD.SALE_TOTAL) DT_Sale_YTD.SALE_DATE
16.Double-click the Sale Date (SALE_YTD table) object and click on the Properties tab. 17.Select the Automatic Time Hierarchy button and create a year and month object. 18.Create the following indicator or boolean flag objects in the YTD Objects class that are used to create YTD measure objects in the remaining activity steps:
Boolean Flag Object SELECT Syntax
@select(YTD Objects\Year of Sale Date (SALE_YTD table)) @select(Current Dates\Current Year) 1 0 END
CASE @select(YTD Objects\Year of Sale Date (SALE_YTD table)) WHEN @select(Current Dates\Current Year) THEN 1 ELSE 0 END * CASE sign(@select(Current Dates\Current Month)@select(YTD Objects\Month of Sale Date (SALE_YTD table))) WHEN 1 THEN 1 ELSE 0 END
19.Create the following relative date-time measure objects in the YTD Objects class:
173
20.Save the changes and test the results in Web Intelligence Rich Client. 21.Run a new query using the Sale Date (SALE_YTD table), Sale_Total (SALE_YTD table), Total Sales YTD and the Total Sales YTD - current month objects.
174
Appendix B
<driver><language>.stg
Contains the help text for each external strategy defined in the <driver>.stg file. This text appears when the strategy is selected in a universe. Contains the external strategies available to data access driver.
Note: External Strategies will be covered later on in Lesson 7 External strategies
<driver>.stg
<driver>.sbo
Defines all databases supported and the specific connectivity configuration for each database. Contains the help text for functions that are listed in the <driver>.prm file. This text appears when the function is selected in Universe Designer.
<driver><language>.prm
175
Description
Defines the information parameters and functions related to the database. Stores information related to connection Note: Do not modify this file.
<driver><language>.cod
How can you quickly identify which data access files are being used? By looking at the connection details. Select File Parameters . On the Definition menu click the Test button for the Connection. Click on Details. This will show the version of BusinessObjects Enterprise used, the network layer. The details are split up into two parts: Business Objects configuration
This section highlights the BusinessObjects version used, and the network layer as defined in the connection. Note: The line <DBMS Engine: MS SQL Server 2005> is what has been defined in the connection. This does not mean that the database connected to is actually MS SQL Server 2005. The database version connected to is outlined in the Middleware and DBMS Configuration section. The BusinessObjects Configuration section also highlights the library of data access files used. Note: Double-click on the path to view the full path, or to copy the path. Middleware and DBMS Configuration
176
The Middleware and DBMS Configuration section highlights the actual Database Management System (DBMS) that you are connected to, and the version. This can be an important indicator that no cross reference of DBMS versus what is specified in the connection occurs.
The table below outlines what some of the above shown parameters mean:
177
Parameter
Description
Family
This specifies the family of database engine to be displayed in the Database Middleware Selection page of the new connection wizard. The middleware that correspond to your data access key are displayed on this page in a tree view.
Note: Do not modify this parameter.
The bind array is the area in memory that Connection Server stores a batch of data to be loaded (sent to the repository). When the bind array fills, it is transmitted to the database. This parameter specifies if the database supports this method. Values can be set to True or False, the default value is set to True Specifies the limitations of each driver. This setting is specific to each <driver>.sbo file 1 specifies that you can only use the driver to create and execute queries. 13 specifies that you can use the driver to create and execute queries, and to create universe folders. 15 specifies that you can use the driver to create the BusinessObjects repository, and to create and execute queries. 31 specifies that you can use the driver to create the BusinessObjects repository, to create and execute queries, and to access stored procedures.
Driver Level
CharSet Table
Specifies the Charset file (.crs) for the data access driver with no extension. This setting is specific to each .sbo file. The .crs file is in the same directory as the .sbo file.
Some <driver>.sbo files contain parameters that are also set in the cs.cfg file. The values set in the SBO file can over-ride the values in the cs.cfg file. Note: Prior to making any changes in the .SBO file, you need to create a backup. The .SBO file is a system file. Consult your database administrator before making any changes. Note: All data access files are now in XML format. Although XML files may be opened in any text editor such as WordPad or Notepad, only an editor designed for XML should be used to edit such files. Editing XML files without a proper editor may create file corruptions which can result in problems with demonstrations and activities. Note: Consult the BusinessObjects XI 3.0: Data Access Guide for more information on the .SBO file.
178
Note: The cs.cfg file is an XML file. The Document Type Definition (DTD) file that relates to each element used in the cs.cfg file is in the same directory. Make sure that, when editing and/or modifying the XML file, the cs.dtd is accessible. There are five XML elements in the cs.cfg file: Locales: This element defines the usual operating system charset for a given language. The locales are UNICODE compliant which allows SQL UNICODE to be used. Note that for some databases, SQL Server included, the SQL UNICODE settings are set to NVARCHAR. To allow for UNICODE compliancy the UNICODE setting in the PRM file or the UNICODE Dynamic SQL Parameter in the universe needs to be set accordingly. Settings: This element defines parameters that apply to all data access drivers, for example the file extensions of files used by Connection Server to manage data access. Some settings can be defined either for library version or server version of Connection Server. Library: parameters apply to a standard Connection Server installation. It is installed with other BusinessObjects desktop or server software. This is the default mode when you install a BusinessObjects product that is installed automatically with Connection Server. Server: parameters apply to a Connection Server stand alone server installation. It is installed alone with no other BusinessObjects desktop or server product. Distribution: This element contains two sub elements; Protocols and Lookup. The protocols element contains settings that the Connection Server uses to process requests coming from CORBA clients or HTTP clients. The Lookup element allows you to expose the target RDBMS that corresponds to a specific ODBC network layer to Connection Server. This applies when Connection Server is using two different data access drivers, for example Microsoft SQL Server and Microsoft Access, through a common ODBC network layer. By default, Lookup is set to No, so Connection Server associates a target RDBMS to its ODBC network layer. However, if Connection Server is being used as a standalone server, and has two databases that are accessed by the same ODBC network layer, the specific target database information must be exposed to Connection Server to allow queries to be routed through ODBC to the correct data account. Driver defaults:
179
Data access driver parameters that are also found in driver specific SBO files. The values set for these parameters apply to all data access drivers. Parameters specified in the SBO file can over-ride the parameters set in the cs.cfg file. For example the cs.cfg holds the default settings for the Array Fetch Size and Array Bind Size values, in the oracle.sbo file you can define different Array Fetch size and Array Bind size values. These values are normally set in individual universe connections in the Advanced Parameters and Custom Parameters menus. If no values are changed in these menus when defining the universe connection, the default settings from the cs.cfg will be used instead. If these values have been altered in the SBO file, this file over-rides the default from the cs.cfg file. Traces: You can set trace parameters that allow the recording of connection activity through Connection Server in log files. Note: Consult the BusinessObjects XI 3.0: Data Access Guide for more information on the cs.cfg file.
180
Configuration
Date Operations
Operators
Functions
The function list shown in the PRM file never includes a complete list of available functions for the designated RDBMS. If additional functions are required for reporting purposes, the PRM file can be adapted and new functions can be added. When working in Universe Designer, you can add SQL functions directly into the Select statement box of an object. If functions are used frequently this way, instead of typing this in every time, it can be added to the PRM file to appear as a function in the list. Note: Prior to making any changes in the .PRM file, you need to create a backup. The .PRM file is a system file. Consult your database administrator before making any changes. Note: All data access files are now in XML format. Although XML files may be opened in any text editor such as WordPad or Notepad, only an editor designed for XML should be used to edit such files. Editing XML files without a proper editor may create file corruptions which can result in problems with demonstrations and activities. Note: Consult the BusinessObjects XI 3.0: Data Access Guide for more information on the .PRM file.
181
The first parameter lists the RISQL functions supported by the database. The Over Clause parameter allows BusinessObjects products to include aggregate analytic functions (for example, SUM OVER PARTITION BY) when generating SQL. Depending on the database used, in the PRM file you also need to apply parameter rules for the GROUP BY.
182
Note: Consult the BusinessObjects XI 3.0: Designer's Guide for more information on analytic functions and the PRM file.
183
184
Appendix C
External Strategies
Using external strategies in Universe Designer
Universe Designer uses built-in automated routines to automatically create universe components based on the database structure. These routines are called strategies and are available from the Strategies page of the Parameters dialog box. These strategies are built-in to Universe Designer. You cannot access or modify them. You can, however, create SQL scripts that follow a defined output structure to perform customized automatic universe creation tasks. You can select these from the Strategies page with the other strategies. These user defined and customized scripts are called External strategies. This appendix describes external strategies and their use.
External strategy files are in XML format. They can be edited or viewed in Notepad or Wordpad, but it is recommended to use an XML editor to make modifications.
For example, an external strategy for join creation called Constraints in the Strategy file, appears as External Strategy: Constraints in the Joins drop down list on the Strategies page.
185
The information in the Strategy dialog box is accessed by Universe Designer when: the quick design wizard is used to build a new universe. your database option for "Extract joins with tables" has been selected in Tools Options Database to assist in automatically creating tables and joins for a universe. tables, objects and joins are inserted via the toolbar icons or via the Insert menu. There are a number of default built-in strategies that provide a good starting point. However, if you have a data warehouse or DBMS that uses public synonyms (Oracle for example), you will need to create external strategies to ensure Universe Designer can see those synonyms as tables in the table browser. Built-in strategies can not be modified, so in order to get data source specific requirements added to the universe, designers can create customizable external strategies to reflect their needs. Strategies are SQL statements that read the data dictionary tables in your source system. The returned query results use that dictionary information to form of a list of potential tables, joins, classes and objects. In some cases Data warehouse tables have a DW prefix, for example DW_Sales_fact. If a built-in strategy is used to identify potential classes and objects, the proposed classes will also have a DW prefix. Classes and objects need to remain end users focused and should not be portrayed with confusing prefixes. Instead of using the built-in strategy and manually remove the prefixes, designers can create a customized strategy that identifies potential classes and objects, and that drops the DW from the proposed classes automatically.
186
Types of strategies
There are three universe components that strategies interact with: objects, joins, and tables. To learn more about how strategies interact with these components we will look at how these are used in the built-in strategies.
Objects
The built-in object strategy determines how Universe Designer reads the table and column information from the data dictionary to come up with potential classes and objects (either when using the wizard or when inserting tables). By default, the data source table names are used as the proposed class names and the table columns are used as the proposed objects names. The built-in object strategy also converts all names to initial caps and removes the underscore (_) from any table and field names.
Joins
Universe Designer has four built-in strategies that automatically create joins in a universe. Edit manually (none): Joins are not created automatically. Database keys matching names: When using this strategy, joins are created automatically between columns that are indicated in the database as primary keys and foreign keys. All matching column names: This strategy identifies matching column names. When the column names match between two tables, the joins are automatically inserted, even if these columns are not designated primary or foreign keys. All matching numeric column names: When using this strategy, joins are created automatically between columns that are numeric and have matching names. In some schemas primary and foreign keys can be a date or char type, rather than a numeric value. This strategy would only propose join candidates for numeric fields. If you wish joins to be proposed for numeric, date, or character columns, select the preceding strategy.
Tables
The built-in table strategy selects all physical tables owned by the individual user specified in the connection parameters. If the owner of the tables in your DBMS is System, then you must log in with the user ID System for Universe Designer to find these tables. To avoid users to see Owner prefixes on tables you DBA can create synonyms (depending on the DBMS used), or can change the OWNER parameter in the <driver>.PRM file. When setting this parameter to N it drop the owner name from your table prefix and will cause the built-in strategies to look for public synonyms and views (for example, the user name specified in the connection parameters does not necessarily own the physical tables). Note: Setting the parameter OWNER to N without customizing an external strategy can also pick up unwanted system tables. If owner prefixes need to be excluded from tables names it is better to use an external table strategy that adapts to those needs instead of using the built-in-strategy. All these built-in strategies can be used as an example layout for customized external strategies. External strategies allow you to control how the data dictionary is read. They can be a useful solution for:
187
database public synonyms extracting column comments from your source system and use them as object descriptions importing metadata from a text file
188
Appendix D
189
ORACLE
This section provides solution syntaxes for ORACLE, based on SQL examples used in the course.
Instr() function. Can be used as: instr('some string','search string') instr('some string','search string',position) instr('some string','search string',position,occurence) CharIndex()
Fn_Length()
position, length characters long. if start is positive, Oracle counts from the beginning of the string.
Fn_Right() (or Right(,))
if start is negative, Oracle counts backwards from the end of the string. if length is omitted, Oracle returns all characters to the end of the string. This example returns the first four characters of the Client Name column:
substr(CLIENT.CLIENT_NAME,1,4)
This example returns the last four characters of the Client Name column:
substr(CLIENT.CLIENT_NAME,-4)
190
You can add the following parameters to the To_char function to extract date parts:
YEAR YYYY Q MM MON MONTH Year, spelled out 4-digit year Quarter of year (1, 2, 3, 4; JAN-MAR = 1). Month (01-12; JAN = 01). Abbreviated name of month. Name of month Week of year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year. Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh. Week of year (1-52 or 1-53) based on the ISO standard. Day of week (1-7). Name of day.
WW
IW D DAY
191
SQL Server
Oracle DD DDD DY Day of month (1-31). Day of year (1-366). Abbreviated name of day.
DateDiff()
There is no real equivalent in Oracle. You can use months_between(date 2, date 1)or subtract one date directlyt from another date.
To_Char() Sysdate() or current_date() to_date(to_char(Sysdate(),'YYYY') 'YYYY') to_date(to_char(Sysdate(),'MM') 'MM') Add_Months(12,sysdate()) to_date(to_char(@Select(Sales Dates\Sales Date Prompt),'YYYY') 'YYYY') to_date(to_char(@Select(Sales Dates\Sales Date Prompt),'MM') 'MM')
DateName() Current Date Current Year Current Month Next Year Sales Year Prompt
192
SELECT max(datename(weekday,SALE.SALE_DATE)) FROM SALE WHERE ( SALE.SALE_TYPE='S' ) GROUP BY Datename(weekday,SALE.SALE_DATE), {fn dayofweek(SALE.SALE_DATE)} ORDER BY{fn dayofweek(SALE.SALE_DATE)}
SELECT max(TO_CHAR(RENTAL.SALE_DATE,'D')) FROM SALE RENTAL WHERE ( RENTAL.SALE_TYPE='R' ) GROUP BY TO_CHAR(RENTAL.SALE_DATE,'D')), TO_NUMBER(TO_CHAR(RENTAL.SALE_DATE,'D')) ORDER BY TO_NUMBER(TO_CHAR(RENTAL.SALE_DATE,'D'))
193
MySQL
This section provides solution syntaxes for MySQL, based on SQL examples used in the course.
Fn_Length() Fn_Right() (or Right(,)) Fn_Left() (or Left(,)) Ceiling() Floor() Round() CAST() CASE WHEN THEN ELSE END
194
MonthName() DateName() WeekDay() Current Date Current Year CURDATE() or NOW() to_date(to_char(Sysdate(),'YYYY') 'YYYY')
Month(CURDATE()) Current Month MonthName(CURDATE()) Next Year Sales Year Prompt Sales Month Prompt DATE_ADD(CURDATE(), INTERVAL 12 MONTH) Year(@Select(Sales Dates\Sales Date Prompt) Month(@Select(Sales Dates\Sales Date Prompt)
SELECT max(MonthName(RENTAL.SALE_DATE)) FROM SALE RENTAL WHERE ( RENTAL.SALE_TYPE='R' ) GROUP BY MonthName(RENTAL.SALE_DATE), Month(RENTAL.SALE_DATE) ORDER BY Month(RENTAL.SALE_DATE)
195
MySQL
196
DB2
This section provides solution syntaxes for DB2, based on SQL examples used in the course.
Fn_Length() Fn_Right() (or Right(,)) Fn_Left() (or Left(,)) Ceiling() Floor() Round() CAST()
Length()
Right()
Left() Ceil() Floor() Round( number, [ decimal_places ] ) CAST() CASE WHEN THEN ELSE END
197
SQL Server
DB2 adds date values by using "- <datetype>" and "+ datetype"
SALE.SALE_DATE -5 day SALE.SALE_DATE +5 day DateAdd() SALE.SALE_DATE -5 months SALE.SALE_DATE +5 months SALE.SALE_DATE -5 year SALE.SALE_DATE +5 year DateDiff() timestampdiff() or DateDiff()
Month(Date()) Current Month Month(Current Date) Next Year Sales Year Prompt Sales Month Prompt Year(Current Date + 1 year) Year(@Select(Sales Dates\Sales Date Prompt) Month(@Select(Sales Dates\Sales Date Prompt)
198
SELECT max(MonthName(RENTAL.SALE_DATE)) FROM SALE RENTAL WHERE ( RENTAL.SALE_TYPE='R' ) GROUP BY MonthName(RENTAL.SALE_DATE), Month(RENTAL.SALE_DATE) ORDER BY Month(RENTAL.SALE_DATE)
SELECT max(datename(weekday,SALE.SALE_DATE)) FROM SALE WHERE ( SALE.SALE_TYPE='S' ) GROUP BY Datename(weekday,SALE.SALE_DATE), {fn dayofweek(SALE.SALE_DATE)} ORDER BY{fn dayofweek(SALE.SALE_DATE)} SELECT max(DayOfWeek(RENTAL.SALE_DATE)) FROM SALE RENTAL WHERE ( RENTAL.SALE_TYPE='R' ) GROUP BY DayOfWeek(RENTAL.SALE_DATE), Week(RENTAL.SALE_DATE) ORDER BY Week(RENTAL.SALE_DATE)
199
200
Answer Key
This section contains the answers to the reviews and/or activities for the applicable lessons.
201
202
203
Detail: These objects relate to supportive information and are associated with dimensions. They can be date, character, or number type, and may contain a calculation. They are used in queries and condition/filters but cannot be used to drill on or link on between queries. Measure: These objects are dynamic aggregates and are always a number type, containing functions like Sum, Count, Average, Max, or Min. Depending on the other objects in the query, they dynamically aggregate themselves when displayed in the report block. Predefined Condition/Filter: These objects contain a name, a description and a restriction. They are designed to give the user a choice as to whether to apply a condition filter or not. They can be quite basic, or can contain a complex where clause. 6. What are the different join types allowed in the universe structure. Provide a short description of each type. Answer: Equi: This join works on the principle of the data in the fields that are a joined match, for example Customer ID = Customer ID, therefore returning data from both tables where the data matches. Outer: This join works in the same way as an equi-join, however there may be data in one table but not the other, and the requirement is for the data to be returned regardless. For example, a join between Customer and Sales would be based on Customer ID, however a customer may still be prospective and not have any records in the sales table, but all customers must be reported on regardless of sales. Complex/Theta: This join works on the Between principle. For example, a sales date may be joined to a begin and also an end date in a table which is date based, for example sales date between begin date and end date. Self-restricting: This join works as a restriction on the table. If there is a field that can be used as a flag on a table, then this join would allow that flag to be referenced every time the table is used in the SQL statement. Self-referencing: A self-referencing join is a join from one column of a table to another column of the same table. This join should not be used as it creates a loop. Ideally, if this join exists, then the table should be aliased and the appropriate join and cardinality should be assigned. Shortcut: A shortcut join is a join that provides an alternate path between two tables. It improves the performance of a query by not taking into account intermediate tables, and shortening a normally longer join path. 7. What are the different types of SQL traps that can be found in a schema? How can each of these types be identified? How can each type be resolved in the universe schema? Answer: Chasm Trap: Identify - A chasm trap is essentially a many-to-one-to-many relationship and may be seen as a parent table with two child tables, the child tables having the many end
204
of the relationship. If a query is run with a chasm trap, depending on the objects used, either too many or not enough rows (but aggregation may be affected) are produced. Resolve - Best resolved by using contexts.
Fan Trap: Identify - A fan trap is identified as a one-to-many or a one-to-many-to-many relationship. In itself, this isn't an issue - what is the issue is if there are two fields being used as aggregates and they are at different levels in the path. This can give the same result as a chasm trap. Resolve - If they can be avoided by using the lowest level of granularity then this is the best practice, however that isn't always possible. In which case, a combination of aliases and contexts resolves the fan trap.
8. What are loops and how can they be resolved? Answer: Loops are joins between tables that (eventually) come back to the starting point, forming a circle, or loop. Usually the error Incompatible combination of objects alerts you to the fact you may have a loop. 9. Describe how you would test a measure to make sure the aggregation levels are projected correctly. Answer: To test a measure correctly, a minimum of three queries should be created. 1. 2. The measure on its own. The measure with two different dimensions, in different queries. Once the table has been projected, remove the dimensions and then add them again using the drag and drop method. This checks the aggregation in the report is correct. Applying a total to the tables checks (if they are all the same total) the aggregation level from the database.
3.
10.Explain two drawbacks of using restrictions at the object level. Answer: Two drawbacks: 1. Conflicting restrictions in the objects may be confusing if those objects are placed in the query. For example: UK customers, US customers. Effectively you are saying they must be UK and US at the same time, this is a conflict so no data is returned. Creates a flat level at the end of the class making drilling through the hierarchy difficult.
2.
11.Describe the use of the @select function. Answer: The @select function has no benefit to the end user. However, it does have benefit to the designer, as this is how they can reuse code between objects.
205
12.What is a hierarchy? Answer: A hierarchy is the order of dimensions in a "class" in a one-to-many order. Hierarchies can be default (or natural) and custom. 13.Describe what a derived table is and how it is generally used in a universe schema. Answer: A derived table is a table that contains an SQL statement. It is generally used: When it is not possible to create a table at the database level, especially if there is a need to link two otherwise un-linkable tables together To create a table based on a restriction - instead of aliasing tables based on their flag and using self-restricting joins 14.Describe what index awareness is, and how it is used in a universe schema. Answer: Index awareness is a way of utilizing the indexing in the database to enable queries to be more efficient in the SQL that they generate. It is set up via the object properties. 15.What are the pros and cons of delegated functionality in a universe-based reporting structure? Answer: Delegated or "smart" measure objects were discussed in the core Universe Design class. The objective is to shift the responsibility for the aggregation to the data source, instead of the universe This allows for complex and weighted calculations of dimensional subsets, but requires a refresh to the data source in order to display the results in the Web Intelligence report.
206
207
208
209
210
211
212
2. True or False. A stored procedure is a compiled SQL program, consisting of one or more SQL statements, which resides and runs on the target database. Answer: True. 3. True or False. When creating an OLAP universe, no tables are generated in the Structure pane. Answer: True. 4. True or False. Stored procedures are represented as Derived Tables, thus they benefit from Derived Table mechanisms and concepts. Answer: True.
213
214
Notes
Notes
Notes
Notes