JOIN Syntax and Techniques Noreen Redden Information Builders Copyright 2011, Information Builders. Slide 1.

Slides:



Advertisements
Similar presentations
Database Relationships in Access As you recall, the data in a database is stored in tables. In a relational database like Access, you can have multiple.
Advertisements

Advanced SQL Topics Edward Wu.
Chapter 4 Joining Multiple Tables
Copyright 2007, Information Builders. Slide 1 Relational Efficiencies: Part II Overview and JOIN / Sort Scenarios Renee Teatro Information Builders.
Copyright 2007, Information Builders. Slide 1 Walter Brengel Information Builders New Jersey User Forum – June 2008 FOCUS to SQL DeMystified.
McGyver for Dynamic Subtotals/Subfoots Presented by David Smith of Brinker International.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Chapter 9: Advanced SQL and PL/SQL Topics Guide to Oracle 10g.
XP Chapter 3 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Analyzing Data For Effective Decision Making.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
4 Copyright © 2004, Oracle. All rights reserved. Creating a Basic Form Module.
Eyad Alshareef 1 Creating Custom Forms Part A. 2Eyad Alshareef Data Block and Custom Forms Data block form Data block form Based on data blocks that are.
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.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
Database Updates Made Easy In WebFocus Using SQL And HTML Painter Sept 2011 Lender Processing Services 1.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
1 JOIN: Rules, Roles, and Conventions Floria Foote June 2008.
WebFOCUS Developer Studio Update Dimitris Poulos Technical Director September 3, 2015 Copyright 2009, Information Builders. Slide 1.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Copyright 2007, Paradigm Publishing Inc. BACKNEXTEND 3-1 LINKS TO OBJECTIVES Save a Filter as a Query Save a Filter as a Query Parameter Query Inner, Left,
© Paradigm Publishing, Inc Access 2010 Level 2 Unit 1Advanced Tables, Relationships, Queries, and Forms Chapter 3Advanced Query Techniques.
Copyright 2007, Information Builders. Slide 1 JOIN, MATCH and MORE– Making the Connections Walter F. Blood Technical Director, FOCUS Division May, 2011.
Project Implementation for COSC 5050 Distributed Database Applications Lab3.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014.
Analyzing Data For Effective Decision Making Chapter 3.
Lecture 2 of Advanced Databases Advanced SQL Instructor: Mr.Ahmed Al Astal.
Chapter 9 Joining Data from Multiple Tables
Other database objects (Sequence). What Is a Sequence? A sequence: Automatically generates sequential numbers Is a sharable object Is typically used to.
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.
Copyright 2007, Information Builders. Slide 1 Enhancing Maintain Applications with HTML Mark Derwin and Mark Rawls Information Builders.
1 Client/Server Databases and the Oracle Relational Database.
Data Management Console Synonym Editor
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Oracle Data Integrator Transformations: Adding More Complexity
Copyright 2007, Information Builders. Slide 1 JOIN, MATCH and MORE– Making the Connections Walter F. Blood Technical Director, FOCUS Division June, 2009.
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.
5 Copyright © 2004, Oracle. All rights reserved. Creating a Master-Detail Form.
Creating Databases for web applications [Complete presentations] More SQL Class time: discuss final projects. Do posting if you have not done it.
1 The Master That Tells All Floria Foote Information Builders June 2008.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
John Ykema, Director of Sales & Marketing. Agenda  Understanding the NEW Tool  Table JOINS & Database Views  Building your first report  Charts and.
Task #1 Create a relational database on computers in computer classroom 308, using MySQL server and any client. Create the same database, using MS Access.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
1 CS 430 Database Theory Winter 2005 Lecture 13: SQL DML - Modifying Data.
CHAPTER 7 LESSON C Creating Database Reports. Lesson C Objectives  Display image data in a report  Manually create queries and data links  Create summary.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 CONACT UC:  Magnific training   
Physical Layer of a Repository. March 6, 2009 Agenda – What is a Repository? –What is meant by Physical Layer? –Data Source, Connection Pool, Tables and.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
DAY 20: ACCESS CHAPTERS 5, 6, 7 Larry Reaves October 28,
CHAPTER 7 LESSON B Creating Database Reports. Lesson B Objectives  Describe the components of a report  Modify report components  Modify the format.
Chapter 12 Introducing Databases. Objectives What a database is and which databases are typically used with ASP.NET pages What SQL is, how it looks, and.
Working in the Forms Developer Environment
SQL and SQL*Plus Interaction
ORACLE SQL Developer & SQLPLUS Statements
INNER JOIN INNER SPRIDEN SARADAP
Relational Queries (query 12) Display vendor contact info (contact person and phone number) for inventory products (relationship query) Query: Inventory.
SQL Fundamentals in Three Hours
Data Management Innovations 2017 High level overview of DB
Contents Preface I Introduction Lesson Objectives I-2
IST 318 Database Administration
Presentation transcript:

JOIN Syntax and Techniques Noreen Redden Information Builders Copyright 2011, Information Builders. Slide 1

JOIN Syntax and Techniques Overview  When To JOIN  Type Of JOINs  JOIN Techniques  JOIN Syntax  Joining Files In The Synonym  Considerations  Review Copyright 2011, Information Builders. Slide 2

When To JOIN Copyright 2011, Information Builders. Slide 3

JOIN Syntax and Techniques When To JOIN Files  Data Is Stored In Several Locations  Different Servers  Different Databases  Different Tables  A Relationship Exists Between The Two Sources  A Common Key Exists Between The Two Sources  If the fields/columns are the same, but different years, etc., use MORE or Concatenation  To Update multiple files with different fields/columns, use MAINTAIN or COMBINE with MODIFY Copyright 2011, Information Builders. Slide 4

Types of JOINs Copyright 2011, Information Builders. Slide 5

JOIN Syntax and Techniques Types Of JOINs  Data Source Dependent  Non Keyed (FIX Format)  Keyed  FOCUS  VSAM  Relational  Cross Reference Source Determines The Rules Oracle to OracleFOCUS to FIX FOCUS to FOCUSFIX to FOCUS Oracle to FOCUS FOCUS to Oracle SQL Server to Oracle Copyright 2011, Information Builders. Slide 6

JOIN Syntax and Techniques Types Of JOINs  JOIN Behavior  INNER  Only Records That Occur In Host AND Cross Reference Are Returned  LEFT OUTER  All Records From The Host Are Processed regardless of a corresponding Record In The Cross Reference  Non Relational Considerations  UNIQUE – Return Only One Matching Record From The Cross Reference  MULTIPLE – More Than One Record May exist in the Cross Reference Copyright 2011, Information Builders. Slide 7

JOIN Techniques Copyright 2011, Information Builders. Slide 8

JOIN Syntax and Techniques JOIN Techniques  JOIN Statements  Explicitly Coded In The Procedure  Gives Flexibility To End Users  Requires Knowledge of Data And Data Relationships  Can Join On Real Field Or Defined Field (DEFINE BASED)  Can Issue A Specific Join Predicate (WHERE BASED)  Cluster Synonyms  Uses Syntax In The Synonym  Allows Better Control Copyright 2011, Information Builders. Slide 9

JOIN Syntax Copyright 2011, Information Builders. Slide 10

JOIN Syntax and Techniques JOIN Syntax  Items In […] Are Optional  If LEFT_OUTER Is Omitted, An INNER JOIN Is Implied  If UNIQUE or MULTIPLE Is Omitted, UNIQUE Is Implied  AS asname Should Only Be Omitted If there Is only one JOIN statement. Always using an AS name Is good practice  END Is only required if the JOIN statement Is longer than one line Copyright 2011, Information Builders. Slide 11 JOIN [LEFT_OUTER] field IN host [TAG tagname] TO [UNIQUE/MULTIPLE] field IN crfile [TAG tagname] [AS asname] [END]

JOIN Syntax and Techniques JOIN Syntax – DEFINE Based JOIN Copyright 2011, Information Builders. Slide 12 JOIN [LEFT_OUTER] define_field WITH real_field IN host TO [UNIQUE/MULTIPLE] field IN crfile [AS asname] [END] DEFINE FILE filename define_field/format=expression; END JOIN clears all DEFINEs unless SET KEEPDEFINES = ON

JOIN Syntax and Techniques JOIN Syntax – WHERE Based Copyright 2011, Information Builders. Slide 13 JOIN [LEFT_OUTER|INNER] hfld1 [AND hfld2...] IN hostfile [TAG tag1] TO [UNIQUE|MULTIPLE] crfield [AND crfld2...] IN crfile [TAG tag2] [AS joinname] WHERE expression; END JOIN LEFT_OUTER FILE EMPLOYEE AT DEPT_ID TAG T1 TO MULTIPLE FILE DEPARTMENT AT DEPT_ID TAG T2 AS J1. WHERE (T1.DEPT_ID EQ T2.DEPT_ID) AND (T2.DEPT_NAME EQ 'sales‘); END SELECT T1."emp_name",T1."dept_id",T2."dept_name",T2."dept_id" FROM ( dbo.emp T1 LEFT OUTER JOIN dbo.department T2 ON T2."dept_id" = T1."dept_id" AND (T2."dept_name" = 'sales') );

Examples Copyright 2011, Information Builders. Slide 14

JOIN Syntax and Techniques Examples Copyright 2011, Information Builders. Slide 15

JOIN Syntax and Techniques Examples JOIN COUNTRY IN WSUMCAR TO COUNTRY IN WSUMCARREG AS J1 Copyright 2011, Information Builders. Slide 16 TABLE FILE WSUMCAR SUM SALES BY REGION BY COUNTRY ON TABLE SET PAGE OFF END

JOIN Syntax and Techniques Examples JOIN LEFT_OUTER COUNTRY IN WSUMCAR TO COUNTRY IN WSUMCARREG AS J1 END Copyright 2011, Information Builders. Slide 17 TABLE FILE WSUMCAR SUM SALES BY REGION BY COUNTRY ON TABLE SET PAGE OFF END

JOIN Syntax and Techniques Examples -- Relational Datasource JOIN COUNTRY IN WSUMCARREG TO COUNTRY IN WSUMCAR AS J1 Copyright 2011, Information Builders. Slide 18 TABLE FILE WSUMCARREG PRINT COUNTRY WSUMCAR.COUNTRY CAR MODEL ON TABLE SET PAGE OFF END

JOIN Syntax and Techniques Examples -- Non-Relational Datasource JOIN COUNTRY IN WSUMCARREG TO COUNTRY IN WSUMCAR AS J1 Copyright 2011, Information Builders. Slide 19 TABLE FILE WSUMCARREG PRINT COUNTRY WSUMCAR.COUNTRY CAR MODEL ON TABLE SET PAGE OFF END

JOIN Syntax and Techniques Examples -- Non-Relational Datasource JOIN COUNTRY IN WSUMCARREG TO COUNTRY IN WSUMCAR AS J1 Copyright 2011, Information Builders. Slide 20 TABLE FILE WSUMCAR PRINT COUNTRY CAR MODEL WHERE COUNTRY EQ ‘ENGLAND’ ON TABLE SET PAGE OFF END

JOIN Syntax and Techniques Examples -- Non-Relational Datasource JOIN COUNTRY IN WSUMCARREG TO MULTIPLE COUNTRY IN WSUMCAR AS J1 END Copyright 2011, Information Builders. Slide 21 TABLE FILE WSUMCARREG PRINT COUNTRY WSUMCAR.COUNTRY CAR MODEL ON TABLE SET PAGE OFF END

Cluster Synonym Copyright 2011, Information Builders. Slide 22

JOIN Syntax and Techniques Cluster Synonym Copyright 2011, Information Builders. Slide 23 Synonym: FILENAME=WSUMCAR, SUFFIX=SQLORA, $ SEGMENT=SEG01, SEGTYPE=S0, $ FIELDNAME=COUNTRY, ALIAS=COUNTRY, USAGE=A10, ACTUAL=A10, $ FIELDNAME=CAR, ALIAS=CARS, USAGE=A16, ACTUAL=A16, $ FIELDNAME=MODEL, ALIAS=MODEL, USAGE=A24, ACTUAL=A24, $ FIELDNAME=DEALER_COST, ALIAS=DCOST, USAGE=D7, ACTUAL=D8, $ FIELDNAME=RETAIL_COST, ALIAS=RCOST, USAGE=D7, ACTUAL=D8, $ FIELDNAME=SALES, ALIAS=UNITS, USAGE=I6, ACTUAL=I4, $ Access: SEGNAME=SEG01, TABLENAME=WSUMCAR, KEYS=03, WRITE=YES, $

JOIN Syntax and Techniques Cluster Synonym Copyright 2011, Information Builders. Slide 24 Synonym: FILENAME=WSUMCARREG, SUFFIX=SQLORA, $ SEGMENT=SEG01, SEGTYPE=S0, $ FIELDNAME=COUNTRY, ALIAS=COUNTRY, USAGE=A10, ACTUAL=A10, $ FIELDNAME=REGION, ALIAS=REGION, USAGE=A10, ACTUAL=A10, MISSING=ON, $ Access: SEGNAME=SEG01, TABLENAME=WSUMCARREG, KEYS=01, WRITE=YES, $

Cluster Synonym – Using the Tool Copyright 2011, Information Builders. Slide 25

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Open The Root Synonym Copyright 2011, Information Builders. Slide 26

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Open The Root Synonym Copyright 2011, Information Builders. Slide 27 Click on Modeling View Tab

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Copyright 2011, Information Builders. Slide 28 Click on Insert Reference to Segment from Existing Synonym

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Copyright 2011, Information Builders. Slide 29 Select The Table/File To Add.

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Copyright 2011, Information Builders. Slide 30 Default JOIN Type Is INNER To Multiple

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Copyright 2011, Information Builders. Slide 31 In Our Case, Select Left Outer Join

JOIN Syntax and Techniques Cluster Synonym – Synonym Editor Copyright 2011, Information Builders. Slide 32 To View The Code, Click On Text View and Access File Text View tabs

JOIN Syntax and Techniques Cluster Synonym Copyright 2011, Information Builders. Slide 33 Synonym: FILENAME=wsumcarc, SUFFIX=SQLORA, $ SEGMENT=SEG01, SEGTYPE=S0, $ FIELDNAME=COUNTRY, ALIAS=COUNTRY, USAGE=A10, ACTUAL=A10, $ FIELDNAME=CAR, ALIAS=CARS, USAGE=A16, ACTUAL=A16, $ FIELDNAME=MODEL, ALIAS=MODEL, USAGE=A24, ACTUAL=A24, $ FIELDNAME=DEALER_COST, ALIAS=DCOST, USAGE=D7, ACTUAL=D8, $ FIELDNAME=RETAIL_COST, ALIAS=RCOST, USAGE=D7, ACTUAL=D8, $ FIELDNAME=SALES, ALIAS=UNITS, USAGE=I6, ACTUAL=I4, $ SEGMENT=SEG011, SEGTYPE=KM, PARENT=SEG01, CRFILE=REPRO_NFS/WSUMCARREG, CRSEGMENT=SEG01, CRINCLUDE=ALL, CRJOINTYPE=LEFT_OUTER, JOIN_WHERE=SEG01.COUNTRY EQ SEG011.COUNTRY;, $ Access: SEGNAME=SEG01, TABLENAME=WSUMCAR, KEYS=03, WRITE=YES, $ SEGNAME=SEG011, $

JOIN Syntax and Techniques Cluster Synonym Copyright 2011, Information Builders. Slide 34 SEGMENT=SEG011, SEGTYPE=KM, PARENT=SEG01, CRFILE=REPRO_NFS/WSUMCARREG, CRSEGMENT=SEG01, CRINCLUDE=ALL, CRJOINTYPE=LEFT_OUTER, JOIN_WHERE=SEG01.COUNTRY EQ SEG011.COUNTRY;, $ SEGTYPE=KM (KU) - Keyed Multiple/Keyed Unique PARENT=SEG01- Identifies Host CRFILE=REPRO_NFS/WSUMCARREG- Name Of Synonym CRSEGMENT=SEG01- Segment To Use In Synonym CRJOINTYPE=LEFT_OUTER (INNER)- Relationship JOIN_WHERE=JOIN predicate expression CRINCLUDE=ALL - Use FIELDNAMES from the Cross reference synonym

Considerations Copyright 2011, Information Builders. Slide 35

JOIN Syntax and Techniques Considerations  Traces SET TRACEOFF=ALL SET TRACEON=SQLAGGR//CLIENT SET TRACEON=STMTRACE//CLIENT SET TRACEON=SQLCALL//CLIENT SET TRACESTAMP=OFF SET TRACEUSER=ON Copyright 2011, Information Builders. Slide 36

JOIN Syntax and Techniques Considerations Multiplicative Effect Parent Data Will Be Generated For Each Child Record Table A – A 1, B 2, C3 Table B – A 5, A 7, A 2, B 0, B1, C2 Joining A to B Will Produce: A 1 5 A 1 7 A 1 2 If You Subtotaled The Values: 3 14 Even Though A 1 Only Occurred Once In Table A Copyright 2011, Information Builders. Slide 37

JOIN Syntax and Techniques Overview  When To Combine Files  Type Of JOINs  JOIN Techniques  JOIN Syntax  Joining Files In The Synonym  Considerations  Review Copyright 2011, Information Builders. Slide 38

Questions Copyright 2011, Information Builders. Slide 39

Thank You For Attending Copyright 2011, Information Builders. Slide 40