Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

MSc IT UFCE8K-15-M Data Management Prakash Chatterjee Room 2Q18
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
Monday, 08 June 2015Dr. Mohamed Osman1 What is Database Administration A high level function (technical Function) that is responsible for ► physical DB.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Database Integrity, Security and Recovery Database integrity Database integrity Database security Database security Database recovery Database recovery.
Introduction to Structured Query Language (SQL)
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
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.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 157 Database Systems I SQL Constraints and Triggers.
Database Constraints. Database constraints are restrictions on the contents of the database or on database operations Database constraints provide a way.
CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
Chapter 6: Integrity and Security Thomas Nikl 19 October, 2004 CS157B.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden Date:
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
Database Technical Session By: Prof. Adarsh Patel.
Made by: Sambit Pulak XI-IB. Reliability refers to the operation of hardware, the design of software, the accuracy of data or the correspondence of data.
Data Modeling and Database Design
Instructor: Churee Techawut Basic Concepts of Relational Database Chapter 5 CS (204)321 Database System I.
Chapter 10 – Database Creation1 IT238: Data Modeling and Database Design Unit 6: Database Creation Instructor: Qing Yan, M.D., Ph.D.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
R ELATIONAL D ATA M ODEL Joe Meehean 1. R ELATIONAL D ATA M ODEL Data stored as a set of relations really just tables Tables related to one another through.
SQL Server 7.0 Maintaining Referential Integrity.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Fall 2001Database Systems1 Triggers Assertions –Assertions describe rules that should hold for a given database. –An assertion is checked anytime a table.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
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.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
Session 1 Module 1: Introduction to Data Integrity
Integrity Prof. Yin-Fu Huang CSIE, NYUST Chapter 9.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Databases Introduction - concepts. Concepts of Relational Databases.
Chapter 4 The Relational Model Pearson Education © 2009.
SQL Triggers, Functions & Stored Procedures Programming Operations.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
SQL IMPLEMENTATION & ADMINISTRATION Data Integrity, Constraints, Relationships & Joins.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
1 Agenda TMA02 M876 Block 4. 2 Model of database development data requirements conceptual data model logical schema schema and database establishing requirements.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
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
Logical Database Design and the Rational Model
Chapter 6: Integrity (and Security)
Chapter 6 - Database Implementation and Use
Module 5: Implementing Data Integrity by Using Constraints
Database solutions Chosen aspects of the relational model Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology.
Relational Database Design
INSTRUCTOR: MRS T.G. ZHOU
SQL – Constraints & Triggers
Presentation transcript:

Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management

Data integrity o What is data integrity? Data integrity is vital in a database; if the quality of the data is questionable, any information derived from that data must be suspect. The relational model defines four types of integrity that can be used to ensure that the data in the database is consistent and correct: o Domain integrity o Entity integrity o Referential integrity o User integrity UFCE8K-15-M Data Management 2014/152

Domain integrity (1) Domain integrity is to do with the values that may be contained within a specific column. All columns have an implicit domain derived from their data type (e.g. character, string, integer, boolean, real, etc.). Some databases support the CREATE DOMAIN statement. A domain can also be defined with a number of CHECK clauses and a DEFAULT value. If a domain definition is allowed, then it can be used instead of a data type in a column definition. This has the advantage that the same definition of data type, check clauses and default value can be used in many column definitions and therefore those columns are guaranteed to have the same attributes. UFCE8K-15-M Data Management 2014/153

Domain integrity (2) If a DEFAULT value is not specified for a column definition (either explicitly or implicitly through the use of a DOMAIN) then NULL can be used. A column definition can specify NOT NULL. This indicates that the table column must contain a value for each row. By implication a column definition that does not specify NOT NULL do not have to contain an actual value. NULL is a condition (rather than a value) that represents at least one of three states of the data values: not applicable, applicable but not available, or applicability unknown. While this is not formally a domain constraint it is an important concept that is referred to in the other constraints. UFCE8K-15-M Data Management 2014/154

Entity integrity Entity integrity ensures that each row in a table is uniquely identified. The concept is basic to database design. The primary key of a table is one or more columns that are used to uniquely identify each row of the table. The primary key enforces entity integrity. A table can only have one primary key. The primary key constraint does not allow duplicate values and does not allow NULL. UFCE8K-15-M Data Management 2014/155

Referential integrity Referential integrity is concerned with the maintenance of relationships between tables. A referential constraint defines a foreign key relationship between the referencing table and another table in the database (the 'referenced table'). The foreign key is defined in the referencing table as a relationship either the primary key or one of the unique keys in the referenced table. For example, you cannot insert into the referencing table a foreign key value that does not exist in the referenced table. This rule of referential integrity ensures that a non-NULL value of a foreign key must be within the domain of the related primary or unique key. Rules can be defined in references that specify the action to be taken on the affected rows of the referencing table when a DELETE operation is performed on the referenced table. These rules can define one of the following triggered actions: CASCADE, the affected rows are also deleted; SET NULL, the appropriate foreign key columns are set to NULL; SET DEFAULT, the appropriate foreign key columns are set to their default value; and NO ACTION, which raises an error because the referential constraint would be violated. UFCE8K-15-M Data Management 2014/156

User integrity (1) o User integrity covers all other forms of integrity constraints that are not covered by the other three. o Table integrity refers to the facility of defining CHECK clauses in table definitions whereby the contents of a column is verified against a list of acceptable values. Alternatively, it can check the relationship between values in more than one column in a row. In addition, UNIQUE constraints (alternative keys) can be defined on a table. Like the primary key, a unique key is composed of one or more table columns and a key value uniquely identifies a row in the table (i.e. there are no duplicates). o View integrity means that if a view is created WITH CHECK OPTION this indicates that any data inserted into the view will be checked for conformity with the view-defining conditions. UFCE8K-15-M Data Management 2014/157

User integrity (2) o User integrity also covers user-defined business rules, regulations, policies and procedures. Stored routines (procedures) and triggers are usually used to enforce business integrity. o Stored routines (procedures and functions) can be used so that users, who require access to certain tables or views from an application, can gain access without having any explicit access rights to the actual objects. Instead the users can be granted the right to execute a stored routine (with or without GRANT option) that accesses those objects. The user creating a stored routine must, of course, have sufficient access rights to all objects involved in the routine. Using stored routines in this way allows the DBA to create an environment where the users are forced to only perform database operations through a series of well-debugged routines. UFCE8K-15-M Data Management 2014/158

Triggers o A trigger is a special type of stored procedure that is called automatically whenever a specific operation is performed on a table. Triggers are most useful when the features supported by constraints cannot meet the functional needs of the application. o Triggers can operate at a number of different levels – table, row, and column level triggers are implemented in their database by most of the commercial database vendors UFCE8K-15-M Data Management 2014/159

Views o The View mechanism is a very powerful concept. It is the result set from a predefined SELECT statement, a so-called derived table. A view may simply be a restriction of a single table, or may involve the joining of two or more tables (a so called 'join view'). A view can be used anywhere where a table may be used. Views are a powerful tool for restricting user access to defined parts of the database, and complement the system of access privileges in maintaining database security. By defining restriction views (i.e. views based on one table but including only specified rows and/or columns in the table), access privileges may be granted to subsets of table contents without affecting the physical database structure. Join views can be used to create the 'Universal Relations' which are used by many applications, from a normalized database. o Views with an implicit one-to-one relationship with an underlying table are directly updateable, provided the appropriate access privileges are held. An INSTEAD OF trigger provides full view updating. The trigger body contains SQL procedural code, allowing the developer to define the operations to be performed on the tables that under-pin the view. UFCE8K-15-M Data Management 2014/1510

Veracity o Veracity is usually defined as “Conformity to fact or truth; accuracy or precision.” o In a database context veracity refers to the goodness-of-fit between the factbase and the application domain (UoD). It is related to integrity (correctness) but not reducible to it. For instance, the model of the domain may be inadequate, important data items may not be captured, out of date or undetected duplicate data may exist, data may be entered incorrectly etc, etc. o Veracity becomes critical in domains where a match between the state of the world and the factbase is crucial, i.e. medical application, aircraft control, life support systems, missile guidence systems etc. etc. UFCE8K-15-M Data Management 2014/1511

Data integrity rules for table columns to enforce different types of data integrity. Null rule: A null rule is a rule defined on a single column that allows or disallows inserts or updates of rows containing a null (the absence of a value) in that column. Unique column values: A unique value rule defined on a column (or set of columns) allows the insert or update of a row only if it contains a unique value in that column (or set of columns). Primary key values: A primary key value rule defined on a key (a column or set of columns) specifies that each row in the table can be uniquely identified by the values in the key. Referential integrity rules: A referential integrity rule is a rule defined on a key (a column or set of columns) in one table that guarantees that the values in that key match the values in a key in a related table (the referenced value). Referential integrity also includes the rules that dictate what types of data manipulation are allowed on referenced values and how these actions affect dependent values. The rules associated with referential integrity are: o Restrict: Disallows the update or deletion of referenced data. o Set to null: When referenced data is updated or deleted, all associated dependent data is set to NULL. o Set to default: When referenced data is updated or deleted, all associated dependent data is set to a default value. o Cascade: When referenced data is updated, all associated dependent data is correspondingly updated. When a referenced row is deleted, all associated dependent rows are deleted. UFCE8K-15-M Data Management 2014/15 12 Data Integrity (tables & columns)