SlideShare a Scribd company logo
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
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
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

What's hot

Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
AbhinavPandey274499
 
Files Vs DataBase
Files Vs DataBaseFiles Vs DataBase
Files Vs DataBase
Dr. C.V. Suresh Babu
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMSkoolkampus
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architectureKumar
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMSkoolkampus
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
Arun Sharma
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbmsNaresh Kumar
 
Codd's rules
Codd's rulesCodd's rules
Codd's rulesMohd Arif
 
Rdbms
RdbmsRdbms
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
Shubham Dwivedi
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
Vignesh Saravanan
 
Data Models
Data ModelsData Models
Data Models
RituBhargava7
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
LGS, GBHS&IC, University Of South-Asia, TARA-Technologies
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
RUpaliLohar
 
Structure of dbms
Structure of dbmsStructure of dbms
Structure of dbms
Megha yadav
 
Distributed dbms architectures
Distributed dbms architecturesDistributed dbms architectures
Distributed dbms architectures
Pooja Dixit
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
RituBhargava7
 
Introduction & history of dbms
Introduction & history of dbmsIntroduction & history of dbms
Introduction & history of dbmssethu pm
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
Saranya Natarajan
 

What's hot (20)

Elmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 pptElmasri Navathe DBMS Unit-1 ppt
Elmasri Navathe DBMS Unit-1 ppt
 
Files Vs DataBase
Files Vs DataBaseFiles Vs DataBase
Files Vs DataBase
 
2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS2. Entity Relationship Model in DBMS
2. Entity Relationship Model in DBMS
 
2 database system concepts and architecture
2 database system concepts and architecture2 database system concepts and architecture
2 database system concepts and architecture
 
3. Relational Models in DBMS
3. Relational Models in DBMS3. Relational Models in DBMS
3. Relational Models in DBMS
 
Database Normalization
Database NormalizationDatabase Normalization
Database Normalization
 
All data models in dbms
All data models in dbmsAll data models in dbms
All data models in dbms
 
Codd's rules
Codd's rulesCodd's rules
Codd's rules
 
Rdbms
RdbmsRdbms
Rdbms
 
Dbms architecture
Dbms architectureDbms architecture
Dbms architecture
 
Integrity constraints in dbms
Integrity constraints in dbmsIntegrity constraints in dbms
Integrity constraints in dbms
 
Data Models
Data ModelsData Models
Data Models
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Relational algebra.pptx
Relational algebra.pptxRelational algebra.pptx
Relational algebra.pptx
 
Structure of dbms
Structure of dbmsStructure of dbms
Structure of dbms
 
Distributed dbms architectures
Distributed dbms architecturesDistributed dbms architectures
Distributed dbms architectures
 
File systems versus a dbms
File systems versus a dbmsFile systems versus a dbms
File systems versus a dbms
 
Databases: Normalisation
Databases: NormalisationDatabases: Normalisation
Databases: Normalisation
 
Introduction & history of dbms
Introduction & history of dbmsIntroduction & history of dbms
Introduction & history of dbms
 
ER-Model-ER Diagram
ER-Model-ER DiagramER-Model-ER Diagram
ER-Model-ER Diagram
 

Viewers also liked

Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
Nikhil Deswal
 
Relational database management system (rdbms) i
Relational database management system (rdbms) iRelational database management system (rdbms) i
Relational database management system (rdbms) i
Ravinder Kamboj
 
Urinary system embryology
Urinary system embryologyUrinary system embryology
Urinary system embryology
ishtiaqqazi
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
John Mulhall
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
Mustafa Kamel Mohammadi
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
Bashir Rezaie
 
Introduction to RDBMS
Introduction to RDBMSIntroduction to RDBMS
Introduction to RDBMS
Sarmad Ali
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraintsKumar
 
Denormalization
DenormalizationDenormalization
Denormalization
Sohail Haider
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMSkoolkampus
 
Rdbms
RdbmsRdbms
Rdbms
rdbms
 

Viewers also liked (13)

Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Rdbms
RdbmsRdbms
Rdbms
 
Relational database management system (rdbms) i
Relational database management system (rdbms) iRelational database management system (rdbms) i
Relational database management system (rdbms) i
 
Urinary system embryology
Urinary system embryologyUrinary system embryology
Urinary system embryology
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Fundamentals of database system - Relational data model and relational datab...
Fundamentals of database system  - Relational data model and relational datab...Fundamentals of database system  - Relational data model and relational datab...
Fundamentals of database system - Relational data model and relational datab...
 
The relational data model part[1]
The relational data model part[1]The relational data model part[1]
The relational data model part[1]
 
Introduction to RDBMS
Introduction to RDBMSIntroduction to RDBMS
Introduction to RDBMS
 
4 the relational data model and relational database constraints
4 the relational data model and relational database constraints4 the relational data model and relational database constraints
4 the relational data model and relational database constraints
 
Denormalization
DenormalizationDenormalization
Denormalization
 
RDBMS.ppt
RDBMS.pptRDBMS.ppt
RDBMS.ppt
 
14. Query Optimization in DBMS
14. Query Optimization in DBMS14. Query Optimization in DBMS
14. Query Optimization in DBMS
 
Rdbms
RdbmsRdbms
Rdbms
 

Similar to Database : Relational Data Model

SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
Smriti Jain
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
Prosanta Ghosh
 
6 integrity and security
6 integrity and security6 integrity and security
6 integrity and securityDilip G R
 
MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
YUCHENG HU
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
Raghu Bright
 
My sql advacnce topics
My sql advacnce topicsMy sql advacnce topics
My sql advacnce topics
Prabhat gangwar
 
Ch6
Ch6Ch6
Design dbms
Design dbmsDesign dbms
Design dbms
IIITA
 
RDBMS
RDBMSRDBMS
RDBMS
NilaNila16
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
Abdullah Almasud
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMSkoolkampus
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMSkoolkampus
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
YashWaghmare27
 
Ch4
Ch4Ch4
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
santosh mishra
 

Similar to Database : Relational Data Model (20)

SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013Dbms ii mca-ch4-relational model-2013
Dbms ii mca-ch4-relational model-2013
 
6 integrity and security
6 integrity and security6 integrity and security
6 integrity and security
 
MySQL 指南
MySQL 指南MySQL 指南
MySQL 指南
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
Unit04 dbms
Unit04 dbmsUnit04 dbms
Unit04 dbms
 
My sql advacnce topics
My sql advacnce topicsMy sql advacnce topics
My sql advacnce topics
 
Ch6
Ch6Ch6
Ch6
 
Design dbms
Design dbmsDesign dbms
Design dbms
 
ch2
ch2ch2
ch2
 
RDBMS
RDBMSRDBMS
RDBMS
 
E-R diagram & SQL
E-R diagram & SQLE-R diagram & SQL
E-R diagram & SQL
 
ch4
ch4ch4
ch4
 
6. Integrity and Security in DBMS
6. Integrity and Security in DBMS6. Integrity and Security in DBMS
6. Integrity and Security in DBMS
 
Unit 04 dbms
Unit 04 dbmsUnit 04 dbms
Unit 04 dbms
 
5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS5. Other Relational Languages in DBMS
5. Other Relational Languages in DBMS
 
uniT 4 (1).pptx
uniT 4 (1).pptxuniT 4 (1).pptx
uniT 4 (1).pptx
 
Ch4
Ch4Ch4
Ch4
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 
Mysql tutorial
Mysql tutorialMysql tutorial
Mysql tutorial
 

Recently uploaded

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 

Recently uploaded (20)

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 

Database : Relational Data Model

  • 1.
  • 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
  • 9.
  • 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
  • 19.
  • 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

  1. 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.
  2. 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.
  3. Mapping Entity
  4. Mapping Relation
  5. 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
  6. 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.
  7. (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
  8. 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.
  9. 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.
  10. The above model of triggers is referred to as the event-condition-action model for triggers.
  11. 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.
  12. 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.
  13. 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)
  14. 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))
  15. 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))
  16. Rename Operation Excellent Example Further reading from korth
  17. 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.