The Relational Data Model and Relational Database Constraints

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1.
Advertisements

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
Database Systems Chapter 5 ITM 354. Chapter Outline Relational Model Concepts Relational Model Constraints and Relational Database Schemas Update Operations.
Relational Database Management System A type of database in which records are stored in relational form is called relational database management system.
Database Systems Relational Model Concepts Toqir Ahmad Rana Database Management Systems 1 Lecture 17.
Database Architecture The Relational Database Model.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Relational Data Model and SQL.
Topic 5 The Relational Data Model and Relational Database Constraints Faculty of Information Science and Technology Mahanakorn University of Technology.
Instructor: Churee Techawut Basic Concepts of Relational Database Chapter 5 CS (204)321 Database System I.
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
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1 Week4 Relational Model and Relational Database Constraints Relational Model Concepts.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 5 The Relational Data Model and Relational Database Constraints.
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.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
Relational Model E.F. Codd at IBM 1970 Chapter 3 (ed. 7 – Chap. 5)
Relational Data Model DeSiaMore Powered by DeSiaMore.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 5 The Relational Data Model and Relational Database Constraints Slide 1- 1.
The Relational Data Model and Relational Database Constraints
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5- 1.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 5- 1.
The Relational Data Model and Relational Database Constraints.
Chapter 3 The Relational Data Model and Relational Database Constraints Copyright © 2004 Pearson Education, Inc.
Copyright © 2004 Pearson Education, Inc.
Relational Model Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 3.
4/20/2018.
Database Constraints Ashima Wadhwa.
Chapter 2: Relational Model
Lecture # 13 (After 1st Exam)
Constraints AND Examples
376a. Database Design Dept. of Computer Science Vassar College
The Relational Data Model
Relational Integrity Constraints
The Relational Data Model and Relational Database Constraints
Data Base System Lecture 6: Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
CS4222 Principles of Database System
12/7/2018.
The Relational Model Transparencies
Chapter 4 The Relational Model Pearson Education © 2009.
The Relational Data Model and Relational Database Constraints
Chapter 4 The Relational Model Pearson Education © 2009.
ER to Relational Mapping
Design tools and techniques for a relational database system
4/8/2019.
Chapter 4 The Relational Model Pearson Education © 2009.
INSTRUCTOR: MRS T.G. ZHOU
The Relational Data Model and Relational Database Constraints
The Relational Data Model and Relational Database Constraints
5/12/2019.
Constraints AND Examples
Copyright © 2004 Pearson Education, Inc.
The Relational Data Model and Relational Database Constraints
Chapter 3 The Relational Model
RELATIONAL DATA MODEL - 1
The Relational Data Model and Relational Database Constraints
Presentation transcript:

The Relational Data Model and Relational Database Constraints Chapter 3 The Relational Data Model and Relational Database Constraints

Component Values Notation We refer to of a tuple t by: t[Ai] or t.Ai This is the value vi of attribute Ai for tuple t Similarly, t[Au, Av, ..., Aw] refers to the subtuple of t containing the values of attributes Au, Av, ..., Aw, respectively in t

Component Values Notation t1.Name OR t1[Name] = “Dick Davidson” t3[Gpa] = 3.93 t4[Ssn, Name] ={305-61-2435, “Benjamin Bayer”}

Relational Integrity Constraints Constraints are conditions that must hold on all valid relation states. There are three main types of constraints in the relational model: Key constraints Entity integrity constraints Referential integrity constraints Another implicit constraint is the domain constraint Every value in a tuple must be from the domain of its attribute (or it could be null, if allowed for that attribute)

What is a key We want to be able to retrieve every single piece of data that we putted into the database So, it is important to specify one attribute or more than one attributes which make it possible to uniquely identify every row in a table This attribute (s) is called a key This uniqueness ensure that we are retrieving exactly the row we want. The key can not be NULL Selecting a good key, is considered a challenge in the database design

Super key (SK) Candidate key (CK) Primary key (PK) Foreign Key (FK) Relational keys Super key (SK) Candidate key (CK) Primary key (PK) Foreign Key (FK)

Super Key Is a set of attributes SK of R with the following condition: No two tuples in any valid relation state r(R) will have the same value for SK That is, for any distinct tuples t1 and t2 in r(R), t1[SK]  t2[SK] This condition must hold in any valid state r(R) Every relation has one default super key which is the set of all its attributes

Super Key SK1 = {Name, Ssn, Home_phone, address, office_phone, Age, Gpa} SK2 = {Name, Ssn} SK3 = {Address, Ssn}

Candidate Key A superkey may contains additional attributes that are not necessarily for unique identification We are interested in identifying superkeys that contain only the attributes necessary for unique identification So, a candidate key is a superkey such that no proper subset is a superkey within the relation Example SK2 = {Name, Ssn}  Proper Subset = {Ssn} SK3 = {Address, Ssn}Proper Subset = {Ssn} Then SK2 and SK3 is not candidate key

Candidate Key A candidate key, k, for a relation R has two properties Uniqueness In each tuple of R, the values of k uniquely identify that tuple Irreducibility No proper subset of k has the uniqueness property For example suppose we choose CK1 = {A1, A2, A3} as a candidate key and we discovered that CK2  CK1 = {A1, A2} achieve uniqueness then CK1 is not a candidate key Identifying the candidate key requires that we know the meaning of attributes in the real world so that we can decide whether duplicates are possible

Candidate Key Given the value of city , we can determine several branch office, So this attribute cannot be candidate key But given a branchNo we can determine at most one tuple Also, given a postcode we can determine at most one tuple Then branchNo and postcode are candidate keys

Primary Key A primary key is a candidate key that is selected to identify tuples in the relation If a relation has several candidate keys, the minimal one is chosen arbitrarily to be the primary key. In ER the primary key attributes are underlined.

Primary Key Example: Consider the CAR relation schema: CAR(State, Reg#, SerialNo, Make, Model, Year) CAR has two keys: Key1 = {State, Reg#} Key2 = {SerialNo} Both are also candidate keys of CAR So a serialNo is selected as a primary key because it is minimal In general: Any key is a superkey (but not vice versa) for example {SerialNo, Make} is a superkey but not a key. Any set of attributes that includes a key is a superkey