Relational data integrity

Slides:



Advertisements
Similar presentations
You have been given a mission and a code. Use the code to complete the mission and you will save the world from obliteration…
Advertisements

3/25/2017.
Chapter 1 The Study of Body Function Image PowerPoint
1 Copyright © 2010, Elsevier Inc. All rights Reserved Fig 2.1 Chapter 2.
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Relational Database and Data Modeling
Business Transaction Management Software for Application Coordination 1 Business Processes and Coordination.
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Jeopardy Q 1 Q 6 Q 11 Q 16 Q 21 Q 2 Q 7 Q 12 Q 17 Q 22 Q 3 Q 8 Q 13
Title Subtitle.
Determine Eligibility Chapter 4. Determine Eligibility 4-2 Objectives Search for Customer on database Enter application signed date and eligibility determination.
My Alphabet Book abcdefghijklm nopqrstuvwxyz.
0 - 0.
DIVIDING INTEGERS 1. IF THE SIGNS ARE THE SAME THE ANSWER IS POSITIVE 2. IF THE SIGNS ARE DIFFERENT THE ANSWER IS NEGATIVE.
Addition Facts
Year 6 mental test 5 second questions
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
Relational data objects 1 Lecture 6. Relational data objects 2 Answer to last lectures activity.
Introduction to Relational Database Systems 1 Lecture 4.
5NF and other normal forms
Introduction to SQL 1 Lecture 5. Introduction to SQL 2 Note in different implementations the syntax might slightly differ different features might be.
1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5.
Views-basics 1. 2 Introduction a view is a perspective of the database different users may need to see the database differently; this is achieved through.
Functional dependencies 1. 2 Outline motivation: update anomalies cause: not expressed constraints on data (FDs) functional dependencies (FDs) definitions.
Active database concepts
Relational operators 1 Lecture 7 Relational Operators.
Normal forms - 1NF, 2NF and 3NF
Conceptual / semantic modelling
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Term 2, 2004, Lecture 6, Views and SecurityMarian Ursu, Department of Computing, Goldsmiths College Views and Security 3.
Data Definition and Integrity Constraints
SQL: The Query Language Part 2
ABC Technology Project
CS 3630 Database Design and Implementation. Where Clause and Aggregate Functions -- List all rooms whose price is greater than the -- average room price.
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
R ELATIONAL M ODEL TO SQL Data Model. 22 C ONCEPTUAL D ESIGN : ER TO R ELATIONAL TO SQL How to represent Entity sets, Relationship sets, Attributes, Key.
Chapter 7 © 2013 Pearson Education, Inc. Publishing as Prentice Hall 1 Modern Database Management 11 th Edition Jeffrey A. Hoffer, V. Ramesh, Heikki Topi.
Squares and Square Root WALK. Solve each problem REVIEW:
the Entity-Relationship (ER) Model
Lecture plan Outline of DB design process Entity-relationship model
Chapter 5 Test Review Sections 5-1 through 5-4.
SIMOCODE-DP Software.
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
GG Consulting, LLC I-SUITE. Source: TEA SHARS Frequently asked questions 2.
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
25 seconds left…...
Stephen C. Hayne 1 Database System Components The Database and the DBMS.
Week 1.
We will resume in: 25 Minutes.
1 PART 1 ILLUSTRATION OF DOCUMENTS  Brief introduction to the documents contained in the envelope  Detailed clarification of the documents content.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
Chapter 5 Relational Model Concepts Dr. Bernard Chen Ph.D. University of Central Arkansas.
Chapter 14 & 15 Conceptual & Logical Database Design Methodology
An Investigation of Oracle and SQL Server with respect to Integrity, and SQL Language standards Presented by: Paul Tarwireyi Supervisor: John Ebden Date:
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.
Chapter 9 Logical Database Design : Mapping ER Model To Tables.
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.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Integrity Prof. Yin-Fu Huang CSIE, NYUST Chapter 9.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Presentation transcript:

Relational data integrity Lecture 8

Outline integrity constraints and data definition candidate keys foreign keys nulls domains conditional expressions normal forms

Constraints in real life systems constraints exist between data values it would be useful to communicate these constraints to the database system data is associated with a meaning stating some constraints on data  describing a part of the meaning 90% should be spent on integrity constraints definition

Examples of possible inaccuracies how would you express, in NL, integrity constraints that would avoid the above situations?

Types of integrity constraints application specific integrity constraints examples mechanisms domains conditional expressions normal forms generic (inherent to the relational model - resulting from definitions) entity integrity : primary key referential integrity : foreign key

Data definition integrity constraints definition in a relational language should include primary key definition candidate keys definition foreign key definition - including foreign key rules conditional expressions

Example - SQL data definition (in brief) CREATE TABLE <relation name> ( @<attribute definition><conditional expression>, <primary key definition>, @<candidate key definition>, @<foreign key definition>, @<conditional expressions> ) ; <primary key definition> ::= PRIMARY KEY ( <set of attributes> ) <candidate key definition > ::= CANDIDATE KEY ( <set of attributes> ) <foreign key definition> ::= FOREIGN KEY ( <set of attributes> ) REFERENCES <relation name> ON DELETE <option> ON UPDATE <option> CREATE ASSERTION <name> CHECK <conditional expression>

Candidate key - example

Candidate key candidate key entity integrity constraint uniqueness property irreducibility property entity integrity constraint simple/composite primary/alternate

Foreign key - example

Foreign key foreign key (FK)  corresponding candidate key (CK) in another relation  FK  CK such that FK = CK (reverse not required) target/referenced relation/tuple | referring relation/tuple referential integrity constraint foreign keys and PostgreSQL

Referential diagram

Foreign key rules - motivation

What happens if ... short saving accounts are not offered by the bank anymore? the “code” and name for small saving accounts is to be changed to ‘i-sav’ and ‘instant saving’ respectively? the interest for s-sav is to be decreased by 0.3%?

Foreign key rules the modifications are performed in the REFERRED relation rules ON DELETE RESTRICT ON DELETE CASCADE ON UPDATE RESTRICT ON UPDATE CASCADE split into four groups: think of one example for each situation; don’t use the study guide

Examples on delete restrict on delete cascade on update restrict students and books on delete cascade employees and children on update restrict students and modules on update cascade employees and departments

Nulls

Nulls representing missing/unavailable information primary key and nulls foreign key and nulls

Domains expressing integrity constraints on scalar values SQL constraints on permissible scalar values constraints on the applicability of scalar operators SQL does not support domains offers other mechanisms

Domains - example of integrity constraints

Conditional expressions will be studied with SQL pointer forward: the university’s database: “a student has two choose two options (1/2cu courses) in the final year; if the students chooses an extra optional course than the final year project will count as only 1/2cu”

FDs, MDs, and JDs particular constraints functional dependencies multiple dependencies join dependencies expressed by means of normal forms extensively studied in the following lectures

Normal forms - example

Integrity constraints - further considerations state and transition integrity constraints example when and how are the integrity constraints applied depends on the type ‘normal forms’ and ‘domains’ - always entity and referential - after each transaction conditional expressions default : after each transaction other possibilities? correct database = the logical AND of the set of integrity constraints is satisfied after each transaction

Summary the relational data model SQL implements the relational model data objects operators integrity constraints SQL implements the relational model the subject of the next lectures you know what a relational model is, but do not know yet how to design one