Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Relational Algebra, print all tuples where the project city and parts city

ID: 3885015 • Letter: U

Question

Using Relational Algebra, print all tuples where the project city and parts city are the same when the parts and projects tables are joined together.

Relational Algebra that is used in my class:

() Select
[] Project
* Natural join
- Difference
& Intersection
| Union

parts('pno', 'pname', 'color', 'weight', 'pcity')
=====
('p1', 'Nut', 'Red', '12', 'London')
('p2', 'Bolt', 'Green', '17', 'Paris')
('p3', 'Screw', 'Blue', '17', 'Rome')
('p4', 'Screw', 'Red', '14', 'London')
('p5', 'Cam', 'Blue', '12', 'Paris')
('p6', 'Cog', 'Red', '19', 'London')
('p7', 'Bolt', 'Black', '7', 'New York')
('p8', 'Cam', 'Yellow', '21', 'London')

projects('jno', 'jname', 'jcity')
========
('j1', 'Sorter', 'Paris')
('j2', 'Punch', 'Rome')
('j3', 'Reader', 'Athens')
('j4', 'Console', 'Athens')
('j5', 'Collator', 'London')
('j6', 'Terminal', 'Oslo')
('j7', 'Tape', 'London')
('j8', 'Ruler', 'New York')

suppliers('sno', 'sname', 'status', 'scity')
=========
('s1', 'Smith', '20', 'London')
('s2', 'Jones', '10', 'Paris')
('s3', 'Blake', '30', 'Paris')
('s4', 'Clark', '20', 'London')
('s5', 'Adams', '30', 'Athens')

Explanation / Answer

Result := projects *projects.jcity = parts.pcity parts

actually this is not natural join it is called Theta join

it will print all the tuples where projects.jcity equals to parts.pcity , if you want use project to select custom columns .

for natural join the name jcity in projects and pcity in parts should be equal

ie just change jcity to pcity or vise versa

then u can just call

result := projects * parts

sorry for the mistake

theta join means normal join with condition

you can appley select with normal join

ie

()jcity = pcity projects * parts

i don't familiear with the notation given by you so if there is any error in syntax please comment

and one more if you call projects * parts ie natural join with out common attribute then it will give cartision product as output

so this will work

()jcity = pcity projects * parts

if not please comment

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote