1
Good afternoon guys I’m doing the following exercise but I’m in doubt whether I did it right or not, could you take a look?
Write the SQL queries according to the database schema present below.
a. Select the year, semester and the name of the courses taught by [João Setubal].
b. Select the AR and the names of the [Jacques Wainer] students who attended the [Evolutionary Algorithms] course in the semester [1] between the years [2008] and [2010].
Student - (ra, student_name, admission_year, birth_date)
Course - (id, professor_name, course_name, year, semester)
Disciplina - (id, course:id, student:ra, grade_a, grade_b)
a. SELECT year semester course_name FROM Course WHERE professor_name = “João Setubal”
b. SELECT t1.ra, t1.student_name
FROM Student t1
INNER JOIN Disciplina t3 ON (t1.ra = t3.student:ra)
INNER JOIN Course t2 ON (t2.id = t3.course:id)
WHERE t2.professor_name = “Jacques Wainer”
AND t2.course_name = “Evolutionary Algorithms”
AND t2.semester = 1
AND t2.year BETWEEN 2008 AND 2010
Hello, the best way to know if you are right is to create the tables, pollute with data that meet and that do not meet your search and run your selects. Good luck PS: Apparent is correct
– Gê Bender
You can use the Sqlfiddle to test sql.
– ramaral