Vehicle(VRN, Ma, Mo, Color) , Own(VRN, SSN) , Person (SSN, Name, Addr, Phone) Ve
ID: 3855843 • Letter: V
Question
Vehicle(VRN, Ma, Mo, Color) , Own(VRN, SSN) , Person (SSN, Name, Addr, Phone)
Vehicle
Own
Person
VRN
Ma
Mo
Color
VRN
SSN
SSN
Name
Addr
Phone
123
Honda
Hawk
Red
123
bcd
abc
Dave
Birch
xxx
234
Mazda
RX7
Blue
234
abc
bcd
Mary
Grove
yyy
345
Ford
Taurus
Blue
456
uonakoo
cde
Sriram
Oak
zzz
456
Ford
Ranger Green
567
ghi
def
Fang
Birch
www
567
Honda
Accord Red
683
def
efg
Derek
Elm
uuu
678
Mazda
RX7
Silver
795
abc
uona
Jason
Elm
vvv
789
VW
Bug
White
901
bcd
ghi
Xie
Oak
sss
890
Suzuki
Intruder
Black
789
uona
hij
Gilford
Birch
ttt
901
Harley
Sportster
Black
012
VW
Bug
Red
1. Write a relational algebra query to return all rows (tuples) of Vehicle table in which Ma = ‘Suzuki’
2. Write a relational algebra query to return only the Ma and Mo of Vehicles with Ma = ‘VW’
3. Using the full table of the handout write the result of the query
Vehicle
Own
Person
VRN
Ma
Mo
Color
VRN
SSN
SSN
Name
Addr
Phone
123
Honda
Hawk
Red
123
bcd
abc
Dave
Birch
xxx
234
Mazda
RX7
Blue
234
abc
bcd
Mary
Grove
yyy
345
Ford
Taurus
Blue
456
uonakoo
cde
Sriram
Oak
zzz
456
Ford
Ranger Green
567
ghi
def
Fang
Birch
www
567
Honda
Accord Red
683
def
efg
Derek
Elm
uuu
678
Mazda
RX7
Silver
795
abc
uona
Jason
Elm
vvv
789
VW
Bug
White
901
bcd
ghi
Xie
Oak
sss
890
Suzuki
Intruder
Black
789
uona
hij
Gilford
Birch
ttt
901
Harley
Sportster
Black
012
VW
Bug
Red
TT Ma, SSN ( (Vehicle I own) Color ,Green,Explanation / Answer
Given relations are:
ehicle(VRN, Ma, Mo, Color) ,
Own(VRN, SSN) ,
Person (SSN, Name, Addr, Phone)
Relational algebra query:
Relational algebra is a type of query language in sql, which takes relations as input and yields instances as output by using operators. There are so many operators , but in our question we mainly using select and project operators.
Select Operation ()
select operator is represented by () and selects tuples that satisfy the given condition.
Projection ( ):
It Deletes unwanted columns from relation. That means we vcan select needed columns only.
1. Write a relational algebra query to return all rows (tuples) of Vehicle table in which Ma = ‘Suzuki’
As per given query we need to select touples wich satisfying condition as Ma = ‘Suzuki’.
Ma = "Suzuki"(Vehicle)
Here we are selcting Ma using by giving Ma value as Ma = "Suzuki" from Vehicle.
sql query is:
select * from veicle where Ma = ‘Suzuki’;
2. Write a relational algebra query to return only the Ma and Mo of Vehicles with Ma = ‘VW’
Here we need to specially result only ma and Mo . Hence we are retrieving them using as follows
Ma,Mo(Ma)="VW"(Vehicle)
select Ma,Mo from vehicle where Ma = ‘VW’;
3. As per given relational alzebra query we are selecting Ma,SSN from vehicle and Own tables.
sql quesry for given relational alzebra query is:
select Ma,SSN from Vehicle and Own where Vehicle.VRN=Own.VRN and Own.Color='green';
The result data is
Ma SSN
... .......
Ford uonakoo
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.