Relational Model Constraints and Integrity

relational model n.w
1 / 15
Embed
Share

Explore the importance of relational model constraints, focusing on key constraints, entity integrity, referential integrity, and other types of constraints. Learn how these conditions ensure data accuracy and consistency in database systems.

  • Database
  • Constraints
  • Integrity
  • Relational Model
  • ER Model

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Relational model Constraints AND Examples

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

  3. 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 : 1. Key constraints 2. Entity integrity constraint 3. Referential integrity constraint

  4. 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

  5. 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.

  6. What is the PK?

  7. 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: 1. The attributes in FK in R1 have the same domain as the Primary key attributes of R2 2. 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 )

  8. 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

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

  10. Exercise 1 ( UML notation ) 2 1 3

  11. 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 )

  12. Exercise 2 ( chen notation )

  13. Exercise 2 ANSWER displaying referential integrity constraints

More Related Content