Joins and Cardinality Demystified

Slides:



Advertisements
Similar presentations
SQL: The Query Language Part 2
Advertisements

Chapter 4 Tutorial.
Framework Manager and Transformer Tips
Chapter 4 Joining Multiple Tables
A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
MIS 451 Building Business Intelligence Systems
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Outline What is a data warehouse? A multi-dimensional data model Data warehouse architecture Data warehouse implementation Further development of data.
Dimensional Modeling Business Intelligence Solutions.
Introduction to Oracle9i: SQL1 Subqueries. Introduction to Oracle9i: SQL2 Chapter Objectives Determine when it is appropriate to use a subquery Identify.
CSE 190: Internet E-Commerce Lecture 10: Data Tier.
Some relationship types Using the Builder2 schema.
Nov 24, 2003Murali Mani SQL B term 2004: lecture 12.
LIS 557 Database Design and Management William Voon Michael Cole Spring '04.
Advanced Querying OLAP Part 2. Context OLAP systems for supporting decision making. Components: –Dimensions with hierarchies, –Measures, –Aggregation.
Database Systems More SQL Database Design -- More SQL1.
Hash vs Join A case study evaluating the use of the data step hash object to replace a SQL join Geoff Ness Sep 2014.
By N.Gopinath AP/CSE. Two common multi-dimensional schemas are 1. Star schema: Consists of a fact table with a single table for each dimension 2. Snowflake.
Inner join, self join and Outer join Sen Zhang. Joining data together is one of the most significant strengths of a relational database. A join is a query.
Building a Data Warehouse with SQL Server Presented by John Sterrett.
Sayed Ahmed Logical Design of a Data Warehouse.  Free Training and Educational Services  Training and Education in Bangla: Training and Education in.
Attribute Data in GIS Data in GIS are stored as features AND tabular info Tabular information can be associated with features OR Tabular data may NOT be.
IFS180 Intro. to Data Management Chapter 9 – Outer Joins.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Advanced SQL Murat Kantarcioglu Adapted from Silberchatz et al. slides.
Chapter 9 Joining Data from Multiple Tables
Programming using C# Joins SQL Injection Stored Procedures
1 Intro to JOINs SQL INNER JOIN SQL OUTER JOIN SQL FULL JOIN SQL CROSS JOIN Intro to VIEWs Simple VIEWs Considerations about VIEWs VIEWs as filters ALTER.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Week 10 Quiz 9 Answers Group 28 Christine Hallstrom Deena Phadnis.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 4: Intermediate.
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables.
Unit 4 Queries and Joins. Key Concepts Using the SELECT statement Statement clauses Subqueries Multiple table statements Using table pseudonyms Inner.
Joins We will look at joins again this time we will closer examine each join type in detail. We will look at the following join types. a)inner join b)Right.
Intro to SQL Management Studio. Please Be Sure!! Make sure that your access is read only. If it isn’t, you have the potential to change data within your.
SQL 101 – Class 1 Lee Turner. Agenda 1. This is your life – SQL A brief history of SQL What SQL is and what it is not Normalization 2. Some Super Simple.
1 Chapter 10 Joins and Subqueries. 2 Joins & Subqueries Joins – Methods to combine data from multiple tables – Optimizer information can be limited based.
SE305 Database System Technology 23/10/2014 Quiz-2.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Indexes and Views Unit 7.
Computer Science & Engineering 2111 Outer Joins 1CSE 2111 Lecture- Inner Vs. Outer Jioins.
BI Practice March-2006 COGNOS 8BI TOOLS COGNOS 8 Framework Manager TATA CONSULTANCY SERVICES SEEPZ, Mumbai.
Jennifer Widom Relational Databases The Relational Model.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
Thinking in Sets and SQL Query Logical Processing.
SQL Server Analysis Services Understanding Unified Dimension Model (UDM)
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
Building the Corporate Data Warehouse Pindaro Demertzoglou Data Resource Management.
SQL - Training Rajesh Charles. Agenda (Complete Course) Introduction Testing Methodologies Manual Testing Practical Workshop Automation Testing Practical.
More SQL: Complex Queries, Triggers, Views, and Schema Modification
More SQL: Complex Queries,
Chapter 12 Subqueries and MERGE Oracle 10g: SQL
SQL Query Joins ASP.Net 2.0 – Visual Studio 2005
Database Systems: Design, Implementation, and Management Tenth Edition
Chapter 4: Intermediate SQL Joins
Assignment 2 Due Thursday Feb 9, 2006
Dimensional Model January 14, 2003
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Implementing Data Models & Reports with Microsoft SQL Server
Relational Databases The Relational Model.
Relational Databases The Relational Model.
JOINS (Joinining multiple tables)
More SQL: Complex Queries, Triggers, Views, and Schema Modification
The Relational Model Textbook /7/2018.
SQL Fundamentals in Three Hours
Structured Query Language – The Fundamentals
JOINS (Joinining multiple tables)
Database Systems: Design, Implementation, and Management
Trainer: Bach Ngoc Toan– TEDU Website:
Presentation transcript:

Joins and Cardinality Demystified Elizabeth Snow-Trenkle Rocky Mountain Cognos User Group Meeting May 17, 2013

Topics Introduction to Joins 1..1 “The Inner Join” 0..1 “The Outer Join” Classifying the “Fact” Table 1..n “The Fact Table” 0..n “The Outer Fact Table” Considerations

Introduction to Joins What is cardinality within Cognos? Relationship between tables: Traditionally, inner and outer joins Cognos introduces Fact Detection

Consider the following tables: Underlying Tables Consider the following tables:

Requirement/Goal This report shows Patient Id with associated Charges and Payments.

1..1 “The Inner Join” Returns rows when there is at least one match in both tables. REG to REG_DISTRICT

1..1 “The Inner Join” Expected Actual Notice missing patients and totals are incorrect Actual

Will count 2x payments because there are 2 charges. 1..1 “The Inner Join” Examine the SQL select Patient.PatientId as PatientId, XSUM(charge.ChargeAmt for Patient.PatientId ) as ChargeAmt, XSUM(payments.PaymentAmt for Patient.PatientId ) as PaymentAmt from Test.Test.dbo.Patient Patient, Test.Test.dbo.charge charge, Test.Test.dbo.payments payments where (Patient.PatientId = charge.PatientId) and (Patient.PatientId = payments.PatientId) group by Patient.PatientId Dr Will count 2x payments because there are 2 charges.

0..1 “The Outer Join” Returns all rows from the left table in conjunction with matching rows from the right table. If there are no matching columns in the right table, the outer join returns NULL values.

0..1 “The Outer Join” Expected Actual

Will count 2x payments because there are 2 charges. 0..1 “The Outer Join” Examine the SQL select Patient.PatientId as PatientId, XSUM(charge.ChargeAmt for Patient.PatientId ) as ChargeAmt, XSUM(payments.PaymentAmt for Patient.PatientId ) as PaymentAmt from Test.Test.dbo.Patient Patient left outer join Test.Test.dbo.charge charge on (Patient.PatientId = charge.PatientId) Test.Test.dbo.payments payments on (Patient.PatientId = payments.PatientId) group by Patient.PatientId Will count 2x payments because there are 2 charges.

Classify the “Fact” Table Center of a star schema Only facts and keys; attributes come from dimension tables Multi-Fact queries are possible, but require a conformed dimension. In this case, Patient is the conformed dimension. Make them key players. Drive priorities – even between business units Assignments – user validation AND acceptance testing, training, champion, etc Let them earn sweat equity.

1..n “The Fact Table” Expected & Actual

1..n “The Fact Table” Why does changing from 1..n to 1..1 sometimes resolve the issue? If you want a report that shows only patients with Charges AND Payments Why does changing it from 1..1 to 1..n sometimes resolve the issue? If you want a report that only shows patients with Charges OR Payments

1..n “The Fact Table” Examine the SQL in Report Studio -- (It’s too long!) The Fact Table creates two inner join “queries,” then performs a full outer join “query” between the two.

0..n “The Outer Fact Table” Expected & Actual

0..n “The Outer Fact Table” Examine the SQL in Report Studio -- (It’s too long, again!) The Outer Fact Table creates two outer join “queries”, then performs a full outer join “query” between the two.

Considerations Tuning: Indexes should be evaluated based on the sub-queries they create Ignore the very misleading FM Relationship Impact description: 1..n/0..n means MUCH more and has BIGGER impact/ramifications

Conclusion Which do we use – 1..1, 0..1, 1..n, 0..n? Know the reporting requirements Dimensional data warehouses should typically leverage 0..n or 1..n cardinality Know the data, how to present it, and the capabilities

Questions? Final slide