Question
Need help with these two questions, desired output: The questions: Create Tables: CREATE TABLE likes ( student varchar(50), professor varchar(50) ); CREATE TABLE enrolls (
Need help with these two questions, desired output:
The questions:
Create Tables:
CREATE TABLE likes ( student varchar(50), professor varchar(50) );
CREATE TABLE enrolls ( student varchar(50), course varchar(50) );
CREATE TABLE teaches ( professor varchar(50), course varchar(50) );
-- load table
insert into likes(student,professor) values ('s1', 'Einstein'); insert into likes(student,professor) values ('s1', 'Feynman'); insert into likes(student,professor) values ('s2', 'Einstein'); insert into likes(student,professor) values ('s2', 'Feynman'); insert into likes(student,professor) values ('s3', 'Einstein'); insert into likes(student,professor) values ('s4', 'Einstein'); insert into likes(student,professor) values ('s6', 'Feynman'); insert into likes(student,professor) values ('s8', 'Feynman'); insert into likes(student,professor) values ('s11', 'p41'); insert into likes(student,professor) values ('s11', 'p42'); insert into likes(student,professor) values ('s12', 'p41');
insert into enrolls(student,course) values ('s1', 'c1'); insert into enrolls(student,course) values ('s1', 'c2'); insert into enrolls(student,course) values ('s2', 'c2'); insert into enrolls(student,course) values ('s1', 'c3'); insert into enrolls(student,course) values ('s4', 'c4'); insert into enrolls(student,course) values ('s5', 'c4'); insert into enrolls(student,course) values ('s6', 'c5'); insert into enrolls(student,course) values ('s7', 'c5'); insert into enrolls(student,course) values ('s8', 'c5'); insert into enrolls(student,course) values ('s9', 'c5'); insert into enrolls(student,course) values ('s10', 'c5'); insert into enrolls(student,course) values ('s11', 'c41'); insert into enrolls(student,course) values ('s11', 'c42'); insert into enrolls(student,course) values ('s12', 'c41'); insert into enrolls(student,course) values ('s12', 'c42');
insert into teaches(professor,course) values ('Einstein', 'c4'); insert into teaches(professor,course) values ('Einstein', 'c5'); insert into teaches(professor,course) values ('Einstein', 'c6'); insert into teaches(professor,course) values ('Feynman', 'c4'); insert into teaches(professor,course) values ('Feynman', 'c5'); insert into teaches(professor,course) values ('Feynman', 'c7'); insert into teaches(professor,course) values ('p41', 'c41'); insert into teaches(professor,course) values ('p42', 'c42');
27 find all students that enrolled in some course taught by some professor that they don't like student s9 s 8 s5 s7 s6 s10 s4 s12 (8 rows) Q8 * find all students that enrolled in some course taught only by professors that they don't like */ student s9 s5 s7 s10 s12 (5 rows) 1. Create a database in PostgreSQL named courses. 2. The database will contain three relations with the schema: Likes (student, professor) Enrolls (student, course) Teaches (professor, course) teaches professor enrolls student course course likes student professor Q7 Find all students that enrolled in some course taught by some professor that they don't like. Q8 Find all students that enrolled in some course taught only by professors that they don't like. 27 find all students that enrolled in some course taught by some professor that they don't like student s9 s 8 s5 s7 s6 s10 s4 s12 (8 rows) Q8 * find all students that enrolled in some course taught only by professors that they don't like */ student s9 s5 s7 s10 s12 (5 rows) 1. Create a database in PostgreSQL named courses. 2. The database will contain three relations with the schema: Likes (student, professor) Enrolls (student, course) Teaches (professor, course) teaches professor enrolls student course course likes student professor Q7 Find all students that enrolled in some course taught by some professor that they don't like. Q8 Find all students that enrolled in some course taught only by professors that they don't likeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started