Unit 1 DR - Mohd.nazim
Unit 1 DR - Mohd.nazim
Introduction of Database
& Conceptual Designing
Unit: 1
BCSE0452
Dr. Mohd. Nazim
Assistant Professor
Course Details
(B Tech IVth Sem) CSE Department
Lucknow
02/08/2025 3
DBMS Unit-1
Syllabus
02/08/20 DBMS 13
25
Program Outcomes
Engineering Graduates will be able to:
5. Modern tool usage: Create, select, and apply appropriate techniques,
resources, and modern engineering and IT tools including prediction and
modeling to complex engineering activities with an understanding of the
limitations.
6. The engineer and society: Apply reasoning informed by the contextual
knowledge to assess societal, health, safety, legal and cultural issues and the
consequent responsibilities relevant to the professional engineering practice.
02/08/20 DBMS 14
25
Program Outcomes
Engineering Graduates will be able to:
9. Individual and team work: Function effectively as an individual, and as a
member or leader in diverse teams, and in multidisciplinary settings.
12. Life-long learning: Recognize the need for, and have the preparation and ability
to engage in independent and life-long learning in the broadest context of
technological change.
02/08/20 DBMS 15
25
COs and POs Mapping
PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12
BCSE0452.1
2 3 3 3 2 1 - 1 2 - 2 2
BCSE0452.2
3 2 3 3 2 2 - 2 1 2 2 2
BCSE0452.3
3 3 2 3 3 2 - 2 1 - 2 2
BCSE0452.4
3 2 3 2 2 2 - - 2 2 2 3
BCSE0452.5
2 2 2 2 2 2 - - 1 2 1 2
AVG
2.6 2.4 2.6 2.6 2.2 1.8 - 1.67 1.4 2.0 1.8 2.2
02/08/2025 DBMS 16
Program Specific Outcomes (PSOs)
PSO1:
Identify, analyze real world problems and design their ethical solutions using artificial
intelligence, robotics, virtual/augmented reality, data analytics, block chain technology, and
cloud computing.
PSO2:
Design and develop the hardware sensor devices and related interfacing software systems
for solving complex engineering problems.
PSO3:
Understand inter-disciplinary computing techniques and to apply them in the design of
advanced computing.
PSO4:
Conduct investigation of complex problems with the help of technical, managerial, leadership
qualities, and modern engineering tools provided by industry-sponsored laboratories.
02/08/2025 DBMS 17
COs and PSOs Mapping
BCSE0452.1
3
3 1 3
BCSE0452.2 2
3 1 3
BCSE0452.3 2
3 2 2
BCSE0452.4 2
3 2 2
BCSE0452.5 2
3 2 2
Average 3 1.6 2.4 2.2
02/08/2025 DBMS 18
Program Educational Objectives (PEOs)
PEO4: To have life-long learning for up-skilling and re-skilling for a successful
professional career as an engineer, scientist, entrepreneur or bureaucrat for the
betterment of the society.
02/08/2025 DBMS 19
Result Analysis
02/08/20 DBMS 20
25
Question Paper Template
02/08/20 DBMS 21
25
Question Paper
Template SECTION – A CO
SECTION – B CO
02/08/20 DBMS 22
22
25
Question Paper
Template
SECTION – C CO
02/08/20 DBMS 23
25
Prerequisite and Recap
02/08/20 DBMS 24
25
Brief Introduction about the Subject
Video Link:
www.youtube.com/watch?v=3EJlovevfcA&t=436s
02/08/20 DBMS 25
25
Content – Unit 1
02/08/20 DBMS 26
25
Unit Objective
2. DDL stands for Data Definition Language. DML stands for Data
Manipulation Language. DDL statements are used to create
database, schema, constraints, users, tables etc. DML statement is
used to insert, update or delete the records.
02/08/20 DBMS 27
25
Introduction of SDLC
02/08/20 DBMS 28
25
Introduction of SDLC
1. Requirement Analysis
1. The most critical phase where stakeholders, project managers, and
analysts gather and analyze business needs.
2. The outcome is a detailed Software Requirements Specification
(SRS) document.
2. Planning
1. Focuses on defining the project scope, timelines, costs, and
resources.
2. A feasibility study is conducted to determine the technical,
operational, and economic viability of the project.
3. System Design
1. Architects and designers create the overall system design, including
UI/UX, database structure, and system architecture.
2. High-Level Design (HLD) and Low-Level Design (LLD) documents are
produced.
02/08/20 DBMS 29
25
Introduction of SDLC
4. Development (Coding)
1. Developers write the actual code based on design specifications.
2. Different coding standards and programming languages are chosen
according to the project requirements.
5. Testing
1. The developed software is rigorously tested for bugs, errors, and
functionality mismatches.
2. Testing types include unit testing, integration testing, system
testing, and user acceptance testing (UAT).
02/08/20 DBMS 30
25
Introduction of SDLC
6. Deployment
1. The software is deployed to a production environment for use by end
users.
2. This may involve installing the software, configuring it, and providing
user training.
7. Maintenance
3. Post-deployment, the software requires updates, bug fixes, and
enhancements to adapt to changing user needs or technologies.
4. Ensures the longevity and relevance of the software.
02/08/20 DBMS 31
25
Data and Information
Data
• Raw, unprocessed facts and figures without any context.
• It can be numeric, textual, or in other forms and does not carry meaning
by itself.
• Examples:
Numbers: 123, 456
Text: "John", "Delhi“
Date: 2025-01-07
Information
• Processed, structured, or interpreted data that provides meaning or
context, making it useful for decision-making.
• Examples:
Data: 123, John, Delhi
Information: "John (ID: 123) lives in Delhi"
02/08/20 DBMS 32
25
What is DBMS
02/08/20 DBMS 33
25
Why use DBMS
02/08/20 DBMS 34
25
History of DBMS
Punch Cards: Early computers used punch cards to store and process data,
but this method was cumbersome and limited.
•Hierarchical Databases:
• Data was organized like a tree (parent-child relationships).
• Example: IBM’s IMS (Information Management System).
• Limitation: Rigid structure, hard to handle complex relationships.
•Network Databases:
• Data was connected using a flexible graph structure (many-to-many
relationships).
• Example: CODASYL DBTG (Database Task Group).
• Limitation: Complex to manage and query
02/08/20 DBMS 36
25
History of DBMS
• Dr. E.F. Codd (1970) introduced the Relational Model, which became the
foundation for modern databases.
• Data was stored in tables (relations) with rows and columns.
• Advantages:
• Easier to understand and manage.
• Queries could be written using SQL (Structured Query Language).
• Popular systems: Oracle, MySQL, PostgreSQL, Microsoft SQL Server.
02/08/20 DBMS 37
25
History of DBMS
6. NoSQL Databases (2000s)
• With the rise of big data and web applications, traditional relational
databases struggled with scalability.
• NoSQL (Not Only SQL) databases emerged, designed to handle:
• Large amounts of unstructured or semi-structured data.
• High-speed read/write operations.
Types:
• Document databases (e.g., MongoDB).
• Key-Value stores (e.g., Redis).
• Column-family stores (e.g., Cassandra).
• Graph databases (e.g., Neo4j).
02/08/20 DBMS 38
25
History of DBMS
02/08/20 DBMS 39
25
Why we study DBMS
02/08/20 DBMS 40
25
Advantage of DBMS
⚫ Controlling Redundancy
⚫ Restricting Unauthorized Access
⚫ Provide storage structures for efficient query processing
⚫ Backup and Recovery
⚫ Support concurrent access
⚫ Multiple user interfaces
⚫ Represent complex relationship among data
⚫ Enforcing Integrity constraints
02/08/2025 DBMS 41
Files vs.
DBMS
• Application must stage large datasets between main memory and
secondary storage (e.g., buffering, page-oriented access, 32-bit
addressing, etc.)
• Special code for different queries
• Must protect data from inconsistency due to multiple concurrent
users
• Crash recovery
• Security and access control
02/08/2025 DBMS 42
Purpose of Database Systems
⚫ In the early days, database applications were built directly on top of
file systems
⚫ Drawbacks of using file systems to store data:
⚫ Data redundancy and inconsistency
⚫ Multiple file formats, duplication of information in different
files
⚫ Difficulty in accessing data
⚫ Need to write a new program to carry out each new task
⚫ Data isolation — multiple files and formats
⚫ Integrity problems
⚫ Integrity constraints (e.g. account balance >
0) become
“buried” in program code rather than being stated explicitly
⚫ Hard to add new constraints or change existing ones
02/08/2025 DBMS 43
Purpose of Database Systems (Cont.)
02/08/20 DBMS 45
25
Database Administrator
02/08/20 DBMS 46
25
Database System Concepts
Key concepts of database systems:
3. Data Model : Framework for organizing data (e.g., Relational Model, ER Model).
10. Joins : Operations to retrieve related data from multiple tables (e.g., INNER JOIN,
LEFT JOIN).
12. Data Warehousing : Systems for reporting and analyzing large volumes of
historical data.
13. Big Data : Large datasets managed with technologies like Hadoop and Spark.
14. Data Mining : Discovering patterns and knowledge from large datasets.
02/08/20 DBMS 49
25
Types of Data Models
02/08/20 DBMS 50
25
Types of Data Models
02/08/20 DBMS 52
25
Types of Data Models
02/08/20 DBMS 53
25
Specific Types of Data Models
02/08/20 DBMS 54
25
Specific Types of Data Models
02/08/20 DBMS 55
25
Specific Types of Data Models
02/08/20 DBMS 56
25
Specific Types of Data Models
02/08/20 DBMS 57
25
Specific Types of Data Models
02/08/20 DBMS 58
25
Schemas and Instances
02/08/20 DBMS 59
25
Levels of Abstraction
02/08/20 DBMS 61
25
Example: University Database
Physical schema:
Relations stored as unordered files.
Index on first column of Students.
Conceptual schema:
Students(sid: string, name: string, login: string, age: integer, gpa:real)
Courses(cid: string, cname:string, credits:integer)
Enrolled(sid:string, cid:string, grade:string)
External Schema (View):
View1- Course_info(cid:string,enrollment:integer)
View2-studeninfo(id:int. name:string)
02/08/20 DBMS 62
25
Relational Database Terms
1. Relation
•A relation is a table in the database.
•It consists of rows and columns.
•Example:
A "Students" table is a relation.
2. Tuple
• A tuple is a single row in a table.
• Each row contains information about one instance.
• Example:In the "Students" table above:(101, John, 20) is
a tuple.
02/08/20 DBMS 63
25
Relational Database Terms
3. Attribute
• An attribute is a column in a table.
• It represents a property of the data.
• Example:
In the "Students" table:
• Roll Number, Name, and Age are attributes.
4. Domain
• A domain is the set of all possible values an attribute can
take.
• Example:
• For the Age attribute, the domain could be all positive
integers (e.g., 18–100).
• For the Name attribute, the domain could be all strings
02/08/20
of text. DBMS 64
25
Codd’s 12 Rule
70
02/08/20
25
Introduction of ER Model
• An entity set is a set of entities of the same type that share the
same properties.
– Example: set of all persons, companies, trees, holidays
02/08/20 DBMS 71
25
Entity Sets customer and
loan
customer_id customer_ customer_ customer_ loan_ amount
name street city number
02/08/20 DBMS 72
25
Attributes
• An entity is represented by a set of attributes, that is descriptive
properties possessed by all members of an entity set.
Example: customer = (customer_id, customer_name,
customer_street, customer_city )
loan = (loan_number, amount )
02/08/20 DBMS 73
25
Attribute
Type
• Key Attribute – The attribute which uniquely identifies each entity
in the entity set is called key attribute. For example, Roll_No will be
unique for each student. In ER diagram, key attribute is represented
by an oval with underlying lines.
02/08/20 DBMS 74
25
Attribute
Type
• Multivalued Attribute – An attribute consisting more than one
value for a given entity. For example, Phone_No (can be more than
one for a given student). In ER diagram, multivalued attribute is
represented by double oval.
02/08/20 DBMS 75
25
Attribute
Type
• The complete entity type Student with its attributes can
be represented as:
02/08/20 DBMS 76
25
Relationship
Type
• A relationship type represents the association between
entity types.
02/08/20 DBMS 77
25
Relationship
Set
• A set of relationships of same type is known as relationship set.
02/08/20 DBMS 78
25
Degree of Relationship
Set
– Unary Relationship
– Binary Relationship
– n-ary Relationship
02/08/20 DBMS 79
25
Unary Relationship
02/08/20 DBMS 80
25
Binary Relationship
02/08/20 DBMS 81
25
n-ary Relationship
02/08/20 DBMS 82
25
Mapping
Cardinality
02/08/20 DBMS 83
25
One to one
• When each entity in each entity set can take part only once in the
relationship, the cardinality is one to one. Let us assume that a
male can marry to one female and a female can marry to one male.
So the relationship will be one to one.
02/08/20 DBMS 84
25
Many to one
• When entities in one entity set can take part only once in the
relationship set and entities in other entity set can take part more
than once in the relationship set, cardinality is many to one
02/08/20 DBMS 85
25
Many to many
• When entities in all entity sets can take part more than once in the
relationship cardinality is many to many. Let us assume that a
student can take more than one course and one course can be
taken by many students. So the relationship will be many to many.
02/08/20 DBMS 86
25
Participation
Constraint
• Total Participation – Each entity in the entity set must participate in
the relationship. If each student must enroll in a course, the
participation of student will be total. Total participation is shown by
double line in ER diagram.
• Partial Participation – The entity in the entity set may or may NOT
participate in the relationship. If some courses are not enrolled by
any of the student, the participation of course will be partial.
02/08/20 DBMS 87
25
Participation Constraint
(contd..)
02/08/20 DBMS 88
25
Weak Entity Type & Identifying
Relationship
• An entity type has a key attribute which uniquely identifies each
entity in the entity set.
• But there exists some entity type for which key attribute can’t be
defined. These are called Weak Entity type.
• For example, A company may store the information of dependents
(Parents, Children, Spouse) of an Employee.
• But the dependents don’t have existence without the employee.
• So Dependent will be weak entity type and Employee will
be
Identifying Entity type for Dependent.
02/08/20 DBMS 89
25
Weak Entity Type & Identifying Relationship
02/08/20 DBMS 90
25
Example of ER Diagram
02/08/20 DBMS 91
25
ER Diagram
Examples
02/08/20 DBMS 95
25
Reducing ER Diagrams to Tables
02/08/20 DBMS 96
25
Reduction of an ER diagrams to tables Rule-01
•
02/08/20 DBMS Unit-1 101
25
RULE-05 (contd..)
NOTE- Here, combined table will be drawn for the entity set A and
relationship set R.
• Here, two tables will be required. Either combine ‘R’ with ‘A’ or ‘B’
• Way-01:
1. AR ( a1 , a2 , b1 )
2. B ( b1 , b2 )
• Way-02:
1. A ( a1 , a2 )
2. BR ( a1 , b1 , b2 )
02/08/20 DBMS Unit-1 105
25
RULE-06
Enhanced ERD are high level models that represent the requirements and
complexities of complex database.
Category or Union
Relationship of one super or sub class with more than one super class.
Aggregation
Represents relationship between a whole object and its component.
Degree of Relationship
A degree of relationship represents the number of entity types
that are associated with a relationship.
Types of degree
based on the number of linked entity types, we have 4 types of
degrees of relationships.
Unary
Binary
Ternary
N-ary
Unary (Degree 1)
in a relation only one entity set is participating then such type of
relationship is known as a unary relationship.
Example: In a particular class, we have many students, there are monitors
too. So, here class monitors are also students. Thus, we can say that only
students are participating here. So the degree of such type of relationship
is 1.
Binary (Degree 2)
In a relation when two entity sets are participating then such type
of relationship is known as a binary relationship. This is the most used
relationship and one can easily be converted into a relational table.
Example: We have two entity types ‘Student’ and ‘ID’ where each
‘Student’ has his ‘ID’. So, here two entity types are associating, it is a binary
relationship.
Also, one ‘Father’ can have many ‘daughters’ but each ‘daughter’ should
belong to only one ‘father. it is a one-to-many binary relationship.
Ternary (Degree 3)
Ternary relationship exists when there are three types of entity
and we call them a degree of relationship is 3.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The
relationship between these entities is defined as the teacher teaching a
particular course, also the teacher teaches a particular class. So, here three
entity types are associating we can say it is a ternary relationship.
N-ary (n Degree)
an N-ary relationship exists when there are n types of entities.
There is one limitation of the N-ary relationship, as there are many entities
so it is very hard to convert into an entity, rational table.
https://youtu.be/M4qZ5i1LL2o?si=M-YvPZ1Vp9KZK5Kn
https://youtu.be/010_f2HKzJY?si=82Z1Qleud-bBduii
Example: We have 5 entities Teacher, Class, Location, Salary, Course. So,
here five entity types are associating we can say an n-ary relationship is 5.
02/08/20 DBMS 12
25 0
Generalization
• Generalization is the process of extracting common properties from
a set of entities and create a generalized entity from it.
Q. Which type of entity cannot exist in the database unless another type
of entity also exists in the database, but does not require that the
identifier of that other entity be included as part of its own
identifier?
5. Weak entity
6. Strong entity
7. ID-dependent entity
02/08/20 DBMS Unit -1 127
25 8. ID- independent entity
Topic- Database Language Objective
1. DDL stands for Data Definition Language. DML stands for Data
Manipulation Language. DDL statements are used to create database,
schema, constraints, users, tables etc. DML statement is used to insert,
update or delete the records.
4. Data Query Language (DQL) is used to fetch the data from the database.
02/08/20 DBMS 12
25 9
DATA BASE
LANGUAGE
02/08/20 DBMS 13
25 0
Data Definition Language
(DDL)
• DDL stands for Data Definition Language. It is used to define
database structure or pattern.
• It is used to create schema, tables, indexes, constraints, etc. in the
database.
• Using the DDL statements, you can create the skeleton of the
database.
• Data definition language is used to store the information of
metadata like the number of tables and schemas, their names,
indexes, columns in each table, constraints, etc.
These commands are used to update the database schema that's why
they come under Data definition language.
02/08/20 DBMS 13
25 2
Data Manipulation Language
(DML)
• DML stands for Data Manipulation Language. It is used for accessing
and manipulating data in a database. It handles user requests.
• Here are some tasks that come under DML:
– Select: It is used to retrieve data from a database.
– Insert: It is used to insert data into a table.
– Update: It is used to update existing data within a table.
– Delete: It is used to delete all records from a table.
– Merge: It performs UPSERT operation, i.e., insert or
update operations.
– Call: It is used to call a structured query language or
a Java subprogram.
– Explain Plan: It has the parameter of explaining data.
– Lock Table: It controls concurrency.
02/08/20 DBMS 13
25 3
Data Control Language (DCL)
02/08/20 DBMS 13
25 4
Transaction Control Language (TCL)
• TCL is used to run the changes made by the DML statement. TCL
can be grouped into a logical transaction.
02/08/20 DBMS 13
25 5
Short Quiz
1. The ability to query data, as well as insert, delete, and alter tuples,
is
offered by
a) TCL (Transaction Control Language)
b) DCL (Data Control Language)
c) DDL (Data Definition Langauge)
d) DML (Data Manipulation Langauge)
02/08/20 DBMS 13
25 6
Topic- Relational Model and SQL Objective
2. One of the major goals of Object relational data model is to close the
gap between relational databases and the object oriented practises
frequently used in many programming languages such as C++, C#, Java
etc.
3. Be able to write SQL statements that edit existing data. Be able to write
SQL statements that create database objects.
8/24/2022
02/08/20 DBMS 53
13
25 7
Relational
Model
02/08/20 DBMS 13
25 8
A Sample Relational Database
02/08/20 DBMS 13
25 9
Properties of Relations
02/08/2025 140
Constraints in Relational Model
• An important concept is that of NULL values, which are used to represent the values of
attributes that may be unknown or may not apply to a tuple. A special value, called NULL, is
used in these cases.
02/08/2025 141
Types of Integrity Constraints
02/08/2025 142
Domain constraints
• Domain constraints can be defined as the definition of a valid set of values for an
attribute.
• The data type of domain includes string, character, integer, time, date, currency,
etc. The value of the attribute must be available in the corresponding domain.
02/08/2025 143
Entity integrity constraints
• The entity integrity constraint states that primary key value can't be null.
• This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those rows.
• A table can contain a null value other than the primary key field.
02/08/2025 144
Referential Integrity Constraints
02/08/2025 145
Key constraints
• Keys are the entity set that is used to identify an entity within its entity set uniquely.
• An entity set can have multiple keys, but out of which one key will be the primary
key. A primary key can contain a unique and null value in the relational table.
02/08/2025 146
Contents
Relational Algebra
02/08/2025 147
Basic of Relational Database
02/08/2025 148
Relational Algebra
The basic set of operations for the relational model is known as the relational
algebra. These operations enable a user to specify basic retrieval requests.
Working of relational Algebra
The result of a retrieval is a new relation, which may have been formed from one or
more relations. The algebra operations thus produce new relations, which can be
further manipulated using operations of the same algebra.
A sequence of relational algebra operations forms a relational algebra expression,
whose result will also be a relation that represents the result of a database query (or
retrieval request).
02/08/2025 149
Importance of Relational Algebra
02/08/2025 150
Query Processing
02/08/2025 151
Relational Query Languages
• Relational query languages use relational algebra to break the user requests and
instruct the DBMS to execute the requests. It is the language by which user
communicates with the database.
02/08/2025 152
Relational Query Languages(Conti…)
Here users tells what data to be retrieved from database and how to retrieve it.
Relational algebra is a procedural query language.
02/08/2025 153
Relational Query Languages(conti…)
02/08/2025 154
Relational Query Languages(conti…)
Note :- I have used word conceptual while describing relational algebra and
relational calculus, because they are theoretical mathematical system or
query language, they are not the practical implementation, SQL is a practical
implementation of relational algebra and relational calculus.
02/08/2025 155
Relational Algebra
02/08/2025 156
Relational Algebra Operations
02/08/2025 157
Basic SQL Relational Algebra Operations
02/08/2025 158
SELECT (σ)
• The SELECT operation is used for selecting a subset of the tuples according to a given
selection condition. Sigma(σ)Symbol denotes it. It is used as an expression to choose
tuples which meet the selection condition. Select operator selects tuples that satisfy a
given predicate.
Notation: σp(r)
where:
• σ is the predicate
• r stands for relation which is the name of the table
• p is prepositional logic
02/08/2025 159
SELECT (σ) Examples
• Example 1:
σ topic = "Database" (Subject)
Output – Selects tuples from Subject where topic = ‘Database’.
• Example 2
σ topic = "Database" and author = “Codd"( Subject)
Output – Selects tuples from Subject where the topic is ‘Database’ and
‘author’ is Codd.
• Example 3
σ sales > 50000 (Customers)
Output – Selects tuples from Customers where sales is greater than
50000
02/08/2025 160
Projection(π)
• The projection eliminates all attributes of the input relation but those
mentioned in the projection list. The projection method defines a relation
that contains a vertical subset of Relation.
• This helps to extract the values of specified attributes to eliminates
duplicate values. (pi) ∏ symbol is used to choose attributes from a relation.
This operator helps you to keep specific columns from a relation and
discards the other columns.
• Notation: ∏ A1, A2, An (r)
• A1, A2, A3 is used as an attribute name of relation r.
02/08/2025 161
Example of Projection
1 Google Active
2 Amazon Active
3 Apple Inactive
4 Alibaba Active
CustomerName Status
Google Active
Amazon Active
Apple Inactive
Alibaba Active
02/08/2025 162
Rename (ρ)
02/08/2025 163
Union operation (υ)
02/08/2025 164
Example of Union
1 1 1 1
1 2 1 3
• A ∪ B gives
column 1 column 2
1 1
1 2
1 3
02/08/2025 165
Set Difference (-)
• The result of set difference operation is tuples, which are present in one relation
but are not in the second relation. – Symbol denotes it.
• The result of A – B, is a relation which includes all tuples that are in A but not in
B.
Notation : r − s
02/08/2025 166
Set Difference (-) Example
Table A Table B
1 1 1 1
1 2 1 3
• Example: A-B
Table A – B
column 1 column 2
1 2
02/08/2025 167
Intersection
02/08/2025 168
Intersection Example
Table A Table B
column 1 column 2 column 1 column 2
1 1 1 1
1 2 1 3
• Example: A ∩ B
Table A ∩ B
column 1 column 2
1 1
02/08/2025 169
Cartesian Product(X) in DBMS
•Cartesian Product in DBMS is an operation used to merge columns from two relations.
Generally, a cartesian product is never a meaningful operation when it performs alone.
However, it becomes meaningful when it is followed by other operations. It is also
called Cross Product or Cross Join.
• σ column 2 = ‘1’ (A X B)
• Output – The above example shows all rows from relation A and B whose column 2
has value 1
σ column 2 = ‘1’ (A X B)
column 1 column 2
1 1
1 1
02/08/2025 170
Cartesian Product(X) Example
• Consider R1 table −
RegNo Branch Section
1 CSE A
2 ECE B
3 CIVIL A
4 IT B
• Table R2
Name RegNo
Bhanu 2
Priya 4
02/08/2025 171
Cartesian Product(X) Example
• R1 X R2
1 CSE A Bhanu 2
1 CSE A Priya 4
2 ECE B Bhanu 2
2 ECE B Priya 4
3 CIVIL A Bhanu 2
3 CIVIL A Priya 4
4 IT B Bhanu 2
4 IT B Priya 4
02/08/2025 172
Join Operations
02/08/2025 173
Join Operations
02/08/2025 174
Inner Join (Theta Join)
• In an inner join, only those tuples that satisfy the matching criteria are included, while
the rest are excluded. Let’s study various types of Inner Joins:
Theta Join:
• The general case of JOIN operation is called a Theta join. It is denoted by symbol θ
Example:- A ⋈θ B
• Theta join can use any conditions in the selection criteria.
• For example:- A ⋈ A.column 2 > B.column 2 (B)
column 1 column 2
1 2
02/08/2025 175
Inner Join ( Equi Join)
EQUI join:
• When a theta join uses only equivalence condition, it becomes a equi join.
column 1 column 2
1 1
02/08/2025 176
Inner Join- Natural Join (⋈)
NATURAL JOIN:
Natural Join does not utilize any of the comparison operators. In this type of join, the
attributes should have the same name and domain.
• In Natural Join, there should be at least one common attribute between two
relations.
02/08/2025 177
Natural Join Example
2 4 2 8
3 9 3 27
• C⋈D
C⋈D
2 4 8
3 9 27
02/08/2025 178
Outer Join
Outer Join:
•An OUTER JOIN doesn’t require each record in the two join tables to have a
matching record. In this type of join, the table retains each record even if no other
matching record exists.
Three types of Outer Joins are:
• Left Outer Join
• Right Outer Join
• Full Outer Join
02/08/2025 179
Left Outer Join (A B)
02/08/2025 180
Left Outer Join Example
Num Square
2 4
3 9
4 16
Num Cube
2 8
3 27
5 125
02/08/2025 181
Left Outer Join Example
• (A B)
(A B)
Num Square Cube
2 4 8
3 9 27
4 16 –
02/08/2025 182
Right Outer Join (A B)
02/08/2025 183
Right Outer Join Example
(A B)
(A B)
2 8 4
3 27 9
5 125 –
02/08/2025 184
Full Outer Join (A B)
• In a FULL OUTER JOIN , all tuples from both relations are included in the result,
irrespective of the matching condition.
• Example:
A B
2 4 8
3 9 27
4 16 –
5 – 125
02/08/2025 185
Relational Algebra Queries
Ques: Let us consider following relational database consisting of four relation schemas :
passenger ( pid, pname, pgender, pcity)
agency ( aid, aname, acity)
flight (fid, fdate, time, src, dest)
booking (pid, aid, fid, fdate)
Write the relational algebra queries for the following expression
1. Get all details of flights scheduled on both dates 01/12/2022 and 02/12/2022 at
16:00.
2. Find the passenger names for passengers who have bookings on at least one flight.
3. Find the pid of passenger who booking every flight.
4. Find the name and city of passenger whose gender is female .
5. Find the name of passenger who booking the flight by ‘MakeMyTrip’ agency.
6. Get the complete details of all flights to New Delhi.
02/08/2025 186
Short Quiz
https://youtu.be/M4qZ5i1LL2o?si=M-YvPZ1Vp9KZK5Kn
https://youtu.be/010_f2HKzJY?si=82Z1Qleud-bBduii
1. https://www.geeksforgeeks.org/last-minute-notes-dbms/
2. https://www.geeksforgeeks.org/quiz-corner-gq/#DBMS%20Mock%20Tests
3. https://www.geeksforgeeks.org/commonly-asked-dbms-interview-
questions/
4. https://www.geeksforgeeks.org/commonly-asked-dbms-interview-
questions-set-2/