1 JOIN: Rules, Roles, and Conventions Floria Foote June 2008.

Slides:



Advertisements
Similar presentations
Sometimes you need to use data from more than one table. In example1, the report displays data from two separate tables. Employee IDs exist in the EMPLOYEES.
Advertisements

Copyright 2007, Information Builders. Slide 1 Walter Brengel & Cesare Petrizio Unintended Consequences or…. Why Did FOCUS Do THAT!
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
Chapter 3 Data Modeling Copyright © 2014 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent.
Copyright 2007, Information Builders. Slide 1 Non-Relational Efficiencies Walter F. Blood Technical Director Information Builders, Inc.
Tutorial 3 Queries and Table Relationships
Start First step Create a new blank database Create a database using the option that will enable you to build your database using pre-set options. Save.
Copyright 2007, Information Builders. Slide 1 Internals of Retrieval for TABLE/TABLEF/MATCH FILE Cesare Petrizio Information Builders.
Walter F. Blood Information Builders Nashville User Forum February 23, 2012 THINKing in WEBFOCUS.
1 Reporting Internals From a Reports Point of View Renee Teatro Customer Support Services.
Ch5: ER Diagrams - Part 1 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Create a new blank database First step SUBMITTry again.
Copyright 2007, Information Builders. Slide 1 Tips and Techniques From the FOCWIZARDs Art Greenhaus & Noreen Redden FOCWIZARDS Tech Summit, 2008.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
SUNY Morrisville-Norwich Campus-Week 10 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
Database Design Chapter 2. Goal of all Information Systems  To add value –Reduce costs –Increase sales or revenue –Provide a competitive advantage.
Querying a Database Microsoft Office Access 2003.
1 Computing for Todays Lecture 16 Yumei Huo Fall 2006.
Interpreting SQL Code. SQL (The language used to query a database) S is used to specify the you want to include. F is used to specify the the selected.
Displaying Data from Multiple Tables. Obtaining Data from Multiple Tables Sometimes you need to use data from more than one table. In the example, the.
Copyright 2007, Information Builders. Slide 1 FOR and the FML Syntax Noreen Redden Information Builders FOCUS Users of New England.
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Copyright 2007, Information Builders. Slide 1 JOIN, MATCH and MORE– Making the Connections Walter F. Blood Technical Director, FOCUS Division May, 2011.
ASP.NET Programming with C# and SQL Server First Edition
Tutorial 19 Dina Said. Indexing Data 1. A data entry k* is an actual data record (with search key value k 2. A data entry is a (k, rid) pair, where rid.
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
WebFOCUS Tips and Techniques WebFOCUS Tips and Techniques The Next Generation.
Principles of Database Design, Part II AIMS 2710 R. Nakatsu.
TM 7-1 Copyright © 1999 Addison Wesley Longman, Inc. Physical Database Design.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
RELATIONSHIPS Generally there are two main database types: flat-file and relational.
Using Relational Databases and SQL John Hurley Department of Computer Science California State University, Los Angeles Lecture 3: Joins Part I.
Ashwani Roy Understanding Graphical Execution Plans Level 200.
1 FOCUS Internals: Part 1 Update for 7.6.x Renee Teatro FUN Conference August 2008 Internals of Retrieval for TABLE/TABLEF/MATCH FILE.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 9 1 Microsoft Office Access 2003 Tutorial 9 – Using Action Queries, and Defining Table Relationships.
SQL 101 for Web Developers 14 November What is a database and why have one? Tables, relationships, normalization SQL – What SQL is and isn’t – CRUD:
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 9 – Building Links,
Copyright 2007, Information Builders. Slide 1 Tips and Techniques From the FOCWIZARDs Noreen Redden Technical Director, Advanced Technical Support August.
Access Chapter 2: Relational Database Objectives Design data Create tables Understand table relationships Understand data types, key, & field properties.
1 Outline  What is a Primary Key?  AutoNumber primary keys  Single-field primary keys  Composite-field primary key  About Foreign Keys  Database.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
Copyright 2007, Information Builders. Slide 1 JOIN, MATCH and MORE– Making the Connections Walter F. Blood Technical Director, FOCUS Division June, 2009.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
One Customer has Many Pets; One Pet as One Customer, so Customer ID goes on Pet Table. One Pet has many Visits, but only one Visit refers.
IST 220 Introduction to Databases Course Wrap-up.
Tutorial 9 Using Action Queries and Advanced Table Relationships.
Microsoft Access 2013 ®® Tutorial 9 Using Action Queries and Advanced Table Relationships.
FILTERS and FUNCTIONS: Hidden Gems Walter F. Blood Technical Director, FOCUS Division June, 2008.
Access Review. Access Access is a database application A database is a collection of records and files organized for a particular purpose Access supports.
Database Management Systems MIT Lesson 02 – Database Design (Entity Relationship Diagram) By S. Sabraz Nawaz.
1 The Master That Tells All Floria Foote Information Builders June 2008.
- Joiner Transformation. Introduction ►Transformations help to transform the source data according to the requirements of target system and it ensures.
Lesson 2: Designing a Database and Creating Tables.
Planning & Creating a Database By Ms. Naira Microsoft Access.
Copyright 2007, Information Builders. Slide 1 Hidden Gems Walter F. Blood Technical Director Information Builders, Inc.
Chapter 2 Data Modeling Using the Entity-Relationship (ER) Model Copyright © 2004 Pearson Education, Inc.
The Entity-Relationship Model, P. I R. Nakatsu. Data Modeling A data model is the relatively simple representation, usually graphic, of the structure.
JOIN Syntax and Techniques Noreen Redden Information Builders Copyright 2011, Information Builders. Slide 1.
Copyright 2007, Information Builders. Slide 1 TABLE FILE: The Basics Noreen Redden FOCWizard June, 2008.
Query Processing and Query Optimization CS 157B Dennis Le Weishan Wang.
Copyright 2007, Information Builders. Slide 1 Cesare Petrizio June, 2008 The File Is Too Large.
Hibernates - Many to One Association. May 12, 2011 What is Association? Association is the relation between two objects. One class holds a reference of.
® Microsoft Access 2010 Tutorial 9 Using Action Queries and Advanced Table Relationships.
Retele de senzori Curs 2 - 1st edition UNIVERSITATEA „ TRANSILVANIA ” DIN BRAŞOV FACULTATEA DE INGINERIE ELECTRICĂ ŞI ŞTIINŢA CALCULATOARELOR.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 4 1 Microsoft Office Access 2003 Tutorial 4 – Creating Forms and Reports.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
COMP 430 Intro. to Database Systems MongoDB. What is MongoDB? “Humongous” DB NoSQL, no schemas DB Lots of similarities with SQL RDBMs, but with more flexibility.
The Basics of FOCUS Reporting Syntax
What Happens When You Run A Report
Presentation transcript:

1 JOIN: Rules, Roles, and Conventions Floria Foote June 2008

2 JOINs – Inner and Outer Agenda  JOIN Rules  Many-to-Many (or one-to-Many) Relationship  Inner JOIN  Outer JOIN  Many-to-One ( or One-to-One) Relationship  Always OUTER JOIN  Conditional JOINs

3 JOINs – Inner and Outer Rules  All Rules are determined by the SUFFIX of the TO file  JOIN TO FOCUS  Only single target field may be specified  Target field must be indexed  Many-to-Many supported  JOIN TO sqltable  Multiple target fields may be specified  Indexes are not required, but preferred  Many-to-Many supported

4 JOINs – Inner and Outer Rules  JOIN TO Indexed Files  Target field/group must be primary key or alternate index  Multiple target fields may be specified  High-order elements of key or alternate index  Many-to-Many supported  JOIN TO FIX  Multiple target fields may be specified  Many-to-Many not supported  Both files must be sorted in ascending order on the JOIN keys

5 JOINs – Inner and Outer Syntax JOIN field1 [ AND field2 …] [WITH fieldname] [TAG tagname] IN file1 TO [ALL] fielda [AND fieldb…] IN file2 [TAG tagname] AS joinname END JOIN field1 IN file1 TO [ALL] field2 IN file2 AS joiname

6 JOINs – Inner and Outer Where …  Field1 AND field2 …  Up to Four fields may be specified  WITH fieldname  DEFINE-based JOIN  DEFINE of field specified after the JOIN  Fieldname specified becomes the anchor of the JOIN  TAG tagname  Tagname becomes a prefix for fully qualifying fields in specified file  joinname (default is blank)  Identifies JOIN for the session  Another JOIN with the same name will overlay  Specified JOIN can be CLEARed

7 Relationships – One-to-Many

8 JOINs – Inner and Outer EMPDATA FILENAME=EMPDATA, SUFFIX=FOC SEGNAME=EMPDATA, SEGTYPE=S1 FIELDNAME=PIN, ALIAS=ID, FORMAT=A9, INDEX=I,$ FIELDNAME=LASTNAME, ALIAS=LN, FORMAT=A15, $ FIELDNAME=FIRSTNAME, ALIAS=FN, FORMAT=A10, $ FIELDNAME=MIDINITIAL, ALIAS=MI, FORMAT=A1, $ FIELDNAME=DIV, ALIAS=CDIV, FORMAT=A4, $ FIELDNAME=DEPT, ALIAS=CDEPT, FORMAT=A20, $ FIELDNAME=JOBCLASS, ALIAS=CJCLAS, FORMAT=A8, $ FIELDNAME=TITLE, ALIAS=CFUNC, FORMAT=A20, $ FIELDNAME=SALARY, ALIAS=CSAL, FORMAT=D12.2M, $ FIELDNAME=HIREDATE, ALIAS=HDAT, FORMAT=YMD, $

9 JOINs – Inner and Outer EMPDATA PIN LASTNAME FIRSTNAME VALINO DANIEL BELLA MICHAEL CASSANOVA LOIS ADAMS RUTH ADDAMS PETER PATEL DORINA SANCHEZ EVELYN SO PAMELA PULASKI MARIANNE ANDERSON TIM

10 JOINs – Inner and Outer Kids FILENAME=KIDS, SUFFIX=FOC SEGNAME=CHILDSEG, SEGTYPE=S1 FIELDNAME=EMP_ID, ALIAS=PIN, FORMAT=A9, INDEX =I,$ FIELDNAME=LASTNAME, ALIAS=SLN, FORMAT=A15,$ FIELDNAME=CHILDNAME, ALIAS=SFN, FORMAT=A10,$ FIELDNAME=DATE_OF_BIRTH, ALIAS=DOB, FORMAT=MDYY,$

11 JOINs – Inner and Outer Kids EMP_ID LASTNAME CHILDNAME DATE_OF_BIRTH VALINO ANTHONY 12/31/ VALINO ANNE 11/09/ VALINO ARTHUR 06/01/ VALINO ASTRIC 05/03/ CASSANOVA JOHN 05/07/ ADAMS MARY 08/01/ PATEL SAM 07/05/ SANCHEZ SAMANTHA 08/04/1997

12 JOINs – Inner and Outer Spice FILENAME=SPICE, SUFFIX=FOC SEGNAME=SPOUSEI, SEGTYPE=S1 FIELDNAME=PIN, ALIAS=ID, FORMAT=A9, INDEX=I,$ FIELDNAME=LASTNAME, ALIAS=SLN, FORMAT=A15,$ FIELDNAME=SPOUSENAME, ALIAS=SFN, FORMAT=A10,$ FIELDNAME=SPOUSESSN, ALIAS=SSN, FORMAT=A9,$

13 JOINs – Inner and Outer Spice PIN LASTNAME SPOUSENAME SPOUSESSN VALINO ABIGAIL CASSANOVA EDWARD ADAMS BRIAN PATEL KEITH SANCHEZ EDWARD PULASKI DAVID

14 JOINs – Inner and Outer Relationship JOIN PIN IN EMPDATA TO ALL PIN IN KIDS AS JOIN1 PIN LASTNAME FIRSTNAME MIDINITIAL EMPDATA EMP_ID LASTNAME CHILDNAME MIDINITIAL EMP_ID LASTNAME CHILDNAME MIDINITIAL KIDS OUTERINNER

15 JOINs – Inner and Outer Inner JOIN SET ALL = OFF EMP_ID PIN

16 JOINs – Inner and Outer Inner JOIN PIN LASTNAME FIRSTNAME CHILDNAME VALINO DANIEL ASTRIC ARTHUR ANNE ANTHONY CASSANOVA LOIS JOHN ADAMS RUTH MARY PATEL DORINA SAM SANCHEZ EVELYN SAMANTHA

17 JOINs – Inner and Outer Outer JOIN JOIN INNER hfld1 [AND hfld2...] IN hostfile [TAG tag1] TO MULTIPLE crfield [AND crfld2...] IN crfile [TAG tag2] [AS joinname] END

18 JOINs – Inner and Outer Outer JOIN SET ALL = ON EMP_ID PIN

19 JOINs – Inner and Outer Outer JOIN PIN LASTNAME FIRSTNAME CHILDNAME VALINO DANIEL ASTRIC ARTHUR ANNE ANTHONY BELLA MICHAEL CASSANOVA LOIS JOHN ADAMS RUTH MARY ADDAMS PETER PATEL DORINA SAM SANCHEZ EVELYN SAMANTHA SO PAMELA PULASKI MARIANNE ANDERSON TIM.

20 JOINs – Inner and Outer Outer JOIN JOIN LEFT_OUTER hfld1 [AND hfld2...] IN hostfile [TAG tag1] TO MULTIPLE crfield [AND crfld2...] IN crfile [TAG tag2] [AS joinname] END

21 Relationships – One-to-One

22 JOINs – Inner and Outer Relationship JOIN PIN IN EMPDATA TO PIN IN SPICE AS JOIN1 PIN LASTNAME FIRSTNAME MIDINITIAL EMPDATA PIN LASTNAME SPOUSENAME SSN SPICE OUTERINNER

23 JOINs – Inner and Outer Unique Outer JOIN SET ALL = OFF or SET ALL = ON PIN PIN

24 JOINs – Inner and Outer Unique Outer JOIN PIN LASTNAME SPOUSENAME VALINO ABIGAIL BELLA CASSANOVA EDWARD ADAMS BRIAN ADDAMS PATEL KEITH SANCHEZ EDWARD SO PULASKI DAVID ANDERSON

25 JOINs – Inner and Outer Unique Relationship JOIN PIN IN EMPDATA TO ID IN KIDS AS JOINU PIN LASTNAME FIRSTNAME MIDINITIAL EMPDATA PIN LASTNAME CHILDNAME MIDINITIAL KIDS OUTER INNER

26 JOINs – Inner and Outer Unique JOIN EMP_ID PIN

27 JOINs – Inner and Outer Unique JOIN PIN LASTNAME FIRSTNAME VALINO ARTHUR BELLA CASSANOVA JOHN ADAMS MARY ADDAMS PATEL SAM SANCHEZ SAMANTHA SO PULASKI ANDERSON

28 JOINs – Inner and Outer Relationship JOIN PIN IN EMPDATA TO PIN IN KIDS AS JOIN1 TABLE FILE EMPDATA PRINT CHILDSEG.CHILDNAME NOPRINT BY PIN BY LASTNAME BY CHILDNAME WHERE PIN NE EMP_ID END

29 JOINs – Inner and Outer Unique JOIN EMP_ID PIN

30 JOINs – Inner and Outer Inner JOIN PIN LASTNAME FIRSTNAME BELLA MICHAEL ADDAMS PETER SO PAMELA PULASKI MARIANNE ANDERSON TIM

31 JOINs – Inner and Outer Outer JOIN JOIN LEFT_OUTER hfld1 [AND hfld2...] IN hostfile [TAG tag1] TO UNIQUE crfield [AND crfld2...] IN crfile [TAG tag2] [AS joinname] END

32 Conditional JOINs Syntax and Examples

33 Conditional JOINs Syntax JOIN [LEFT_OUTER|INNER] FILE from_file AT from_field [TAG tag1] TO {ALL|ONE} FILE to_file AT to_field [TAG tag2] [AS as_name] [WHERE expression1 ; WHERE expression2 ;... ; ] END

34 Conditional JOINs Insurance Rates TABLE FILE RATES PRINT * AGE EAGE RATE_PER_THOUSAND $ $ $ $ $ $ $ $42

35 Conditional JOINs Insurance Rates JOIN FILE EMPDATA1 AT BIRTHDATE TO ALL FILE RATES AT AGE AS J1 WHERE EMPDATA1.BAGE GE RATES.AGE; WHERE EMPDATA1.BAGE LE RATES.EAGE; END TABLE FILE EMPDATA1 HEADING "To: <FIRSTNAME <LASTNAME " "</1 Thank you for choosing our company for your <0X insurance needs." "Thank you for choosing our company for your insurance needs. " "Since your birthdate is <BIRTHDTATE,your current rate is <0X“ per <RATE_PER_THOUSAND" "unit of coverage. This is your rate through age <EAGE. “ ON TABLE SET PAGE OFF BY PIN NOPRINT PAGE-BREAK END

36 Conditional JOINs Insurance Rates and Letters To: DANIEL VALINO Thank you for choosing our company for your insurance needs. Since your birthdate is 07/20/1959, your current rate is $11 per unit of coverage. This is your rate through age 42. To: MICHAEL BELLA Thank you for choosing our company for your insurance needs. Since your birthdate is 07/27/1952, your current rate is $24 per unit of coverage. This is your rate through age 53.

37 Conditional JOINs Insurance Rates – Another Approach JOIN FILE EMPDATA1 AT BIRTHDATE TO ONE FILE RATES AT AGE AS J1 WHERE EMPDATA1.BAGE GE RATES.AGE; END -RUN -STEP2 TABLE FILE EMPDATA1 PRINT PIN BIRTHD BAGE RATE BY AGE AS 'MINIMUM AGE' END

38 Conditional JOINs Insurance Rates – Another Approach MINIMUM AGE PIN BIRTHDATE BAGE RATE_PER_THOUSAND /24/ $ /17/ $ /07/ $ /20/ $ /06/ $ /10/ $ /08/ $ /08/ $ /24/ $ /17/ $ W 02/19/ $ /21/ $ /16/ $ /20/ $ /08/ $11

39 Conditional JOINs – Clearing JOINs

40 Conditional JOINs Lots of JOINs -* 1 FOR EMPLOYEE JOIN FILE EMPLOYEE AT CURR_SAL TO ALL FILE CAR AT RETAIL_COST AS CARALL END -* 2 FOR EMPLOYEE JOIN CJC IN EMPLOYEE TO JOBCODE IN JOBFILE AS BJ -* 3 FOR EMPLOYEE JOIN FILE EMPLOYEE AT CURR_SAL TO ALL FILE CAR AT RETAIL_COST AS CAREMP WHERE EMPLOYEE.CURR_SAL GT (5 * CAR.RETAIL_COST); END -* 4 FOR CAR JOIN FILE CAR AT RETAIL_COST TO ALL FILE EMPLOYEE AT CURR_SAL AS EMPCAR WHERE EMPLOYEE.CURR_SAL GT (5 * CAR.RETAIL_COST); END

41 Conditional JOINs Lots of JOINs -* 5 FOR EMPLOYEE JOIN FILE EMPLOYEE AT LAST_NAME TO ONE FILE RETIRED AT FOCLIST AS EMPRET WHERE RETIRED.NAME CONTAINS EMPLOYEE.LAST_NAME ; END -* 6 FOR CAR JOIN COUNTRY IN CAR TO COUNTRY IN WORLD AS AJ END -RUN ? JOIN

42 Conditional JOINs Current JOINs JOINS CURRENTLY ACTIVE HOST CROSSREFERENCE FIELD FILE TAG FIELD FILE TAG AS ALL WH CURR_SAL EMPLOYEE RETAIL_COST CAR CARALL Y Y RETAIL_COST CAR CURR_SAL EMPLOYEE EMPCAR Y Y COUNTRY CAR COUNTRY WORLD AJ N N CJC EMPLOYEE JOBCODE JOBFILE BJ N N CURR_SAL EMPLOYEE RETAIL_COST CAR CAREMP Y Y LAST_NAME EMPLOYEE FOCLIST RETIRED EMPRET N Y >

43 Conditional JOINs Insurance Rates – Another Approach JOIN CLEAR CAREMP JOINS CURRENTLY ACTIVE HOST CROSSREFERENCE FIELD FILE TAG FIELD FILE TAG AS ALL WH CURR_SAL EMPLOYEE RETAIL_COST CAR CARALL Y Y RETAIL_COST CAR CURR_SAL EMPLOYEE EMPCAR Y Y COUNTRY CAR COUNTRY WORLD AJ N N CJC EMPLOYEE JOBCODE JOBFILE BJ N N CURR_SAL EMPLOYEE RETAIL_COST CAR CAREMP Y Y LAST_NAME EMPLOYEE FOCLIST RETIRED EMPRET N Y

44 Conditional JOINs Clearing JOINs JOIN CLEAR CARALL JOINS CURRENTLY ACTIVE HOST CROSSREFERENCE FIELD FILE TAG FIELD FILE TAG AS ALL WH CURR_SAL EMPLOYEE RETAIL_COST CAR CARALL Y Y RETAIL_COST CAR CURR_SAL EMPLOYEE EMPCAR Y Y COUNTRY CAR COUNTRY WORLD AJ N N CJC EMPLOYEE JOBCODE JOBFILE BJ N N CURR_SAL EMPLOYEE RETAIL_COST CAR CAREMP Y Y LAST_NAME EMPLOYEE FOCLIST RETIRED EMPRET N Y

45 Conditional JOINs – Caveats

46 Conditional JOINs Rules and Caveats  The conditional JOIN is supported for  FOCUS  VSAM  ADABAS  IMS  All relational data sources  Optimization of the conditional JOIN syntax differs  Specific data sources involved in the join  Complexity of the WHERE criteria

47 Conditional JOINs Rules and Caveats  Where possible, use EQ-JOIN  Index/Key always used  No TABLE Scan  Conditional JOIN  JOIN large file to small  Pages may remain in memory  EQ-JOIN  JOIN small file to LARGE  Reduced I/O for non-matches.

48