Constraints AND Examples

Slides:



Advertisements
Similar presentations
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1.
Database Systems Chapter 5 ITM 354. Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations.
Chapter 5 The Relational Data Model and Relational Database Constraints.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Database Systems Relational Model Concepts Toqir Ahmad Rana Database Management Systems 1 Lecture 17.
CONSTRAINTS AND UPDATES CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1.
Database Architecture The Relational Database Model.
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)
1 Relational model concepts Key constraints Referential integrity constraint Steen Jensen, autumn 2013.
Chapter 4 Rational data model. Chapter 5 Rational data model Chapter 4 Rational data model.
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
INTEGRITY. Integrity constraint Integrity constraints are specified on a database schema and are expected to hold on every valid database state of the.
Topic 5 The Relational Data Model and Relational Database Constraints Faculty of Information Science and Technology Mahanakorn University of Technology.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
The Relational Data Model and Relational Database Constraints
10/9/20151 The Relational Data Model TCU Database Systems Last update: September 2004 Reference: Elmasri 4 th edition, chapter 5.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
1 CSE 480: Database Systems Lecture 5: Relational Data Model.
METU Department of Computer Eng Ceng 302 Introduction to DBMS The Relational Data Model and Relational Database Constraints by Pinar Senkul resources:
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 3 The Basic 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.
Lecture 03 Constraints. Example Schema CONSTRAINTS.
The Relational Data Model and Relational Database Constraints.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
4/28/2017 Chapter 5 The Relational Data Model and Relational Database Constraints.
Chapter 71 The Relational Data Model, Relational Constraints & The Relational Algebra.
Chapter 3 The Relational Data Model and Relational Database Constraints Copyright © 2004 Pearson Education, Inc.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and Relational Database Constraints تنبيه.
ER Diagrams and Relational Model CS 174a (Winter 2015)
Copyright © 2004 Pearson Education, Inc.
Relational Model Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 3.
4/20/2018.
Database Constraints Ashima Wadhwa.
The Relational Data Model and Relational Database Constraints
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
Lecture # 13 (After 1st Exam)
Constraints AND Examples
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
The Relational Data Model
Relational Integrity Constraints
The Relational Data Model and Relational Database Constraints
Chapter 3 The Relational Model.
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
Entity-Relationship Modeling "Extended"
12/7/2018.
The Relational Data Model and Relational Database Constraints
2/28/2019 Chapter 5 The Relational Data Model and Relational Database Constraints.
4/8/2019.
Mapping an ERD to a Relational Database
INSTRUCTOR: MRS T.G. ZHOU
Database Dr. Roueida Mohammed.
CS 505: Intermediate Topics to Database Systems
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
5/12/2019.
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Copyright © 2004 Pearson Education, Inc.
Entity-Relationship Modeling "Extended"
CS 405G: Introduction to Database Systems
Entity-Relationship Modeling "Extended"
The Relational Data Model and Relational Database Constraints
Chapter 3 The Relational Model
The Relational Data Model and Relational Database Constraints
Presentation transcript:

Constraints AND Examples Relational model Constraints AND Examples

OBJECTIVES Relational Integrity Constraint mapping exercises to convert ER model – chen and UML notation – to relational model.

Relational Integrity Constraint Constraints are conditions that must hold on all valid relation states . There are three main types of constraints in the relational models : Key constraints Entity integrity constraint Referential integrity constraint

1. Key constraint Relational schema may have more than one key , each key is called candidate key. If a relation has several candidate keys , one is chosen to be the primary key - the primary key attribute is underlined Ex : CAR( State,Reg#,SerialNO, Make , Model , Year ) The primary key value is used to uniquely identify each tuple in a relation

2. Entity integrity the primary key attributes PK of each relation schema R in S cannot have null values in any tuple. - if PK has several attributes , null is not allowed in any of these attributes . This constraint involve a single relation.

What is the PK?

3. Referential integrity Used to specify a relationship among tuples in two relations. Tuples in the referencing relation R1 have attributes called foreign key attributes FK that reference the PK attributes of the referenced relation R2 FK satisfies the following two rules: The attributes in FK in R1 have the same domain as the Primary key attributes of R2 A value of FK in tuple t1 ether occurs as a value of PK for some tuple t2 or is null . A foreign key ( referential integrity ) constraints is displayed in relational database schema as directed arc ( arrow ) from the FK attributes to the referenced relation ( can also point to the PK for clarity )

4. Other types of constraint Example : “ the max no. of hours per employee for all projects he or she works on is 56 hrs per week Based on application semantics and cannot be expressed by the model A constraint specification language may have to be used to express these

Present the relational schemas mapped from ER model shown in each exercise. Mapping exercises

Exercise 1 ( UML notation ) 2 1 3

Exercise 1 ANSWER STUDENT(SSN, ST_ name , telephone ) STAFF(SNO , S_ name , S_ telephone ) DVD(DItemNO , Title , Author , Current_qty , SNO , SSN , date_barrow , no_renwal , fine ) BOOK(BItemNO , ISBN , Title , Author , Current_qty , SNO , SSN , date_barrow , no_renwal , fine ) REQUESTED_BOOK (SSN, BitemNO date_ requested )

Exercise 2 ( chen notation )

Exercise 2 ANSWER displaying referential integrity constraints