Data Integrity with DB2 for Z/OS

Total Page:16

File Type:pdf, Size:1020Kb

Data Integrity with DB2 for Z/OS Front cover Data Integrity with DB2 for z/OS Assert information integrity by exploiting DB2 functions Understand constraints, referential integrity, and triggers Review recovery-related functions Paolo Bruni John Iczkovits Rama Naidoo Fabricio Pimentel Suresh Sane ibm.com/redbooks International Technical Support Organization Data Integrity with DB2 for z/OS July 2006 SG24-7111-00 Note: Before using this information and the product it supports, read the information in “Notices” on page xv. First Edition (July 2006) This edition applies to Version 8 of IBM Database 2 Universal Database for z/OS (DB2 UDB for z/OS), program number 5625-DB2. © Copyright International Business Machines Corporation 2006. All rights reserved. Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Figures . ix Examples . xi Tables . xiii Notices . .xv Trademarks . xvi Preface . xvii The team that wrote this redbook. xvii Become a published author . xix Comments welcome. xix Chapter 1. Introduction. 1 1.1 Host platform. 3 1.1.1 z/OS and OS/390 system integrity . 4 1.1.2 System-level security . 5 1.1.3 Transaction-level security . 7 1.1.4 zSeries cryptography . 8 1.1.5 System z integrity features . 9 1.1.6 The zIIP. 10 1.1.7 VSAM share options . 11 1.1.8 Data sharing integrity . 12 1.1.9 Global resource serialization. 12 1.1.10 DB2 controls . 12 1.1.11 Auditing your DB2 applications . 15 1.1.12 Other security enhancements . 20 1.1.13 DB2 column level encryption. 22 1.1.14 IBM Data Encryption for IMS and DB2 Databases . 24 1.2 Information integrity. 25 1.3 DB2 and data integrity. 29 1.3.1 Entity integrity . 30 1.3.2 Semantic integrity . 30 1.3.3 Referential integrity . 31 1.3.4 Domain integrity . 32 1.4 Example of integrity needed across applications . 32 1.4.1 Customer names and addresses across applications. 33 Chapter 2. Semantic integrity . 35 2.1 Constraints . 36 2.1.1 Data constraint . 36 2.1.2 NOT NULL constraints . 37 2.1.3 Unique constraint . 37 2.1.4 Check constraints . 39 2.2 Distinct types. 42 2.2.1 Why distinct types . 42 2.2.2 Creating a distinct type . 43 2.2.3 Generated cast functions . 43 © Copyright IBM Corp. 2006. All rights reserved. iii 2.2.4 Comparing distinct types. 44 2.2.5 Assigning a distinct type . 44 2.2.6 Invoking routines with distinct types . 46 2.2.7 Errors with comparisons across distinct types . 46 2.2.8 Summary and usage recommendations . 47 Chapter 3. Referential integrity . 49 3.1 Referential constraints . 50 3.2 RI in the relational model . 51 3.2.1 RI concepts . 51 3.2.2 RI rules and options . 56 3.3 RI in DB2. 57 3.3.1 Additional DB2 terminology. 58 3.3.2 Data definitions for RI . 62 3.3.3 Plan, package, and trigger considerations . 69 3.3.4 Maintaining RI when using data encryption . 70 3.3.5 Informational referential constraint . 70 3.4 Functional implications . 71 3.4.1 DELETE rule for self-referencing tables . 71 3.4.2 DELETE with RESTRICT . 72 3.4.3 DELETE with SET NULL. 72 3.4.4 Cycles should not cause a table to be delete-connected to itself . 73 3.4.5 Table delete-connections through multiple paths . 75 3.4.6 INSERT. 78 3.4.7 UPDATE . 79 3.4.8 DELETE . 80 3.5 Summary of design recommendations . ..
Recommended publications
  • Referential Integrity in Sqlite
    CS 564: Database Management Systems University of Wisconsin - Madison, Fall 2017 Referential Integrity in SQLite Declaring Referential Integrity (Foreign Key) Constraints Foreign key constraints are used to check referential integrity between tables in a database. Consider, for example, the following two tables: create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR ); We can enforce the constraint that a Student’s residence actually exists by making Student.residence a foreign key that refers to Residence.name. SQLite lets you specify this relationship in several different ways: create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR, FOREIGNKEY(residence) REFERENCES Residence(name) ); or create table Residence ( nameVARCHARPRIMARY KEY, capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR REFERENCES Residence(name) ); or create table Residence ( nameVARCHARPRIMARY KEY, 1 capacityINT ); create table Student ( idINTPRIMARY KEY, firstNameVARCHAR, lastNameVARCHAR, residenceVARCHAR REFERENCES Residence-- Implicitly references the primary key of the Residence table. ); All three forms are valid syntax for specifying the same constraint. Constraint Enforcement There are a number of important things about how referential integrity and foreign keys are handled in SQLite: • The attribute(s) referenced by a foreign key constraint (i.e. Residence.name in the example above) must be declared UNIQUE or as the PRIMARY KEY within their table, but this requirement is checked at run-time, not when constraints are declared. For example, if Residence.name had not been declared as the PRIMARY KEY of its table (or as UNIQUE), the FOREIGN KEY declarations above would still be permitted, but inserting into the Student table would always yield an error.
    [Show full text]
  • Clarion & ANSI SQL Standard Referential Integrity and Referential
    Clarion & ANSI SQL Standard Referential Integrity and Referential Actions November 12, 2018 Whitemarsh Information Systems Corporation 2008 Althea Lane Bowie, Maryland 20716 Tele: 301-249-1142 Email: [email protected] Web: www.wiscorp.com Referential Integrity and Referential Actions Fundamental Definition: Actions resulting from instruction to the database engine created in the dictionary (i.e., schema) associated with “Relationship” specifications. For SQL-engine DBMSs, these relationship-specifications and actions relate to value congruence between the value-set of a primary key’s column(s) and the value-set of a Foreign key’s column(s). When either a Update or Delete action occurs that violates the value congruence, a Referential Action occurs. The actions depend on whether the Referential Action is specified. In ANSI SQL Standards, the four referential integrity actions: No Action, Cascade, or Set Null or Set Default. In Clarion, the five referential integrity actions are: None, Restrict, Cascade, Clear, Cascade Server, ClearServer and Restrict Server. Copyright 2018, Whitemarsh Information Systems Corporation Proprietary Data, All Rights Reserved 2 Referential Integrity and Referential Actions Referential Integrity and Actions Referential Action taken when violation occurs On Update On Delete Referential Action Parent Child Parent Child Function ANSI Clarion Table Table Table Table Parent Table No equivalent None: Instructs the Primary No change Row is Nothing. Primary Key Application Generator not key in the deleted Effect is to Column value can to generate any code to column foreign key make the change. Foreign maintain referential value can value child table Key Column value integrity between any change row an does not change.
    [Show full text]
  • Relational Schema Relational Integrity
    Relational Schema Relational Integrity Unpassionate and purposeless Orlando never combine his incalculability! Infinitival Oswald signalize canonically or proceed trustingly when Piotr is leery. Orbadiah volatilizes her options bulgingly, she outwalks it amorally. Save my choice for tables can have no parent table, only on data are problems with multiple base tables may be a combination with the! Employee to radio mandatory role of Employee. DBMSs to check important data satisfies the semantics. Filing System, the dummy set add all Counties of all Countries. It does not seriously affect both tables related in relation schema designs the integrity constraints are. RFS, this sin that goes do dot use fresh unique ID to identify value object. Manual is separate horn the Product entity. Overlap constraints: Can Joe be an Hourly_Emps as through as a Contract_Emps entity? Web site which select a few attributes. Was this on helpful? It involves the relational tables that data are shown is an entity and implemented via objects are modified depending on file sharing services can! In relational schema may want to track of your session has gained wide range of moral character. There is our chance for duplication of data. An unknown error occurred. DBMSs but were originally slower. The second sentence to keep only two tables separated. Similarly, data manipulation, enabling them to shelter network traffic and unit run in disconnected mode. Eer object over any data item, delete all enrolled tuple. When there was not refundable and each table should not allowed through views reflects pdf solve mcq quiz yourself, relational integrity risk is called dno in.
    [Show full text]
  • CSC 443 – Database Management Systems Data and Its Structure
    CSC 443 – Database Management Systems Lecture 3 –The Relational Data Model Data and Its Structure • Data is actually stored as bits, but it is difficult to work with data at this level. • It is convenient to view data at different levels of abstraction . • Schema : Description of data at some abstraction level. Each level has its own schema. • We will be concerned with three schemas: physical , conceptual , and external . 1 Physical Data Level • Physical schema describes details of how data is stored: tracks, cylinders, indices etc. • Early applications worked at this level – explicitly dealt with details. • Problem: Routines were hard-coded to deal with physical representation. – Changes to data structure difficult to make. – Application code becomes complex since it must deal with details. – Rapid implementation of new features impossible. Conceptual Data Level • Hides details. – In the relational model, the conceptual schema presents data as a set of tables. • DBMS maps from conceptual to physical schema automatically. • Physical schema can be changed without changing application: – DBMS would change mapping from conceptual to physical transparently – This property is referred to as physical data independence 2 Conceptual Data Level (con’t) External Data Level • In the relational model, the external schema also presents data as a set of relations. • An external schema specifies a view of the data in terms of the conceptual level. It is tailored to the needs of a particular category of users. – Portions of stored data should not be seen by some users. • Students should not see their files in full. • Faculty should not see billing data. – Information that can be derived from stored data might be viewed as if it were stored.
    [Show full text]
  • March 2017 Report
    BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 6 Professional Graduate Diploma in IT ADVANCED DATABASE MANAGEMENT SYSTEMS March 2017 Answer any THREE questions out of FIVE. All questions carry equal marks. Time: THREE hours Answer any Section A questions you attempt in Answer Book A Answer any Section B questions you attempt in Answer Book B The marks given in brackets are indicative of the weight given to each part of the question. Calculators are NOT allowed in this examination. Section A Answer Section A questions in Answer Book A A1 Examiner's General Comments This was a fairly popular question, attempted by around half of the candidates, with two-thirds of the attempts achieving pass level marks. Therefore, the performance was generally quite good with a wide range of marks, some candidates producing near correct solutions. The definition of a true distributed database system is that it consists of a collection of geographically remote sites of physical databases, connected together via some kind of communication network, in which a user at any site can access data anywhere in the network exactly as if the data were all stored in one single database at the user’s own site. a) Explain the problems associated with achieving a true distributed database in practice. 12 marks ANSWER POINTER Fragmentation of tables requires maintenance of unique keys across horizontal fragments and consistency of primary keys that are reflected in vertical fragments. Also increased network traffic occurs as many fragments may need to be consulted to perform one query.
    [Show full text]
  • Declarative Constraints
    THREE Declarative Constraints 3.1 PRIMARY KEY 3.1.1 Creating the Constraint 3.1.2 Naming the Constraint 3.1.3 The Primary Key Index 3.1.4 Sequences 3.1.5 Sequences in Code 3.1.6 Concatenated Primary Key 3.1.7 Extra Indexes with Pseudo Keys 3.1.8 Enable, Disable, and Drop 3.1.9 Deferrable Option 3.1.10 NOVALIDATE 3.1.11 Error Handling in PL/SQL 3.2 UNIQUE 3.2.1 Combining NOT NULL, CHECK with UNIQUE Constraints 3.2.2 Students Table Example 3.2.3 Deferrable and NOVALIDATE Options 3.2.4 Error Handling in PL/SQL 3.3 FOREIGN KEY 3.3.1 Four Types of Errors 3.3.2 Delete Cascade 3.3.3 Mandatory Foreign Key Columns 3.3.4 Referencing the Parent Syntax 3.3.5 Referential Integrity across Schemas and Databases 3.3.6 Multiple Parents and DDL Migration 3.3.7 Many-to-Many Relationships 3.3.8 Self-Referential Integrity 3.3.9 PL/SQL Error Handling with Parent/Child Tables 3.3.10 The Deferrable Option 69 70 Chapter 3 • Declarative Constraints 3.4 CHECK 3.4.1 Multicolumn Constraint 3.4.2 Supplementing Unique Constraints 3.4.3 Students Table Example 3.4.4 Lookup Tables versus Check Constraints 3.4.5 Cardinality 3.4.6 Designing for Check Constraints 3.5 NOT NULL CONSTRAINTS 3.6 DEFAULT VALUES 3.7 MODIFYING CONSTRAINTS 3.8 EXCEPTION HANDLING 3.9 DATA LOADS This is the first of several chapters that cover enforcing business rules with con- straints.
    [Show full text]
  • (12) United States Patent (10) Patent No.: US 9,053,153 B2 Schreter (45) Date of Patent: Jun
    US009053153B2 (12) United States Patent (10) Patent No.: US 9,053,153 B2 Schreter (45) Date of Patent: Jun. 9, 2015 (54) INTER-QUERY PARALLELIZATION OF 95. R. 358. RaSudevan al. et.....I707,as: al. CONSTRAINT CHECKING 7,113.953 B2 * 9/2006 Brown et al. ...... 707,615 7,240,054 B2 * 7/2007 Adiba et al. .......................... 1.1 (75) Inventor: Ivan Schreter, Malsch (DE) 8,301,934 B1 * 10/2012 Ramesh et al. ................. T14, 18 8,336,051 B2 * 12/2012 Gokulakannan ... ... 718, 101 (73) Assignee: SAP SE, Walldorf (DE) 8,375,047 B2 * 2/2013 Narayanan et al. ... 707 764 2002/01741.08 A1* 11/2002 Cotner et al. ..................... 707/3 - r 2004/0010502 A1* 1 2004 Bomfim et al. 7O7/1OO (*) Notice: Subject to any disclaimer, the term of this 2005, 0131893 A1* 6/2005 Von Glan .......................... 707/5 patent is extended or adjusted under 35 2006/0212465 A1* 9, 2006 Fish et al. ... 707/101 U.S.C. 154(b) by 12 days. 2007/0239661 A1* 10, 2007 Cattell et al. ...................... 707/2 2009/0037498 A1* 2/2009 Mukherjee et al. ........... 707,205 (21) Appl. No.: 13/525,935 2010/0005077 A1* 1/2010 Krishnamurthy et al. ........ 7O7/4 9 2011/0010330 A1 1/2011 McCline et al. .............. 707,602 1-1. 2012/0254887 A1* 10/2012 Rodriguez ... ... 718, 106 (22) Filed: Jun. 18, 2012 2012fO265728 A1* 10, 2012 Plattner et al. 707/6O7 2012/0278282 A1* 11/2012 Lu et al. ......... TO7/634 (65) Prior Publication Data 2012,0310985 A1* 12/2012 Gale et al.
    [Show full text]
  • Referential Integrity Quality Metrics
    Referential Integrity Quality Metrics Carlos Ordonez Javier Garc´ıa-Garc´ıa University of Houston UNAM Houston, TX 77204, USA Mexico City, CU 04510, Mexico ∗ Abstract Referential integrity is an essential global constraint in a relational database, that maintains it in a complete and consistent state. In this work, we assume the database may violate referential integrity and relations may be denormalized. We propose a set of quality metrics, defined at four granularity levels: database, relation, attribute and value, that measure referential completeness and consistency. Quality metrics are efficiently computed with standard SQL queries, that incorporate two query optimizations: left outer joins on foreign keys and early foreign key grouping. Experiments evaluate our proposed metrics and SQL query optimizations on real and synthetic databases, showing they can help detecting and explaining referential errors. 1 Introduction Referential integrity is a fundamental global constraint in a relational database [8], that basically ensures a foreign key value exists in the referenced relation. Referential integrity issues are found in database integra- tion, data quality assurance, data warehousing and data modeling. Referential integrity is violated or relaxed for practical reasons. Database integration represents a common scenario where similar tables coming from multiple source databases (OLTP systems) have different referential integrity constraints and each DBMS provides distinct mechanisms and rules to enforce referential integrity [20]. Therefore, source databases may violate referential integrity and their integration may uncover additional referential integrity problems. Performance is the second common reason, where referential integrity checking is disabled to allow fast insertions in batch mode. Finally, the logical data model behind a relational database evolves, incorporating new attributes and new relations not defined before, causing old data to violate new referential integrity constraints.
    [Show full text]
  • Referential Integrity Revisited: an Object-Oriented Perspective
    REFERENTIAL INTEGRITY REVISITED~AN OBJECT-ORIENTED PERSPECTIVE* VICTOR M. ~KOWITZ Lawrence Berkeley Laboratory Computer Science Research and Development Department 1 Cyclotron Road, Berkeley, CA 94720 ABSTRACT represented by relation tuples, while object connec- Referential integrity underlies the relational tions are represented by references between tuples. representation of objeceoriented structures. The con- Such references are enforced in relational databases cept of referential integrity in relational databases is by referential integrity constraints [2]. There are two hindered by the confusion surrounding both the con- approaches to the specification of these constraints in cept itself and its implementation by relational data- relational databases. In the Universal Relation (UR) base management systems (RDBMS). Most of this approach [ll], referential integrity constraints are confusion is caused by the diversity of relational implied by associating different relations with com- representations for object-oriented structures. We mon attributes; the referential integrity meaning of examine the relationship between these representa- relations sharing common attributes is defined by a tions and the structure of referential integrity con- set of rules, called UR assumptions. The UR assump- straints, and show that the controversial structures tions make the description of object structures either do not occur or can be avoided in the rela- extremely difficult and not entirely reliable, mainly tional representations of object-oriented structures. becaise they require excessively complex attribute Referential integrity is not supported uniformly name assignments. by RDBMS products. Thus, referential integrity con- A different approach to the specification of straints can be specified in some RDBMSs non- referential integrity constraints is ‘to associate expli- procedurally (declaratively) , while in other RDBMSs citly a foreign-key in one relation with the primary- they must be specified procedurally.
    [Show full text]
  • 4 Schema Definition with SQL / DDL (II)
    4.3 SQL/DDL - Constraints Different kinds of integrity constraints 4 Schema Definition with SQL / DDL (II) Important • on attributes, column constraints “ 0 <= accountValue“, “must not be NULL” 4.3 SQL/DDL – Constraints • cardinalities 4.3.1 Attribute and simple table constraints 4.3.2 Enforcing cardinality constraints and foreign keys • “semantic” constraints ("business rules") 4.3.3 Deferred constraints e.g. "The percentage of movies not older than one year must be 25% or more" 4.3.4 Assertions and triggers " After 100 loans a video tape (not DVD) has to be discarded" 4.3.5 Case study – Column constraint 4.3.6 Metadata management Specify constraint as part of column definition 4.3.7 Modifying and deleting definitions and more… – Table constraint More than one row involved, specify constraint after the column definitions HS / DBS04-06-DDL -2 2 Constraints 4.3.1 Attribute and simple table constraints Constraints may be violated when DB is changed • PRIMARY KEY (update, insert, delete) – Only once per table ð Exception – Not necessary, but omission is bad style ORA-02291: integrity constraint (SYS_C0067174) – May be column constraint (single attribute) or table violated - parent key not found constraint CREATE TABLE Tape( Constraint name (optional) t_id INTEGER PRIMARY KEY, m_id INTEGER NOT NULL, CONSTRAINT <name> <def> format CHAR(5), Advantage: error message shows violated constraint in a aquired DATE ) readable way CREATE TABLE People( ORA-02291: integrity constraint name VARCHAR(20), (FKMovieOnTape.SYS_C0067174) violated - parent birth_date
    [Show full text]
  • CGS 2545: Database Concepts Summer 2007
    CGS 2545: Database Concepts Summer 2007 Chapter 7 – Introduction To SQL Instructor : Mark Llewellyn [email protected] HEC 236, 823-2790 http://www.cs.ucf.edu/courses/cgs2545/sum2007 School of Electrical Engineering and Computer Science University of Central Florida CGS 2545: Database Concepts (Chapter 7) Page 1 Mark Llewellyn Objectives • Definition of terms. • Discuss advantages of standardized SQL. • Define a database using SQL data definition language. • Write single table queries using SQL. • Establish referential integrity using SQL. • Work with Views. CGS 2545: Database Concepts (Chapter 7) Page 2 Mark Llewellyn The Physical Design Stage of SDLC (Figures 2-4, 2-5 revisited) Project Identification Purpose –programming, testing, and Selection training, installation, documenting Project Initiation Deliverable – operational programs, and Planning documentation, training materials, program/data structures Analysis Logical Design PhysicalPhysical Design Database activity – physical database design and ImplementationImplementation database implementation Maintenance CGS 2545: Database Concepts (Chapter 7) Page 3 Mark Llewellyn SQL Overview •SQL ≡ Structured Query Language. • The standard for relational database management systems (RDBMS). • SQL-99 and SQL: 2003 Standards – Purpose: – Specify syntax/semantics for data definition and manipulation. – Define data structures. – Enable portability. – Specify minimal (level 1) and complete (level 2) standards. – Allow for later growth/enhancement to standard. CGS 2545: Database Concepts (Chapter 7) Page 4 Mark Llewellyn Benefits of a Standardized Relational Language • Reduced training costs • Productivity • Application portability • Application longevity • Reduced dependence on a single vendor • Cross-system communication CGS 2545: Database Concepts (Chapter 7) Page 5 Mark Llewellyn The SQL Environment • Catalog – A set of schemas that constitute the description of a database.
    [Show full text]
  • Enforcement of Partial Referential Integrity in a Database System
    International Journal of Computer Science and Mathematical Theory ISSN 2545-5699 Vol. 4 No.2 2018 www.iiardpub.org Enforcement of Partial Referential Integrity in a Database System Jaja, Azunna Ibimina & E. O. Bennett Department of Computer Science Rivers State University, Port Harcourt. Nigeria. [email protected], [email protected] Abstract A lack of Referential Integrity in a database can lead Relational Databases to return incomplete data, usually with no indication of an error thus it results in records been lost in the database because they are not returned in queries or reports but the presence of Referential Integrity checks prevents orphan table that no longer has a relationship with its parent table by deleting the orphan row, updating the cells or preventing the action from be performed. However, Simple Referential Integrity cannot check for multiple referential relationships as such this research aims at developing a module that will enforce Partial Referential Integrity checks for MySQL database. The Structured System Analysis and Design Methodology (SSADM) was used in the design and implemented with Java programming language. Meanwhile the tools used for this research are Stored Procedures which encapsulates sets of operations or queries to execute on the database server which is supported by most Relational database systems. Furthermore, MySQL Workbench which is a Graphical User Interface based tool was used to run the queries. Therefore the module will reject or validate data that passes the partial referential integrity check and a database was used to test the module hence the results show that the execution time of the system without the module is less than the execution time of the system with the module because the module ensures that data queried are valid and also, the integrity of the system that uses the module shows that the data in the system meets all constraints enforced and the work done by the database server is minimized.
    [Show full text]