This is a Databases question regarding Relational Algebra You are given four tab
ID: 3876329 • Letter: T
Question
This is a Databases question regarding Relational Algebra
You are given four tables:
----
Painting (paintingId, title, artistId, year)
Artist (artistId, name, phone, country)
PaintingsForSale (paintingId,price)
Museum (museumId, museumName, city, country)
Exhibits (paintingId, musemId, fromDate, toDate)
----
Now write queries using relational algebra (you may only use cartesian product (X), selection (), projection (), natural join (), and theta join..) for:
1. Show the title and year of each painting.
2. Show the artist names from country, “USA”.
3. Show the titles of the paintings that had year before 1998.
4. Show the museum names in UK that are showing the painting with id “P1”
5. Show the titles of the paintings, artist names and museum names and countries where they are exhibited.
6. Show the titles of the paintings and years by artist, “A.Smith”
7. Show the title of the oldest painting.
8. Show the tiles and the artist names of the paintings with “watercolor” medium.
9. Show the names of museums with no exhibits.
10. Show the title of the painting with the highest price.
Explanation / Answer
1) select title, year from Painting;
2) select name from Artist where country="USA";
3) select title from Painting where year<1998;
4) select m.museumName from Museum as m, Exhibits as e where m.country="UK" and e.musemId=m.museumId;
5) select p.title, a.name, m.name, m.country from Painting as p, Museum as m, Exhibits as e, Artist as a where p.artistId=a.artistId and p.paintingId=e.paintingId and m.museumId=e.musemId;
6) select p.title, p.year from Painting as p, Artist as a where p.artistId=a.artistId and a.name="A.Smith" ;
7) select title from Painting Order By year ASC LIMIT 1 ;
8) select p.title, a.name from Painting as p, Artist as a where p.title LIKE "watercolor" ;
9) select m.name from Museum as m where m.name NOT IN (select mu.name from museum as mu, Exhibits as e where mu.museumId=e.museumId) ;
10) select p.title from Painting as p, PaintingsForSale as pfs where p.paintingId=pfs.paintingId Order By pfs.price DESC LIMIT 1 ;
IN CASE OF ANY DOUBT, PLEASE LET ME KNOW IN THE COMMENTS SECTION.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.