DBMS Unit-4 (2)
DBMS Unit-4 (2)
Prepared By:
Dr. Aayushi Chaudhari
Assistant Professor, CE, CSPIT,
CHARUSAT
2. Projection (π):
Denition: Selects specific columns from a relation.
Notation: π_column1, column2,…(R)
Example: π_name, phone_no(STUDENT), retrieves only the names and phone
numbers of students.
Where p is a formula in propositional calculus consisting of terms connected by : ∧ (and), ∨ (or), ¬ (not)
Each term is one of:
<attribute> op <attribute> or <constant>
where op is one of: =, ≠, >, ≥, <, ≤
• Example of selection:
σ dept_name=“Physics”(instructor)
• Example: to find all courses taught in the Fall 2009 semester, but not in the Spring 2010 semester
• Notation r x s
• Defined as:
r x s = {t q | t ∈ r and q ∈ s}
• Assume that attributes of r(R) and s(S) are disjoint. (That is, R ∩ S = ∅).
• If attributes of r(R) and s(S) are not disjoint, then renaming must be used.
p2 p2 p1
s1 p1 p4 p2
s1 p2 p4
s1 p3
s1 p4
s2 p1
s2 p2
s3 p2 sno
s4 p2
s4 p4 s1 sno
s2 sno
s3 s1
s4 s4 s1
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)
Aisha Arora Raj Kumar Aisha Arora Makku Singh Aisha Arora
Raju Chopra
Raju Chopra Karan Rao
Raj Kumar
Honey Chand
Karan Rao
Saurabh
{t | ∃ s ∈ borrower(t[customer-name] = s[customer-name]
∧ ∃ u ∈ loan(u[branch-name] = “ABC” ∧ u[loan-number] = s[loan-number]))}
9 January 2025| U & P U. Patel Department of Computer Engineering 42
Universal Quantification
• Find all students who have taken all courses offered in the Biology department
• {t | ∃ r ∈ student (t [ID] = r [ID]) ∧
(∀ u ∈ course (u [dept_name]=“Biology” ⇒
∃ s ∈ takes (t [ID] = s [ID ] ∧
s [course_id] = u [course_id]))}
L10 Sub 90
L08 Main 60
Find the loan number, branch, amount of loans of greater than or equal to 100 amount.
{≺l, b, a≻ | ≺l, b, a≻ ∈ loan ∧ (a ≥ 100)} Loan number Branch name Amount
Find the names of all customers having a loan at the “Main” branch and find the loan amount.
{≺c, a≻ | ∃ l (≺c, l≻ ∈ borrower ∧ ∃ b (≺l, b, a≻ ∈ loan ∧ (b = “Main”)))}
Customer Name Amount
Ritu 200
Debomit 60
Soumya 150