Consider the following relational schema:
The underlined attributes indicate the primary keys for the relations. The ‘year’ attribute for the STUDENTS relation indicates the year in which the student is currently studying (First year, Second year etc.)
Write a relational algebra query to print the roll number of students who have registered for cno $322.$
Write a SQL query to print the age and year of the youngest student in each year.
Proper underlines according to official question paper:
COURSES(cno, cname)
STUDENTS(rollno, sname, age, year)
REGISTERED_FOR(cno, rollno)
source : https://drive.google.com/file/d/0By-VZ5fZo_6iNHhYNW5QYXZFUVE/view
In the second question we have to find the year and youngest student from that year. So, we have to apply MIN aggregate function on each year (group by year).
@richadwivedi12 We can find the relational algebra query for (b). Below is my approach
I assumed that we know the distinct year in advance.
We then calculate the minimum age for each year and then we union all of them to get the result.
If you something better please tell
@SomeEarth .
1). (a)πroll_no.(σcno.=322(registered for))
2.) select age , year from student s1 where not exists(select s2.age from student s2 where s2.age > s1.age) group by year.
64.3k questions
77.9k answers
244k comments
80.0k users