Advanced Functions and Administration on DB2 Universal Database for Iseries
Total Page:16
File Type:pdf, Size:1020Kb
IBM Advanced Functions and Administration on DB2 Universal Database for iSeries Learn about referential integrity and constraints See how Database Navigator maps your database Discover the secrets of Visual Explain Hernando Bedoya Daniel Lema Vijay Marwaha Dave Squires Mark Walas ibm.com/redbooks International Technical Support Organization Advanced Functions and Administration on DB2 Universal Database for iSeries December 2001 SG24-4249-03 Take Note! Before using this information and the product it supports, be sure to read the general information in “Special notices” on page 345. Fourth Edition (December 2001) This edition applies to Version 5, Release 1 of OS/400, Program Number 5722-SS1. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. JLU Building 107-2 3605 Highway 52N Rochester, Minnesota 55901-7829 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. © Copyright International Business Machines Corporation 1994, 1997, 2000, 2001. All rights reserved. Note to U.S Government Users - Documentation related to restricted rights - Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Contents . iii Preface . ix The team that wrote this redbook. ix Special notice. xi IBM trademarks . xi Comments welcome. xii Part 1. Background. 1 Chapter 1. Introducing DB2 UDB for iSeries . 3 1.1 An integrated relational database . 4 1.2 DB2 UDB for iSeries: An overview . 4 1.2.1 DB2 UDB for iSeries basics . 5 1.2.2 DB2 UDB for iSeries advanced functions . 6 1.3 DB2 Universal Database for iSeries sample schema . 8 Chapter 2. Using the advanced functions: An Order Entry application. 11 2.1 Introduction to the Order Entry application . 12 2.2 Order Entry application overview . 12 2.3 Order Entry database overview. 14 2.4 DB2 UDB for iSeries advanced functions in the Order Entry database . 17 2.4.1 Referential integrity . 17 2.4.2 Two-phase commit . 18 Part 2. Advanced functions . 19 Chapter 3. Referential integrity . 21 3.1 Introduction . 22 3.2 Referential integrity concepts . 22 3.3 Defining a referential integrity relationship . 24 3.3.1 Constraint prerequisites . 24 3.3.2 Journaling and commitment control requirements . 25 3.3.3 Referential integrity and access paths . 25 3.4 Creating a referential constraint . 28 3.4.1 Primary key and unique constraints . 29 3.4.2 Referential constraint . 30 3.4.3 Another example: Order Entry scenario . 32 3.4.4 Self-referencing constraints . 34 3.5 Constraints enforcement . 35 3.5.1 Locking considerations . 35 3.5.2 Referential integrity rules ordering . 36 3.5.3 A CASCADE example. 39 3.6 Journaling and commitment control . 43 3.6.1 Referential integrity journal entries . 45 3.6.2 Applying journal changes and referential integrity . 49 3.7 Referential integrity application impact . 50 3.7.1 Referential integrity I/O messages . 50 3.7.2 Handling referential integrity messages in applications . 51 © Copyright IBM Corp. 1994, 1997, 2000, 2001 iii 3.8 Referential integrity constraint management. 52 3.8.1 Constraint states . 52 3.8.2 Check pending . 53 3.8.3 Constraint commands . 53 3.8.4 Removing a constraint . 56 3.8.5 Save and restore considerations . 59 3.8.6 Restore and journal apply: An example . 61 3.8.7 Displaying constraint information . 61 Chapter 4. Check constraint. 67 4.1 Introduction . 68 4.1.1 Domain or table constraints . 68 4.1.2 Referential integrity constraints. 68 4.1.3 Assertions . 68 4.2 DB2 UDB for iSeries check constraints. 69 4.3 Defining a check constraint . 70 4.4 General considerations . 75 4.5 Check constraint integration into applications. 77 4.5.1 Check constraint I/O messages . 77 4.5.2 Check constraint application messages . 78 4.6 Check constraint management . 79 4.6.1 Check constraint states. 80 4.6.2 Save and restore considerations . 81 4.7 Tips and techniques . 82 Chapter 5. DRDA and two-phase commitment control . 83 5.1 Introduction to DRDA . 84 5.1.1 DRDA architecture . 84 5.1.2 SQL as a common DRDA database access language . 84 5.1.3 Application requester and application server . 84 5.1.4 Unit of work . 85 5.1.5 Openness . ..