SlideShare a Scribd company logo
M S . R . VA N I T HA
RDBMS-UNIT-II (23UITCC31)
Relational model can represent as a table with columns and rows.
Domain: it contains a set of atomic values that an attribute can take.
Attribute: it contains the name of a column in a particular table. Each attribute ai must
have a domain.
Relational instance: in the relational database system, the relational instance is
represented by a finite set of tuples. Relation instances do not have duplicate tuples.
Relational schema: A relational schema contains the name of the relation and name of all
columns or attributes.
Relational key: in the relational key, each row has one or more attributes. It can identify
the row in the relation uniquely.
Relational Model in DBMS
•Name of the relation is distinct from all other relations.
•Each relation cell contains exactly one atomic (single)
value
•Each attribute contains a distinct name
•Attribute domain has no significance
•Tuple has no duplicate value
•Order of tuple can have a different sequence
Properties of Relations
Mainly constraints on the
relational database are of 4 types
•Domain constraints
•Key constraints or uniqueness
constraints
•Entity integrity constraints
•Referential integrity constraints
Contraints on Relational
Database Model
Query is a question or requesting information. Query
language is a language which is used to retrieve
information from a database.
Query language is divided into two types −
•Procedural language
•Non-procedural language
Unary Relational Operations
Procedural Language
Relational algebra consists of a set of operations that take one or two relations as an input
and produces a new relation as output.
The different types of relational algebra operations are as follows −
• Select operation
• Project operation
• Rename operation
• Union operation
• Intersection operation
• Difference operation
• Cartesian product operation
• Join operation
• Division operation
Select Operation
It displays the records that satisfy a condition and is denoted by sigma
(σ). It is a horizontal subset of the original relation.
Syntax
The syntax for the select operation is as follows −
σcondition(table name)
Example:
σbranch=cse(student)
Output:
Reg
No
Branch Sectio
n
1 CSE A
Projection Operation
It displays the specific column of a table. It is denoted by pie (Π). It is a vertical subset of
the original relation. It eliminates duplicate tuples.
Syntax
The syntax of projection operation is as follows −
∏regno(student)
Example 1
∏regno(student)
Output:
RegNo
1
2
3
Rename Operation
It is used to assign a new name to a relation. It is denoted by ρ (rho).
Syntax
The syntax for rename operation is as follows −
ρnewname (tablename or expression)
Example
ρnewstudent (student)
Types of RENAME
Renaming can be used by three methods, which are as follows −
•Changing name of the relation.
•Changing name of the attribute.
•Changing both.
Union Operation
1. The UNION operation is commutative, that is :
A B = B A
∪ ∪
2. The UNION is associative, that means it is applicable to any number of relation.
A ( B C ) = ( A B ) C
∪ ∪ ∪ ∪
3. In SQL, the operation UNION is as same as UNION operation here.
4. Moreover, In SQL there is multiset operation UNION ALL.
Intersection Operation
1. The INTERSECTION operation is commutative, that is :
A ∩ B = B ∩ A
2. The INTERSECTION is associative, that means it is applicable to any number
of relation.
A ∩ ( B ∩ C ) = ( A ∩ B ) ∩ C
3. INTERSECTION can be formed using UNION and MINUS as follows:
A ∩ B = ((A ∪ B) - (A - B)) - (B - A)
4. In SQL, the operation INTERSECT is as same as INTERSECTION operation
here.
5. Moreover, In SQL there is multiset operation INTERSECT ALL.
Minus or Set Difference Operation
1. The SET DIFFERENCE operation is not commutative, that means :
A - B != B - A
2. In SQL, the operation EXCEPT is as same as MINUS operation here.
3. Moreover, In SQL there is multiset operation EXCEPT ALL.
Join Operation
A Join operation combines related
tuples from different relations, if and
only if a given join condition is
satisfied. It is denoted by .
⋈
Example:
Operation:
(EMPLOYEE SALARY)
⋈
Types of Join Operation
1. Natural Join: A natural join is the set of tuples of all combinations in R and S that are equal on their
common attribute names. It is denoted by . Example:
⋈
∏EMP_NAME, SALARY (EMPLOYEE SALARY)
⋈
2. Outer Join: The outer join operation is an extension of the join operation. It is used to deal with
missing information.
Example: (EMPLOYEE FACT_WORKERS)
⋈
3. Equi join: It is also known as an inner join. It is the most common join. It is based on matched data as
per the equality condition. The equi join uses the comparison operator(=)
Example:CUSTOMER PRODUCT
⋈
Types of Outer Join Operation
a. Left outer join:
•Left outer join contains the set of tuples of all combinations in R and S that are equal on their common
attribute names. In the left outer join, tuples in R have no matching tuples in S.
It is denoted by . Example:
⟕ EMPLOYEE FACT_WORKERS
⟕
b. Right outer join:
•Right outer join contains the set of tuples of all combinations in R and S that are equal on their
common attribute names. In right outer join, tuples in S have no matching tuples in R.
It is denoted by . Example:
⟖ EMPLOYEE FACT_WORKERS
⟖
c. Full outer join:
•Full outer join is like a left or right join except that it contains all rows from both tables.
•In full outer join, tuples in R that have no matching tuples in S and tuples in S that have no matching
tuples in R in their common attribute name.
•It is denoted by . Example:
⟗ EMPLOYEE FACT_WORKERS
⟗
Example Queries on Relational
Algebra
Suppose there is a banking database which comprises following tables :
Customer(Cust_name, Cust_street, Cust_city)
Branch(Branch_name, Branch_city, Assets)
Account (Branch_name, Account_number, Balance)
Loan(Branch_name, Loan_number, Amount)
Depositor(Cust_name, Account_number)
Borrower(Cust_name, Loan_number)
Query : Find the names of all the customers who have taken a loan from the bank and also have an account at the bank.
Solution:
Step 1 : Identify the relations that would be required to frame the resultant query.
First half of the query(i.e. names of customers who have taken loan) indicates “borrowers” information.
So Relation 1 —–> Borrower.
Second half of the query needs Customer Name and Account number which can be obtained from Depositor relation.
Hence, Relation 2——> Depositor.
Step 2 : Identify the columns which you require from the relations obtained in Step 1.

More Related Content

Similar to Relational Database management Systems unit-II (20)

DOCX
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Raj vardhan
 
PPTX
Datqbase management system: Relational Algebra.pptx
ShubhamTiwari907077
 
PPTX
5th chapter Relational algebra.pptx
kavitha623544
 
PPTX
REC-UNIT-2-DATABASEMANAGEMENTSYSTEMS.pptx
Uma Kakarlapudi
 
PPTX
316_16SCCCS4_2020052505222431.pptdatabasex
abhaysonone0
 
PPT
354 ch6
Yibelital Alemu
 
PDF
ML111 Lecture 5 Relational Algebra and Advanced SQL.pdf
tory10027
 
PPTX
Relational algebr
Visakh V
 
PDF
Data Base Managment system
batermkf
 
PDF
Data base managment system
batermkf
 
PDF
Cs501 rel algebra
Kamal Singh Lodhi
 
PPT
Relational algebra operations
SanthiNivas
 
PPTX
Dbms relational model
Radhika Talaviya
 
PDF
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
PPTX
Lect - 12 solve d.pptx
SumeetRathi5
 
PPTX
3._Relational_Algebra.pptx:Basics of relation algebra
ZakriyaMalik2
 
PPTX
Module 2_Relational Algebra.pptx
ShashiKumarB5
 
PDF
3.2 SQL to -Relational Algebra.pdf
MuhammadSaadan2
 
PPTX
Chapter-6 Relational Algebra
Kunal Anand
 
Relational Algebra Ch6 (Navathe 4th edition)/ Ch7 (Navathe 3rd edition)
Raj vardhan
 
Datqbase management system: Relational Algebra.pptx
ShubhamTiwari907077
 
5th chapter Relational algebra.pptx
kavitha623544
 
REC-UNIT-2-DATABASEMANAGEMENTSYSTEMS.pptx
Uma Kakarlapudi
 
316_16SCCCS4_2020052505222431.pptdatabasex
abhaysonone0
 
ML111 Lecture 5 Relational Algebra and Advanced SQL.pdf
tory10027
 
Relational algebr
Visakh V
 
Data Base Managment system
batermkf
 
Data base managment system
batermkf
 
Cs501 rel algebra
Kamal Singh Lodhi
 
Relational algebra operations
SanthiNivas
 
Dbms relational model
Radhika Talaviya
 
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
Lect - 12 solve d.pptx
SumeetRathi5
 
3._Relational_Algebra.pptx:Basics of relation algebra
ZakriyaMalik2
 
Module 2_Relational Algebra.pptx
ShashiKumarB5
 
3.2 SQL to -Relational Algebra.pdf
MuhammadSaadan2
 
Chapter-6 Relational Algebra
Kunal Anand
 

Recently uploaded (20)

PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
July Patch Tuesday
Ivanti
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Ad

Relational Database management Systems unit-II

  • 1. M S . R . VA N I T HA RDBMS-UNIT-II (23UITCC31)
  • 2. Relational model can represent as a table with columns and rows. Domain: it contains a set of atomic values that an attribute can take. Attribute: it contains the name of a column in a particular table. Each attribute ai must have a domain. Relational instance: in the relational database system, the relational instance is represented by a finite set of tuples. Relation instances do not have duplicate tuples. Relational schema: A relational schema contains the name of the relation and name of all columns or attributes. Relational key: in the relational key, each row has one or more attributes. It can identify the row in the relation uniquely. Relational Model in DBMS
  • 3. •Name of the relation is distinct from all other relations. •Each relation cell contains exactly one atomic (single) value •Each attribute contains a distinct name •Attribute domain has no significance •Tuple has no duplicate value •Order of tuple can have a different sequence Properties of Relations
  • 4. Mainly constraints on the relational database are of 4 types •Domain constraints •Key constraints or uniqueness constraints •Entity integrity constraints •Referential integrity constraints Contraints on Relational Database Model
  • 5. Query is a question or requesting information. Query language is a language which is used to retrieve information from a database. Query language is divided into two types − •Procedural language •Non-procedural language Unary Relational Operations
  • 6. Procedural Language Relational algebra consists of a set of operations that take one or two relations as an input and produces a new relation as output. The different types of relational algebra operations are as follows − • Select operation • Project operation • Rename operation • Union operation • Intersection operation • Difference operation • Cartesian product operation • Join operation • Division operation
  • 7. Select Operation It displays the records that satisfy a condition and is denoted by sigma (σ). It is a horizontal subset of the original relation. Syntax The syntax for the select operation is as follows − σcondition(table name) Example: σbranch=cse(student) Output: Reg No Branch Sectio n 1 CSE A
  • 8. Projection Operation It displays the specific column of a table. It is denoted by pie (Π). It is a vertical subset of the original relation. It eliminates duplicate tuples. Syntax The syntax of projection operation is as follows − ∏regno(student) Example 1 ∏regno(student) Output: RegNo 1 2 3
  • 9. Rename Operation It is used to assign a new name to a relation. It is denoted by ρ (rho). Syntax The syntax for rename operation is as follows − ρnewname (tablename or expression) Example ρnewstudent (student) Types of RENAME Renaming can be used by three methods, which are as follows − •Changing name of the relation. •Changing name of the attribute. •Changing both.
  • 10. Union Operation 1. The UNION operation is commutative, that is : A B = B A ∪ ∪ 2. The UNION is associative, that means it is applicable to any number of relation. A ( B C ) = ( A B ) C ∪ ∪ ∪ ∪ 3. In SQL, the operation UNION is as same as UNION operation here. 4. Moreover, In SQL there is multiset operation UNION ALL.
  • 11. Intersection Operation 1. The INTERSECTION operation is commutative, that is : A ∩ B = B ∩ A 2. The INTERSECTION is associative, that means it is applicable to any number of relation. A ∩ ( B ∩ C ) = ( A ∩ B ) ∩ C 3. INTERSECTION can be formed using UNION and MINUS as follows: A ∩ B = ((A ∪ B) - (A - B)) - (B - A) 4. In SQL, the operation INTERSECT is as same as INTERSECTION operation here. 5. Moreover, In SQL there is multiset operation INTERSECT ALL.
  • 12. Minus or Set Difference Operation 1. The SET DIFFERENCE operation is not commutative, that means : A - B != B - A 2. In SQL, the operation EXCEPT is as same as MINUS operation here. 3. Moreover, In SQL there is multiset operation EXCEPT ALL.
  • 13. Join Operation A Join operation combines related tuples from different relations, if and only if a given join condition is satisfied. It is denoted by . ⋈ Example: Operation: (EMPLOYEE SALARY) ⋈
  • 14. Types of Join Operation 1. Natural Join: A natural join is the set of tuples of all combinations in R and S that are equal on their common attribute names. It is denoted by . Example: ⋈ ∏EMP_NAME, SALARY (EMPLOYEE SALARY) ⋈ 2. Outer Join: The outer join operation is an extension of the join operation. It is used to deal with missing information. Example: (EMPLOYEE FACT_WORKERS) ⋈ 3. Equi join: It is also known as an inner join. It is the most common join. It is based on matched data as per the equality condition. The equi join uses the comparison operator(=) Example:CUSTOMER PRODUCT ⋈
  • 15. Types of Outer Join Operation a. Left outer join: •Left outer join contains the set of tuples of all combinations in R and S that are equal on their common attribute names. In the left outer join, tuples in R have no matching tuples in S. It is denoted by . Example: ⟕ EMPLOYEE FACT_WORKERS ⟕ b. Right outer join: •Right outer join contains the set of tuples of all combinations in R and S that are equal on their common attribute names. In right outer join, tuples in S have no matching tuples in R. It is denoted by . Example: ⟖ EMPLOYEE FACT_WORKERS ⟖ c. Full outer join: •Full outer join is like a left or right join except that it contains all rows from both tables. •In full outer join, tuples in R that have no matching tuples in S and tuples in S that have no matching tuples in R in their common attribute name. •It is denoted by . Example: ⟗ EMPLOYEE FACT_WORKERS ⟗
  • 16. Example Queries on Relational Algebra Suppose there is a banking database which comprises following tables : Customer(Cust_name, Cust_street, Cust_city) Branch(Branch_name, Branch_city, Assets) Account (Branch_name, Account_number, Balance) Loan(Branch_name, Loan_number, Amount) Depositor(Cust_name, Account_number) Borrower(Cust_name, Loan_number) Query : Find the names of all the customers who have taken a loan from the bank and also have an account at the bank. Solution: Step 1 : Identify the relations that would be required to frame the resultant query. First half of the query(i.e. names of customers who have taken loan) indicates “borrowers” information. So Relation 1 —–> Borrower. Second half of the query needs Customer Name and Account number which can be obtained from Depositor relation. Hence, Relation 2——> Depositor. Step 2 : Identify the columns which you require from the relations obtained in Step 1.