ER Diagram
ER Diagram
Strong entity set always has a It does not have enough attributes
primary key. to build a primary key.
It is represented by a rectangle It is represented by a double
symbol. rectangle symbol.
It contains a Primary key It contains a Partial Key which is
represented by the underline represented by a dashed underline
symbol. symbol.
The member of a strong entity set is The member of a weak entity set
called as dominant entity set. called as a subordinate entity set.
In a weak entity set, it is a
Primary Key is one of its attributes
combination of primary key and
which helps to identify its member.
partial key of the strong entity set.
The relationship between one
In the ER diagram the relationship
strong and a weak entity set shown
between two strong entity set
by using the double diamond
shown by using a diamond symbol.
symbol.
The connecting line of the strong The line connecting the weak entity
entity set with the relationship is set for identifying relationship is
single. double.
ER Diagram Template for Student Enrollment System (Click on the template to edit it online)
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.
σp(r)
σ is the predicate
p is prepositional logic
Example 1
Example 2
Example 3
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.
Example of Projection:
Example
Table A Table B
column 1 column 2 column 1 column 2
1 1 1 1
A ∪ B gives
1 2 1 3
Table A ∪ B
column 1 column 2
1 1
Table A ∪ B
1 2
1 3
ADVERTISING
Example
A-B
Table A – B
column 1 column 2
1 2
Intersection
An intersection is defined by the symbol ∩
A∩B
Defines a relation consisting of a set of all tuple that are in both A and B.
However, A and B must be union-compatible.
Visual
Definition of Intersection
Example:
A ∩ B
Table A ∩ B
column 1 column 2
1 1
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.
Example – Cartesian product
σ 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
Join Operations
Join operation is essentially a cartesian product followed by a selection
criterion.
Types of JOIN:
Inner Joins:
Theta join
EQUI join
Natural join
Outer join:
Inner 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 (B)
A ⋈ A.column 2 > B.column 2 (B)
A.column 2 > B.column 2
column 1 column 2
1 2
EQUI join
When a theta join uses only equivalence condition, it becomes a equi
join.
For example:
⋈
A ⋈ A.column 2 = B.column 2 (B)
A A.column 2 = B.column 2 (B)
column 1 column 2
1 1
EQUI join is the most difficult operations to implement efficiently using
SQL in an RDBMS and one reason why RDBMS have essential
performance problems.
Example
C
Num Square
2 4
3 9
D
Num Cube
2 8
3 27
C ⋈ D
C⋈D
Num Square Cube
2 4 8
3 9 27
OUTER JOIN
In an outer join, along with tuples that satisfy the matching criteria, we
also include some or all tuples that do not match the criteria.
Left Outer Join(A ⟕ B)
In the left outer join, operation allows keeping all tuple in the left
relation. However, if there is no matching tuple is found in right relation,
then the attributes of right relation in the join result are filled with null
values.
A
Num Square
2 4
3 9
4 16
B
Num Cube
2 8
3 18
5 75
A⋈B
A B
In the right outer join, operation allows keeping all tuple in the right
relation. However, if there is no matching tuple is found in the left
relation, then the attributes of the left relation in the join result are filled
with null values.
A⋈B
A B
In a full outer join, all tuples from both relations are included in the
result, irrespective of the matching condition.
A⋈B
A B