SlideShare a Scribd company logo
Database : Relational Data Model
Relational DBMS
 Edgar F. Codd at IBM invented the relational database
in 1970. Called Father of RDBMS.
 The main elements of RDBMS are based on Codd’s 13
rules for a relational system.
 Tables (or relations) are related to each other by
sharing common characteristics
RDBMS
A database management system that stores data in the
form of related tables is called Relational Database
Management System.
The goal of RDBMS is to make data easy to store &
retrieve
Relational databases help solve problems as they are
designed to create tables & then combine the
information in interesting ways to create valid
information.
RDBMS
Typical RDBMS include
Microsoft Access
Microsoft SQL Server
Sybase (The forerunner of Microsoft SQL Server)
IBM DB2
Oracle
Ingres
MySQL
Postgresql etc
RDBMS
Relation Instance:- snapshot of DB
Example:
Schema :- Logical design of DB.
Example:
Account-schema = (account-number, branch-name,
balance)
Branch-schema = (branch-name, branch-city, assets)
Customer-schema = (customer-name, customer-street,
customer-city)
RDBMS
Schema Diagram
Translation ER Model to Relational
Model
Translation ER Model to Relational
Model
Database : Relational Data Model
Integrity Constraint
An integrity constraint (IC) is a condition specified on
a database schema and restricts the data that can be
stored in an instance of the database.
If a database instance satisfies all the integrity
constraints specifies on the database schema, it is
a legal instance.
A DBMS permits only legal instances to be stored in the
database.
Integrity Constraint
Domain Constraints:
A relation schema specifies the domain of each field in
the relation instance. These domain constraints in the
schema specify the condition that each instance of the
relation has to satisfy.
Example:
create domain Dollars numeric(12,2)
create domain Pounds numeric(12,2)
define the domains Dollars and Pounds to be decimal
numbers with a total of 12 digits, two of which are
placed after the decimal point.
Integrity Constraint
Referential Integrity:
ensure that a value that appears in one relation for a
given set of attributes also appears for a certain set of
attributes in another relation.
Example: SQL
branch-name char(15) references branch
Key Constraints
Super Key:
An attribute, or set of attributes, that uniquely identifies a
tuple within a relation.
However, a super key may contain additional attributes that
are not necessary for a unique identification.
Candidate Key:
A super key such that no proper subset is a super key within
the relation. There are two parts of the candidate key
definition:
i. Two distinct tuples in a legal instance cannot have identical
values in all the fields of a key.
ii. No subset of the set of fields in a candidate key is a unique
identifier for a tuple.
Key Constraints
Primary Key:
The candidate key that is selected to identify tuples
uniquely within the relation.
The candidate keys that are not selected as the primary
key are called as alternate keys.
Features of the primary key:
1. Primary key will not allow duplicate values.
2.Primary key will not allow null values.
3. Only one primary key is allowed per table.
Key Constraints
Foreign Key:
Foreign keys represent the relationships between tables.
A foreign key is a column (or a group of columns)
whose values are derived from the primary key of some
other table.
Features of foreign key:
1. Records cannot be inserted into a detail table if
corresponding records in the master table do not exist.
2. Records of the master table cannot be deleted or
updated if corresponding records in the detail table
actually exist.
Integrity Constraint
Assertions:
An assertion is a predicate expressing a condition that we
wish the database always to satisfy.
create assertion <assertion-name> check <predicate>
Example :
create assertion sum-constraint check
(not exists (select * from branch
where (select sum(amount) from loan
where loan.branch-name = branch.branch-name)
>= (select sum(balance) from account
where account.branch-name = branch.branch-name)))
Integrity Constraint
Triggers:
A trigger is a statement that the system executes
automatically as a side effect of a modification to the
database.
To design a trigger mechanism, we must meet two
requirements:
1. Specify when a trigger is to be executed. This is broken
up into an event that causes the trigger to be checked
and a condition that must be satisfied for trigger
execution to proceed.
2. Specify the actions to be taken when the trigger
executes.
Integrity Constraint
Triggers:
Example: define a trigger that replaces the blank value
in a phone number field of an inserted tuple by the
null value.
create trigger setnull-trigger before update on r
referencing new row as nrow for each row when
nrow.phone-number = ’ ’ set nrow.phone-number = null
Database : Relational Data Model
Relational Algebra
Fundamental Operations
Unary Operation
 Select
 Project
 Rename
Binary Operations
 Union
 Set different
 Cartesian product
Relational Algebra
Select (σ) :
(a) Example: select those tuples of the loan relation
where the branch is “Perryridge,”
σbranch-name =“Perryridge” (loan)
(b) Example: find those tuples pertaining to loans of
more than $1200 made by the Perryridge branch
σbranch-name =“Perryridge”∧ amount>1200 (loan)
Relational Algebra
Project(Π)
Example: list all loan numbers and the amount of the
loan as
Πloan-number, amount(loan)
Union(∪)
Example: find the names of all bank customers who hav
either an account or a loan or both.
Πcustomer-name (borrower ) ∪ Πcustomer-name (depositor)
borrower : Customers with a loan in the bank
Relational Algebra
Set Difference (-)
Example: find all customers of the bank who have an account
but not a loan
Πcustomer-name (depositor) − Πcustomer-name (borrower )
Cartesian-Product (X)
Example: find the names of all customers who have a loan at
the Perryridge branch.
3. Πcustomer-name (σborrower .loan-number =loan.loan-number
(σbranch-name =“Perryridge” (borrower × loan)))
Relational Algebra
Rename (ρ)
relational-algebra expression E,
ρ x (E)
returns the result of expression E under the name x.
Additional operations are:
• Set intersection
• Assignment
• Natural join
Relational Calculus
Tuple Relational Calculus
A query in the tuple relational calculus is expressed as
{t | P(t)}
the set of all tuples t such that predicate P is true for t.
Domain Relational Calculus
An expression in the domain relational calculus is of the form
{< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)}
where x1, x2, . . . , xn represent domain variables. P represents a
formula composed of atoms, as was the case in the tuple
relational calculus.

More Related Content

PPTX
Functional dependencies and normalization
PPT
6. Integrity and Security in DBMS
PDF
chapter 2-DATABASE SYSTEM CONCEPTS AND architecture [Autosaved].pdf
PDF
Relational vs Non Relational Databases
PPTX
Module 2 2022 scheme BCS403 database management system
PPTX
Relational Data Model Introduction
PDF
Dbms 10: Conversion of ER model to Relational Model
PPTX
Chapter-2 Database System Concepts and Architecture
Functional dependencies and normalization
6. Integrity and Security in DBMS
chapter 2-DATABASE SYSTEM CONCEPTS AND architecture [Autosaved].pdf
Relational vs Non Relational Databases
Module 2 2022 scheme BCS403 database management system
Relational Data Model Introduction
Dbms 10: Conversion of ER model to Relational Model
Chapter-2 Database System Concepts and Architecture

What's hot (20)

PPTX
Types of Database Models
PPTX
Database Programming
PPTX
ER model to Relational model mapping
PPTX
Relational model
PPTX
Database abstraction
PDF
Chapter 2 Relational Data Model-part1
PPTX
PPT
Constraints In Sql
PPTX
3 Level Architecture
PPT
Aggregate functions
PPTX
ER MODEL
PDF
Primary Key & Foreign Key part10
PPTX
Integrity Constraints
PPTX
Introduction to SQL
PDF
Data Models
PPT
SQLITE Android
PPTX
PPT
2. Entity Relationship Model in DBMS
PPTX
introdution to SQL and SQL functions
Types of Database Models
Database Programming
ER model to Relational model mapping
Relational model
Database abstraction
Chapter 2 Relational Data Model-part1
Constraints In Sql
3 Level Architecture
Aggregate functions
ER MODEL
Primary Key & Foreign Key part10
Integrity Constraints
Introduction to SQL
Data Models
SQLITE Android
2. Entity Relationship Model in DBMS
introdution to SQL and SQL functions
Ad

Viewers also liked (14)

PPTX
Cardinality and participation constraints
PPT
Rdbms
PPTX
Relational database management system (rdbms) i
PPTX
Urinary system embryology
PPTX
Introduction to Software - Coder Forge - John Mulhall
PPTX
Fundamentals of database system - Relational data model and relational datab...
PPTX
The relational data model part[1]
PDF
Introduction to RDBMS
PDF
4 the relational data model and relational database constraints
PPT
3. Relational Models in DBMS
PPTX
Denormalization
PPTX
RDBMS.ppt
PPT
14. Query Optimization in DBMS
PPTX
Rdbms
Cardinality and participation constraints
Rdbms
Relational database management system (rdbms) i
Urinary system embryology
Introduction to Software - Coder Forge - John Mulhall
Fundamentals of database system - Relational data model and relational datab...
The relational data model part[1]
Introduction to RDBMS
4 the relational data model and relational database constraints
3. Relational Models in DBMS
Denormalization
RDBMS.ppt
14. Query Optimization in DBMS
Rdbms
Ad

Similar to Database : Relational Data Model (20)

PPT
2e data models
PPT
NMEC RD_UNIT 1.ppt
PPTX
DBMS Module-2 notes for engineering BE vtu
PPT
introduction to database systems ch2.ppt
PPT
chxnxx introduction to relational model.ppt
PPTX
Relational Model and Relational Algebra.pptx
PPTX
Relational model
PDF
4_RelationalDataModelAndRelationalMapping.pdf
PPT
Lecture 07 relational database management system
DOCX
COMPUTERS Database
PPT
6 integrity and security
PPT
Data model
PDF
3 relational model
PPT
Unit04 dbms
PPTX
Relation Model Database Pertemuan k.pptx
PPTX
relational model.pptx
PDF
3_Relational_Model.pdf
PPT
Integrity & security
PPT
Relational database concept
2e data models
NMEC RD_UNIT 1.ppt
DBMS Module-2 notes for engineering BE vtu
introduction to database systems ch2.ppt
chxnxx introduction to relational model.ppt
Relational Model and Relational Algebra.pptx
Relational model
4_RelationalDataModelAndRelationalMapping.pdf
Lecture 07 relational database management system
COMPUTERS Database
6 integrity and security
Data model
3 relational model
Unit04 dbms
Relation Model Database Pertemuan k.pptx
relational model.pptx
3_Relational_Model.pdf
Integrity & security
Relational database concept

Recently uploaded (20)

PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Construction Project Organization Group 2.pptx
PDF
composite construction of structures.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPT
Mechanical Engineering MATERIALS Selection
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
Current and future trends in Computer Vision.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
additive manufacturing of ss316l using mig welding
PDF
Digital Logic Computer Design lecture notes
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPT
introduction to datamining and warehousing
CYBER-CRIMES AND SECURITY A guide to understanding
Construction Project Organization Group 2.pptx
composite construction of structures.pdf
Foundation to blockchain - A guide to Blockchain Tech
Model Code of Practice - Construction Work - 21102022 .pdf
Mechanical Engineering MATERIALS Selection
Embodied AI: Ushering in the Next Era of Intelligent Systems
Automation-in-Manufacturing-Chapter-Introduction.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Geodesy 1.pptx...............................................
Current and future trends in Computer Vision.pptx
Lecture Notes Electrical Wiring System Components
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
additive manufacturing of ss316l using mig welding
Digital Logic Computer Design lecture notes
R24 SURVEYING LAB MANUAL for civil enggi
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Internet of Things (IOT) - A guide to understanding
introduction to datamining and warehousing

Database : Relational Data Model

  • 2. Relational DBMS  Edgar F. Codd at IBM invented the relational database in 1970. Called Father of RDBMS.  The main elements of RDBMS are based on Codd’s 13 rules for a relational system.  Tables (or relations) are related to each other by sharing common characteristics
  • 3. RDBMS A database management system that stores data in the form of related tables is called Relational Database Management System. The goal of RDBMS is to make data easy to store & retrieve Relational databases help solve problems as they are designed to create tables & then combine the information in interesting ways to create valid information.
  • 4. RDBMS Typical RDBMS include Microsoft Access Microsoft SQL Server Sybase (The forerunner of Microsoft SQL Server) IBM DB2 Oracle Ingres MySQL Postgresql etc
  • 5. RDBMS Relation Instance:- snapshot of DB Example: Schema :- Logical design of DB. Example: Account-schema = (account-number, branch-name, balance) Branch-schema = (branch-name, branch-city, assets) Customer-schema = (customer-name, customer-street, customer-city)
  • 7. Translation ER Model to Relational Model
  • 8. Translation ER Model to Relational Model
  • 10. Integrity Constraint An integrity constraint (IC) is a condition specified on a database schema and restricts the data that can be stored in an instance of the database. If a database instance satisfies all the integrity constraints specifies on the database schema, it is a legal instance. A DBMS permits only legal instances to be stored in the database.
  • 11. Integrity Constraint Domain Constraints: A relation schema specifies the domain of each field in the relation instance. These domain constraints in the schema specify the condition that each instance of the relation has to satisfy. Example: create domain Dollars numeric(12,2) create domain Pounds numeric(12,2) define the domains Dollars and Pounds to be decimal numbers with a total of 12 digits, two of which are placed after the decimal point.
  • 12. Integrity Constraint Referential Integrity: ensure that a value that appears in one relation for a given set of attributes also appears for a certain set of attributes in another relation. Example: SQL branch-name char(15) references branch
  • 13. Key Constraints Super Key: An attribute, or set of attributes, that uniquely identifies a tuple within a relation. However, a super key may contain additional attributes that are not necessary for a unique identification. Candidate Key: A super key such that no proper subset is a super key within the relation. There are two parts of the candidate key definition: i. Two distinct tuples in a legal instance cannot have identical values in all the fields of a key. ii. No subset of the set of fields in a candidate key is a unique identifier for a tuple.
  • 14. Key Constraints Primary Key: The candidate key that is selected to identify tuples uniquely within the relation. The candidate keys that are not selected as the primary key are called as alternate keys. Features of the primary key: 1. Primary key will not allow duplicate values. 2.Primary key will not allow null values. 3. Only one primary key is allowed per table.
  • 15. Key Constraints Foreign Key: Foreign keys represent the relationships between tables. A foreign key is a column (or a group of columns) whose values are derived from the primary key of some other table. Features of foreign key: 1. Records cannot be inserted into a detail table if corresponding records in the master table do not exist. 2. Records of the master table cannot be deleted or updated if corresponding records in the detail table actually exist.
  • 16. Integrity Constraint Assertions: An assertion is a predicate expressing a condition that we wish the database always to satisfy. create assertion <assertion-name> check <predicate> Example : create assertion sum-constraint check (not exists (select * from branch where (select sum(amount) from loan where loan.branch-name = branch.branch-name) >= (select sum(balance) from account where account.branch-name = branch.branch-name)))
  • 17. Integrity Constraint Triggers: A trigger is a statement that the system executes automatically as a side effect of a modification to the database. To design a trigger mechanism, we must meet two requirements: 1. Specify when a trigger is to be executed. This is broken up into an event that causes the trigger to be checked and a condition that must be satisfied for trigger execution to proceed. 2. Specify the actions to be taken when the trigger executes.
  • 18. Integrity Constraint Triggers: Example: define a trigger that replaces the blank value in a phone number field of an inserted tuple by the null value. create trigger setnull-trigger before update on r referencing new row as nrow for each row when nrow.phone-number = ’ ’ set nrow.phone-number = null
  • 20. Relational Algebra Fundamental Operations Unary Operation  Select  Project  Rename Binary Operations  Union  Set different  Cartesian product
  • 21. Relational Algebra Select (σ) : (a) Example: select those tuples of the loan relation where the branch is “Perryridge,” σbranch-name =“Perryridge” (loan) (b) Example: find those tuples pertaining to loans of more than $1200 made by the Perryridge branch σbranch-name =“Perryridge”∧ amount>1200 (loan)
  • 22. Relational Algebra Project(Π) Example: list all loan numbers and the amount of the loan as Πloan-number, amount(loan) Union(∪) Example: find the names of all bank customers who hav either an account or a loan or both. Πcustomer-name (borrower ) ∪ Πcustomer-name (depositor) borrower : Customers with a loan in the bank
  • 23. Relational Algebra Set Difference (-) Example: find all customers of the bank who have an account but not a loan Πcustomer-name (depositor) − Πcustomer-name (borrower ) Cartesian-Product (X) Example: find the names of all customers who have a loan at the Perryridge branch. 3. Πcustomer-name (σborrower .loan-number =loan.loan-number (σbranch-name =“Perryridge” (borrower × loan)))
  • 24. Relational Algebra Rename (ρ) relational-algebra expression E, ρ x (E) returns the result of expression E under the name x. Additional operations are: • Set intersection • Assignment • Natural join
  • 25. Relational Calculus Tuple Relational Calculus A query in the tuple relational calculus is expressed as {t | P(t)} the set of all tuples t such that predicate P is true for t. Domain Relational Calculus An expression in the domain relational calculus is of the form {< x1, x2, . . . , xn > | P(x1, x2, . . . , xn)} where x1, x2, . . . , xn represent domain variables. P represents a formula composed of atoms, as was the case in the tuple relational calculus.

Editor's Notes

  • #6: relation schema corresponds to the programming-language notion of type definition. relation instance corresponds to the programming language notion of a value of a variable.
  • #7: A database schema, along with primary key and foreign key dependencies, can be depicted pictorially by schema diagrams. E-R diagrams do not show foreign key attributes explicitly, whereas schema diagrams show them explicity.
  • #8: Mapping Entity
  • #9: Mapping Relation
  • #12: Domain definitions can be physical & Logical. Such constraints may also prohibit the use of null values for particular attributes. Thus, the domain of a field is essentially the type of that field. Values of one domain can be cast (that is, converted) to another domain. Example : If the attribute A or relation r is of type Dollars, we can convert it to Pounds by writing cast r.A as Pounds
  • #13: By default, a foreign key references the primary key attributes of the referenced table. SQL also supports a version of the references clause where a list of attributes of the referenced relation can be specified explicitly. The specified list of attributes must be declared as a candidate key of the referenced relation.
  • #14: (k1,k2,k3,k4) – superkey –unique identifier for tuple k1 – primary key k2, k3 – candidate key also alternate key K1,k2,k3 – not candiate key
  • #16: The table in which foreign key is defined is called a Foreign table or Details table. The table that defines the primary key and is referenced by the foreign key is called the Primary table or Master table.
  • #17: Domain constraints and referential-integrity constraints are special forms of assertions. When an assertion is created, the system tests it for validity. If the assertion is valid, then any future modification to the database is allowed only if it does not cause that assertion to be violated.
  • #18: The above model of triggers is referred to as the event-condition-action model for triggers.
  • #19: Trigger limited use: For example, suppose an insert trigger on a relation has an action that causes another (new) insert on the same relation. The insert action then triggers yet another insert action, and so on ad infinitum. Database systems typically limit the length of such chains of triggers (for example to 16 or 32), and consider longer chains of triggering an error.
  • #21: The relational algebra is a procedural query language. It consists of a set of operations that take one or two relations as input and produce a new relation as their result.
  • #22: In general, we allow comparisons using =, =, <, ≤, >, ≥ in the selection predicate. Furthermore, we can combine several predicates into a larger predicate by using the connectives and (∧), or (∨), and not (¬). Exercise: find all customers who have the same name as their loan officer, we can write σcustomer-name =banker-name(loan-officer)
  • #23: Since relations are sets, duplicate values are eliminated Composition of Relational Operations Example : “Find those customers who live in Harrison.” Πcustomer-name (σcustomer-city =“Harrison” (customer))
  • #24: Cartesian-Product Example We need the information in both the loan relation and the borrower relation to do so. Cartesian-product operation associates every tuple of loan with every tuple of borrower, 1. σbranch-name =“Perryridge”(borrower × loan) 2. σborrower .loan-number =loan.loan-number (σbranch-name =“Perryridge”(borrower × loan))
  • #25: Rename Operation Excellent Example Further reading from korth
  • #26: The tuple relational calculus, by contrast, is a nonprocedural query language. Following our earlier notation, we use t[A] to denote the value of tuple t on attribute A, andwe use t ∈ r to denote that tuple t is in relation r.