© Logicalis Group Using DB2/400 effectively. Data integrity facilities Traditional iSeries database usage Applications are responsible for data integrity.

Slides:



Advertisements
Similar presentations
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Advertisements

ERWin Template Overview By: Dave Wentzel. Agenda u Overview of Templates/Macros u Template editor u Available templates u Independent column browser u.
Advantage Data Dictionary. agenda Creating and Managing Data Dictionaries –Tables, Indexes, Fields, and Triggers –Defining Referential Integrity –Defining.
Monday, 08 June 2015Dr. Mohamed Osman1 What is Database Administration A high level function (technical Function) that is responsible for ► physical DB.
Maintenance Modifying the data –Add records –Delete records –Update records Modifying the design –Add fields into tables –Remove fields from a table –Change.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Introduction to Databases CIS 5.2. Where would you find info about yourself stored in a computer? College Physician’s office Library Grocery Store Dentist’s.
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
Concepts of Database Management Sixth Edition
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
A Guide to SQL, Seventh Edition. Objectives Understand, create, and drop views Recognize the benefits of using views Grant and revoke user’s database.
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
10/3/2000SIMS 257: Database Management -- Ray Larson Relational Algebra and Calculus University of California, Berkeley School of Information Management.
Working with SQL and PL/SQL/ Session 1 / 1 of 27 SQL Server Architecture.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
Oracle Data Definition Language (DDL)
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Module 3: Table Selection
Database Lecture # 1 By Ubaid Ullah.
Primary & Foreign Keys. PK & FK 1.Primary key is required 2.The PK must be unique 3.If the primary key from one table is related to a field in another.
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Chapter 4 The Relational Model 3: Advanced Topics Concepts of Database Management Seventh Edition.
Database Technical Session By: Prof. Adarsh Patel.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
1 IRU Concurrency, Reliability and Integrity issues Geoff Leese October 2007 updated August 2008, October 2009.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
Commercial RDBMSs Access and Oracle. Access DBMS Architchecture  Can be used as a standalone system on a single PC: -JET Engine -Microsoft Data Engine.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
Oracle 11g: SQL Chapter 4 Constraints.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
DBT544. DB2/400 Advanced Features Level Check Considerations Database Constraints File Overrides Object and Record Locks Trigger Programs.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
Topics Related to Attribute Values Objectives of the Lecture : To consider sorting relations by attribute values. To consider Triggers and their use for.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Session 1 Module 1: Introduction to Data Integrity
WEEK 13 Recovery, Causes of Failure, Local Recovery Protocols (Undo/Redo/No-Redo), Distributed Recovery Protocols, DTPC.
Relational Database Management System(RDBMS) Structured Query Language(SQL)
Starting with Oracle SQL Plus. Today in the lab… Connect to SQL Plus – your schema. Set up two tables. Find the tables in the catalog. Insert four rows.
Constraints Review. What is a constraint? Unique – forbids duplicate values Referencial – Foreign key Check Constraint – sets restrictions on data added.
Chapter 3: Relational Databases
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 2 Objectives: Understanding and Creating Table.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Database Constraints ICT 011. Database Constraints Database constraints are restrictions on the contents of the database or on database operations Database.
Getting started with Accurately Storing Data
Module 11: File Structure
Database Systems Instructor Name: Lecture-12.
Module 5: Implementing Data Integrity by Using Constraints
CS122 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Chapter 11 Managing Databases with SQL Server 2000
CS1222 Using Relational Databases and SQL
CS122 Using Relational Databases and SQL
Updating Databases With Open SQL
CS122 Using Relational Databases and SQL
Updating Databases With Open SQL
Presentation transcript:

© Logicalis Group Using DB2/400 effectively

Data integrity facilities Traditional iSeries database usage Applications are responsible for data integrity Back door access possible Defensive coding required Data integrity built in Application may assume data integrity Code is smaller Data cannot be corrupted... assuming correct database design

Changes to database files Database file RPG program in batch job Visual Basic program using ODBC RPG program in interactive job DFU YWRKF

Data integrity facilities Referential integrity forces internal consistency of the database Order present implies customer details present Triggers force the database to comply with local company rules Field/record validation before database change Additional processing after database change

Integrated Language Environment Develop code in most suitable language(s), and in small modules, without traditional performance trade-off Multiple activation groups within job Commitment control in one activation group is independent of that in another

Original Program Model Completely dynamic Convenient Maintainable Slow One entry point per program

Integrated Language Environment Static (*PGM) or dynamic (*SRVPGM) Calls to OPM programs supported but slow OPM may call ILE *PGM’s main entry point only Much, much faster than OPM

Referential constraints Customer file CUSNBRCUSNAM... Order headers ORHNBRCUSNBR Order details ORHNBRPRDNBR Parent key Foreign key PK FK Compare Synon/2 OWNED BY and REFERS TO relationships Parent file Dependent file Parent file Dependent file

Referential constraints: types RESTRICT (update or delete) CASCADE (delete) NO ACTION (update or delete: *BEFORE trigger is invoked, but database is not updated) SET DEFAULT (delete) SET NULL (delete)

Referential constraints: when the checks are made Delete from parent file Update to parent file (where constrained key is being updated) or to dependent file Insert into dependent file

Referential constraints: journalling and access paths RESTRICT does not require journalling For all other rules parent and dependent files must be journalled to the same journal implicit commitment control is started Constraint access paths are created May share existing access paths

Referential constraints: primary and unique keys Physical file with UNIQUE access path specified in its DDS has a primary key (Synon/2 KNOWN BY) for use as a parent key All other parent keys are called unique keys For consistency with other DBMS

Referential constraints: implementation ADDPFCST or SQL ALTER TABLE Not in DDS, so change control implications May sometimes want to disable constraints temporarily (CHGPFCST) integrity is automatically verified when constraint is re-enabled Display via DSPFD, DSPDBR

Referential constraints: re-establishing Verification of constraints follows e.g. any restore of a constrained file Verification failure results in check pending status EDTCPCST (also appears at manual IPL) to display check pending constraints across the system Disable constraint, fix records, re-enable

Triggers ADDPFTRG command (or via SQL), not in DDS Program written in any language and passed a trigger buffer No data may be returned by the trigger, only ‘OK’ or ‘Error’ Runs synchronously within your job: *LIBL, QTEMP, may share existing open data paths Not invoked by APYJRNCHG Record level, not field level

Triggers: types *INSERT, *UPDATE, *DELETE *BEFORE, *AFTER Update trigger may be *ALWAYS or *CHANGE

Trigger buffer File name Library name Member name ‘1’=insert, ‘2’=delete, ‘3’=update ‘1’=before, ‘2’=after commitment control status CCSID Old record offset Old record length Old record null map offset Old record null map length New record offset New record length New record null map offset New record null map length Old record image Old record null map New record image New record null map

Trigger feedback *BEFORE triggers indicate problems by sending escape messages (QMHSNDPM API). I/O operation then fails, which sets activating program’s error indicator The same happens if the trigger itself fails Specific exception returned cannot be picked up by activating program - need standard for e.g. use of *LDA to communicate details of problem Exceptions returned by *AFTER triggers are ignored

Triggers and data integrity Trigger may not change the record that activated it Either share existing commitment control definition and do not COMMIT or ROLLBACK, or start trigger’s own commitment control definition and be sure to COMMIT or ROLLBACK If only trigger has commitment control, trigger must be run in a separate ILE activation group, so that immediate rollback occurs if the trigger fails

Additional SQL capability ALTER TABLE System-wide catalog: SYSTABLES, SYSCOLUMNS Describes all PFs, whether or not in SQL collections Auxiliary storage implications

Two-phase commit System A, running application System B System C Commitment control with DDM SQL: Distributed Unit of Work