Consider the following relations from a Richfield database. Write relational algebra expression for each statement using symbolic notations.
Books (bid, title, publisher, year)
Students (sid, sname, major, age)
Authors (aid, aname, aaddress)
Borrows (bid, sid, date)
2.2.1 List the title & year of each book. (2)
2.2.2 Find all information about students whose major is Java. (2)
2.2.3 List all students with the books they can borrow. (2)
2.2.4 Obtain all the books published by McGraw-Hill before 2019. (2)
2.2.5 Rename aname in the relation Authors to name.
i)
List the title & year of each book.
select title,year from book;
"\\pi_{(title,year)}Book"
ii)
Find all information about students whose major is Java.
select * from Students where major='java';
"\\sigma_{(major='java')}Student"
iii)
List all students with the books they can borrow.
select s.id,b.id from student as s, borrow as b
where s.id=b.id;
"STUDENTS \\times BOOKS"
iv)
Obtain all the books published by McGraw-Hill before 2019.
select * from books where publisher='McGraw-Hill' and year=1990
"\\sigma_{(publisher='McGraw-Hill' \\wedge year='1990')}(Books)"
v)
Rename a name in the relation Authors to name.
"\\rho_{(Authors(Name,Address))}(AUTHORS)"
Comments
Leave a comment