Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.

Slides:



Advertisements
Similar presentations
Exercise 2 Relational Calculus
Advertisements

Week 5 Relational Database Design by ER- -to-Relational Mapping.
Fundamentals of Database Systems Fourth Edition El Masri & Navathe
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
OUTLINE OF THE LECTURE PART I GOAL: Understand the Data Definition Statements in Fig 4.1 Step1: Columns of the Tables and Data types. Step2: Single column.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Database technology Lecture 2: Relational databases and SQL
Dept. of Computer & Information Sciences
Exploring Microsoft Access 2003 Chapter 4 Proficiency: Relational Databases, External Data, Charts, Pivot, and the Switchboard.
- relation schema, relations - database schema, database state
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Relational Data Model Sept. 2014Yangjun Chen ACS Outline: Relational Data Model Relational Data Model -relation schema, relations -database schema,
Chapter 5 Relational Model Concepts Dr. Bernard Chen Ph.D. University of Central Arkansas.
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 9 Relational Database Design by ER- and EER-to-Relational Mapping.
Functional Dependencies
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 8 SQL-99: Schema Definition, Constraints, and Queries and Views.
Review: Application of Database Systems
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
Retrieve the names of all employees in department 5 who work more than 10 hours per week on the ‘ProductX’ project. p10ssn ← (Π essn (σ hours > 10 (works-on.
Dept. of Computer & Information Sciences
 Employee (fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno)  Department (dname, dnumber, mgrssn, mgrstartdate) 
Slide Chapter 7 Relational Database Design by ER- to-Relational Mapping.
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
1 CS 430 Database Theory Winter 2005 Lecture 4: Relational Model.
Review Database Application Development Access Database Development Theory Practice.
ER-TO-RELATIONAL MODEL MAPPING CONTENT SOURCES: ELAMSARI AND NAVATHE, FUNDAMENTALS OF DATABASE MANAGEMENT SYSTEMS.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
Constraints and Views Chap. 3-5 continued (7 th ed. 5-7)
SQL- Updates, Assertions and Views. Data Definition, Constraints, and Schema Changes Used to CREATE, DROP, and ALTER the descriptions of the tables (relations)
Chapter 15 1 Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
The SQL Database Grammar
Chapter 4 Basic SQL.
CS580 Advanced Database Topics
Database Design The Relational Model Text Ch5
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
376a. Database Design Dept. of Computer Science Vassar College
Mapping ER Diagrams to Tables
Referential Integrity
Outline: Relational Data Model
Company Requirements.
CS4222 Principles of Database System
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EER-to-Relational Mapping
Session - 6 Sequence - 1 SQL: The Structured Query Language:
Review: Application of Database Systems
Structured Query Language (3)
Relational Database Design by ER- and EER-to- Relational Mapping
Session - 6 Sequence - 5 SQL Updating Database Contents
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
ISC321 Database Systems I Chapter 4: SQL: Data definition, Constraints, and Basic Queries and Updates Fall 2015 Dr. Abdullah Almutairi.
SQL Updating Database Contents Presented by: Dr. Samir Tartir
1. Explain the following concepts of the ER data model:
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
SQL: Set Operations & Nested Queries. Presented by: Dr. Samir Tartir
CS 405G: Introduction to Database Systems
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems (Chapter 5 Tutorial)

Chapter 5 Tutorial1 Exercise Suppose that each of the following update operations is applied directly to the following database state. Discuss all integrity constraints violated by each operation, if any, and the different ways of enforcing these constraints.

Chapter 5 Tutorial2 Exercise - a Insert into EMPLOYEE. No constraint violations.

Chapter 5 Tutorial3 Exercise - b Insert into PROJECT. Violates referential integrity because DNUM=2 and there is no tuple in the DEPARTMENT relation with DNUMBER=2. This constraint can be enforced by: Rejecting the insertion, or Changing the value of DNUM in the new PROJECT tuple to an existing DNUMBER value in the DEPARTMENT relation, or Inserting a new DEPARTMENT tuple with DNUMBER=2.

Chapter 5 Tutorial4 Exercise - c Insert into DEPARTMENT. Violates both the key constraint and referential integrity: Violates the key constraint because there already exists a DEPARTMENT tuple with DNUMBER=4. This constraint can be enforced by: Rejecting the insertion, or Changing the value of DNUMBER in the new DEPARTMENT tuple to a value that does not violate the key constraint. Violates referential integrity because MGRSSN=' ' and there is no tuple in the EMPLOYEE relation with SSN=' '. This constraint can be enforced by: Rejecting the insertion, or Changing the value of MGRSSN to an existing SSN value in EMPLOYEE, or Inserting a new EMPLOYEE tuple with SSN=' '.

Chapter 5 Tutorial5 Exercise - d Insert into WORKS_ON. Violates both the entity integrity and referential integrity: Violates entity integrity because PNO, which is part of the primary key of WORKS_ON, is null. This constraint can be enforced by: Rejecting the insertion, or Changing the value of PNO in the new WORKS_ON tuple to a value of PNUMBER that exists in the PROJECT relation. Violates referential integrity because ESSN=' ' and there is no tuple in the EMPLOYEE relation with SSN=' '. This constraint can be enforced by: Rejecting the insertion, or Changing the value of ESSN to an existing SSN value in EMPLOYEE, or Inserting a new EMPLOYEE tuple with SSN=' '.

Chapter 5 Tutorial6 Exercise - e Insert into DEPENDENT. No constraint violations.

Chapter 5 Tutorial7 Exercise - f Delete the WORKS_ON tuples with ESSN= ' '. No constraint violations.

Chapter 5 Tutorial8 Exercise - g Delete the EMPLOYEE tuple with SSN= ' '. Violates referential integrity because several tuples exist in the EMPLOYEE, DEPARTMENT, WORKS_ON, and DEPENDENT relations that reference the tuple being deleted from EMPLOYEE. This constraint can be enforced by: Rejecting the deletion, or Deleting all tuples in the EMPLOYEE, DEPARTMENT, WORKS_ON, and DEPENDENT relations whose values for SUPERSSN, MGRSSN, ESSN, and ESSN, respectively, is equal to ' '. Modifying the referencing attribute values causing violation by either setting them to null or changing them to reference another valid tuple.

Chapter 5 Tutorial9 Exercise - h Delete the PROJECT tuple with PNAME= 'ProductX'. Violates referential integrity because two tuples exist in the WORKS_ON relation that reference the tuple being deleted from PROJECT. This constraint can be enforced by: Rejecting the deletion, or Deleting the tuples in the WORKS_ON relation whose value for PNO=1. Modifying the referencing attribute values causing violation by either setting it to null or changing it to reference another valid tuple.

Chapter 5 Tutorial Exercise - i Modify the MGRSSN and MGRSTARTDATE of the DEPARTMENT tuple with DNUMBER=5 to ' ' and ’ ', respectively. No constraint violations. 10

Chapter 5 Tutorial Exercise - j Modify the SUPERSSN attribute of the EMPLOYEE tuple with SSN= ' ' to ' '. Violates referential integrity because the new value of SUPERSSN=' ' and there is no tuple in the EMPLOYEE relation with SSN=' '. This constraint can be enforced by: Rejecting the modification, or Inserting a new EMPLOYEE tuple with SSN=' '. 11

Chapter 5 Tutorial Exercise - k Modify the HOURS attribute of the WORKS_ON tuple with ESSN= ' ' and PNO= 10 to '5.0'. No constraint violations. 12