DBMS Spring 2014 Database Integrity Sources: Security in Computing, Pfleeger and Pfleeger, Prentice Hall, 2003 Lecture Slides, CSE6243, MSU, Rayford B.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
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.
Overview Begin 6:00 Quiz15 mins6:15 Review Table Terms25 mins6:40 Short Break10 mins6:50 SQL: Creating Tables60 mins7:50 Break10 mins8:00 Lab – Creating.
THE RELATIONAL DATABASE MODEL & THE DATABASE DEVELOPMENT PROCESS Fact of the Week: According to a Gartner study in ‘06, Microsoft SQL server had the highest.
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.
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.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
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 
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
5 Chapter 5 Structured Query Language (SQL1) Revision.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
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.
Chapter 7 Constraints and Triggers Spring 2011 Instructor: Hassan Khosravi.
Computer Science & Engineering 2111 Introduction to Database Management Systems Relationships and Database Creation 1 CSE 2111 Introduction to Database.
Database Integrity and Security HAP 709 – Healthcare Databases George Mason University Janusz Wojtusiak, PhD Fall, 2010.
The Relational Model These slides are based on the slides of your text book.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Chapters 17 & 18 Physical Database Design Methodology.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Learningcomputer.com SQL Server 2008 – Entity Relationships in a Database.
Database Technical Session By: Prof. Adarsh Patel.
Lecture 2 An Overview of Relational Database IST 318 – DB Admin.
Relational Database Management Systems. A set of programs to manage one or more databases Provides means for: Accessing the data Inserting, updating and.
Lecture 7 Integrity & Veracity UFCE8K-15-M: Data Management.
SQL Server 7.0 Maintaining Referential Integrity.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
14-1 Goals of Database Design A database should provide for efficient storage, update, and retrieval of data. A database should be reliable—the stored.
Access Project 3 Notes. Introduction Maintaining the Database  Modifying the data to keep it up-to-date Restructure the Database  To change the database.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Maintaining a Database Access Project 3. 2 What is Database Maintenance ?  Maintaining a database means modifying the data to keep it up-to-date. This.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
Constraints cis 407 Types of Constraints & Naming Key Constraints Unique Constraints Check Constraints Default Constraints Misc Rules and Defaults Triggers.
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.
IS 380 Introduction to SQL This lectures covers material from: database textbook chapter 3 Oracle chapter: 3,14,17.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
Constraints Lesson 8. Skills Matrix Constraints Domain Integrity: A domain refers to a column in a table. Domain integrity includes data types, rules,
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Chapter 9 Designing Databases 9.1.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Database Design and Relation Data Model Muhammad Nasir
Constraints Advanced Database Systems Dr. AlaaEddin Almabhouh.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
CDT/1 Creating data tables and Referential Integrity Objective –To learn about the data constraints supported by SQL2 –To be able to relate tables together.
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.
Getting started with Accurately Storing Data
Fundamentals of DBMS Notes-1.
Fundamental of Database Systems
Managing Tables, Data Integrity, Constraints by Adrienne Watt
Chapter 4 Relational Databases
The Relational Model Relational Data Model
CS4222 Principles of Database System
Presentation transcript:

DBMS Spring 2014 Database Integrity Sources: Security in Computing, Pfleeger and Pfleeger, Prentice Hall, 2003 Lecture Slides, CSE6243, MSU, Rayford B. Vaughn,

First, a followup from Tues  R(A, B, C, D, E) with FDs  AB -> C  C -> D  A -> E  What violations of 3nf are found?  How would you decompose this?

Followup from Tues  R(A, B, C, D) with FDs  AB -> C  C -> D  D -> A  What are the possible keys to this relation?  What violations of 3nf are found?  How would you decompose this? Book, page 92,

Traditional Security Concerns  Confidentiality  Integrity  Availability  Accountability

Traditional Security Concerns  Confidentiality  Integrity  Availability  Accountability

Integrity  DB integrity types  Physical Database Integrity –Data in Database is safe –Data can be reconstructed  Logical Database Integrity –Structure of Database is preserved –No inconsistency  Element Integrity –Correctness/accuracy of data is maintained

Integrity Goals  Database integrity protection must achieve:  Internal consistency: database entries must obey prescribed rules;  External consistency: database entries are correct - combine checking data entered with auditing to check consistent state.

Integrity Rules  Most rules are application specific, but two rules inherent to relational database model:  Entity integrity rule: –no component of primary key can accept nulls.  Referential integrity rule: –database must not contain unmatched foreign key values.

Application Specific Integrity Checks  field checks: check that entries are valid elements of domain  consistency checks: check that entries in different relations do not conflict  scope checks: checks that query results are not computed for too small a sample (for specialized DB)  change logs: check that all changes are recorded with original and modified entry values

Integrity in postresql  Primary keys  Must be unique  Must be non-null  Foreign keys - fk.html fk.html  Field can be null or not-null  If null, we can have a row without the foreign key attribute present, but if the attribute is filled in, it must match a row in the referenced table.

Thinking about foreign keys  If a Foreign Key references another table and the other table row is deleted, what should happen to the referencing row.  For example, dlangs references languages. What if we decide that a language really isn’t a language and so we remove it. ie. PigLatin. What should happen?  No Action / Restrict  On Delete Cascade  On Update Cascade (what happens if we change)

Other constraints  “Table constraints”  Field contraints  Can be built into the CREATE TABLE OR  Can be added using the ALTER TABLE

Other constraints  Null is assumed for a non-key attribute added to a table.  NOT NULL requires a value to be filled in.  SSN int NOT NULL,  UNIQUE requires that no other row can have the same value.  SSN int UNIQUE NOT NULL,

Field vs Table level from Postgresql reference CREATE TABLE products ( product_no integer UNIQUE, name text, price numeric ); CREATE TABLE products ( product_no integer, name text, price numeric, UNIQUE (product_no) ); CREATE TABLE example ( a integer, b integer, c integer, UNIQUE (a, c) );

Check Constraints  Allow us to more finely define field values beyond the overall domain (data type)  For example, can a driver have a vehicle with -5 seats? Can a driver have a vehicle with 192 seats? What is the restriction to insure that we have a reasonable number. CREATE TABLE products ( product_no integer, name text, price numeric CHECK (price > 0) );

Named constraints CREATE TABLE products ( product_no integer, name text, price numeric CONSTRAINT positive_price CHECK (price > 0) ); Table level CREATE TABLE products ( product_no integer, name text, price numeric CHECK (price > 0), discounted_price numeric CHECK (discounted_price > 0), CHECK (price > discounted_price) );

Adding constraints  ALTER TABLE  Can add table level constraints.

Default values CREATE TABLE distributors ( name varchar(40) DEFAULT 'Luso Films', did integer DEFAULT nextval('distributors_serial'), modtime timestamp DEFAULT current_timestamp );