Referential Integrity

Slides:



Advertisements
Similar presentations
DB glossary (focus on typical SQL RDBMS, not XQuery or SPARQL)
Advertisements

Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
The Relational Model Class 2 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) (From ER to Relational)
Cs3431 Constraints Sections 6.1 – 6.5. cs3431 Example CREATE TABLE Student ( sNum int, sName varchar (20), prof int, CONSTRAINT pk PRIMARY KEY (snum),
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Maintaining Referential Integrity Pertemuan 2 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
SPRING 2004CENG 3521 The Relational Model Chapter 3.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
RELATIONSHIP  THE WAY TABLES ARE RELATED  A TABLE MUST PARTICIPATE IN AT LEAST ONE RELATIONSHIP  IN A BINARY RELATIONSHIP TWO ENTITIES PARTICIPATE 
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
SQL Constraints & Triggers May 10 th, Agenda Big picture –what are constraints & triggers? –where do they appear? –why are they important? In SQL.
The Relational Model These slides are based on the slides of your text book.
Relational Data Model, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 The Relational Model Chapter 3.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
SQL Server 7.0 Maintaining Referential Integrity.
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.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Chapter 9 Constraints. Chapter Objectives  Explain the purpose of constraints in a table  Distinguish among PRIMARY KEY, FOREIGN KEY, UNIQUE, CHECK,
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.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
Databases Introduction - concepts. Concepts of Relational Databases.
Murali Mani Constraints. Murali Mani Keys: Primary keys and unique CREATE TABLE Student ( sNum int, sName varchar (20), dept char (2), CONSTRAINT key.
1 Introduction to Database Systems, CS420 SQL Constraints.
Copyright © Curt Hill SQL The Data Manipulation Language.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Database Constraints ICT 011. Database Constraints Database constraints are restrictions on the contents of the database or on database operations Database.
Chapter 5 Database Design
Chapter 6: Integrity (and Security)
COP Introduction to Database Structures
Constraints and Triggers
Rules in active databases and integrity constraints
Translation of ER-diagram into Relational Schema
SQL: Constraints and Triggers
Module 5: Implementing Data Integrity by Using Constraints
Constraints & Triggers
CPSC-310 Database Systems
Instructor: Mohamed Eltabakh
Relational Database.
Relational Databases Relational Algebra (2)
The Relational Model Relational Data Model
Relational Databases Relational Algebra (1) Select, project, join.
Authorization.
Constraints of several types
Referential Integrity
Database solutions Chosen aspects of the relational model Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology.
Entities Things about which you need to store data. One entity for each different thing. At least two attributes At least two occurrences Not a property.
Guide to Modeling Keys to E-R diagrams.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
Instructor: Mohamed Eltabakh
SQL – Constraints & Triggers
CPSC-608 Database Systems
Relational Data Model - 2
Guide to Modeling Keys to E-R diagrams.
Constraints of several types
CS 405G: Introduction to Database Systems
Presentation transcript:

Referential Integrity Constraints & Triggers Referential Integrity

Integrity Constraints Referential Integrity Integrity Constraints Impose restrictions on allowable data, beyond those imposed by structure and types Referential integrity = Integrity of references = No “dangling pointers”

Referential integrity from R.A to S.B Simple Example Database Student Apply College sID sName GPA HS sID cName major dec cName state enr Referential integrity from R.A to S.B Each value in column A of table R must appear in column B of table S

Referential Integrity Referential integrity from R.A to S.B Each value in column A of table R must appear in column B of table S A is called the “foreign key” B is usually required to be the primary key for table S or at least unique Multi-attribute foreign keys are allowed Student Apply College sID sName GPA HS sID cName major dec cName state enr

Referential Integrity Referential Integrity Enforcement (R.A to S.B) Potentially violating modifications: Insert into R Delete from S Update R.A Update S.B Student Apply College sID sName GPA HS sID cName major dec cName state enr

Referential Integrity Referential Integrity Enforcement (R.A to S.B) Special actions: Delete from S Restrict (default), Set Null, Cascade Update S.B Student Apply College sID sName GPA HS sID cName major dec cName state enr