18 votes 18 votes Consider the following relational schema: COURSES (cno, cname) STUDENTS (rollno, sname, age, year) REGISTERED_FOR (cno, rollno) 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. Databases gate1994 databases relational-algebra sql normal descriptive + – Kathleen asked Oct 5, 2014 • recategorized Apr 25, 2021 by Lakshman Bhaiya Kathleen 6.4k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply DoctorNandini commented Oct 20, 2019 reply Follow Share 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 1 votes 1 votes aiyyar.aarushi commented Dec 9, 2019 reply Follow Share Is the following query correct? SELECT age, year FROM Students S1, Students S2 WHERE S1.age<=ALL(SELECT age FROM S2 where S1.rollno <> S2.rollno AND S1.year = S2.year) GROUP BY year 0 votes 0 votes SomeEarth commented Jan 28, 2021 reply Follow Share GO PDF correction: Underline are neither in PDF nor in GO-BOOK as well. (Which Highlights the primary key). 1 votes 1 votes Crate_7 commented Jan 23 reply Follow Share SELECT age,year FROM students GROUPBY age HAVING MIN(age) 0 votes 0 votes Please log in or register to add a comment.
Best answer 37 votes 37 votes $π_{rollno}(σ_{cno.}=_{322}$(REGISTERED_FOR)) SELECT year, min(age) FROM STUDENTS GROUP BY year 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). saket nandan answered Jul 1, 2015 • edited Apr 23, 2021 by Lakshman Bhaiya saket nandan comment Share Follow See all 10 Comments See all 10 10 Comments reply mint commented Jan 23, 2017 reply Follow Share Registered For Cno Rno 122 1 322 2 123 3 I have doubt in REGISTERED FOR Table. Cno is primary key, it means a course can be enrolled only by one student?? 1 votes 1 votes Ayush Upadhyaya commented Sep 22, 2017 reply Follow Share The above may be useful. 2 votes 2 votes sid1221 commented Dec 13, 2017 i edited by JAINchiNMay Dec 5, 2022 reply Follow Share ayush so i can write select year ,age from student group by year , having (min (age) ) it will give error ? due to select and group does not have same attribute ? 0 votes 0 votes Salazar commented Mar 12, 2018 reply Follow Share What would be the query if i need "sname,age,year" of the youngest student in each year. i tried below, but this is wrong SELECT SNAME,YEAR,MIN(AGE) FROM STUDENTS GROUP BY YEAR,SNAME; 0 votes 0 votes lakshaysaini2013 commented Aug 9, 2019 reply Follow Share @ Salazar just see this "https://medium.com/@riccardoodone/the-love-hate-relationship-between-select-and-group-by-in-sql-4957b2a70229" 0 votes 0 votes richadwivedi12 commented Oct 8, 2019 reply Follow Share What will be the relational algebra query for (b) 0 votes 0 votes vizzard110 commented Oct 20, 2019 reply Follow Share @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 1 votes 1 votes SomeEarth commented Jan 28, 2021 reply Follow Share What would be the relational Algebra query for option (ii) would look like????? 0 votes 0 votes JAINchiNMay commented Dec 5, 2022 reply Follow Share @SomeEarth . 0 votes 0 votes Arghya Jana commented Apr 12 reply Follow Share For option b is this the correct query?? I am not getting this 0 votes 0 votes Please log in or register to add a comment.
5 votes 5 votes Select S.age,S.year From Student as S Where S.age <= all ( Select E.age From Student as E Where S.year=E.year) Navneet Singh Tomar answered Sep 12, 2019 Navneet Singh Tomar comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes 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. Sunit Kumar answered Sep 12, 2017 Sunit Kumar comment Share Follow See all 3 Comments See all 3 3 Comments reply Puja Mishra commented Jan 19, 2018 reply Follow Share I think ur query is wrong ... it will select those students of every year who is smaller than the age of older student in their respective year ... 0 votes 0 votes Sunit Kumar commented Jan 19, 2018 reply Follow Share what is your answr.? @pujaa 0 votes 0 votes Puja Mishra commented Jan 19, 2018 reply Follow Share Same as best answer .... hav u run that query ?? 0 votes 0 votes Please log in or register to add a comment.