Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with these questions. Completely stuck. 1. Create a database in PostgreSQL named courses. 2. The database will contain three relations with the schema:

Need help with these questions. Completely stuck.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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 course enrolls student course likes student professor Q5 Find all students that enrolled in only courses taught by professors that they like. 06 Find all students that enrolled in some course taught only by professors that they like. 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. 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 ('sl', 'Einstein'); insert into likes (student, professor) values ('sl', 'Feynman'); insert into likes (student, professor) values ('52', 'Einstein'); insert into likes (student, professor) values ('52', 'Feynman'); insert into likes (student, professor) values ('53', 'Einstein'); insert into likes (student, professor) values ('s', 'Einstein'); insert into likes (student, professor) values ('56', 'Feynman'); insert into likes (student, professor) values ('58', 'Feynman'); insert into likes (student, professor) values ('s11', 'p41'); insert into likes (student, professor) values ('511', 'p42'); insert into likes (student, professor) values ('s12', 'p41'); insert into enrolls(student, course) values ('sl', 'c1'); insert into enrolls(student, course) values ('sl', 'c2'); insert into enrolls (student, course) values ('52', 'c2'); insert into enrolls (student, course) values ('sl', 'c3'); insert into enrolls(student, course) values ('54', 'c4'); insert into enrolls (student, course) values ('55', '64'); insert into enrolls (student, course) values ('56', 'c5'); insert into enrolls (student, course) values ('s7', 'c5'); insert into enrolls(student, course) values ('58', 'c5'); insert into enrolls(student, course) values ('59', 'c5'); insert into enrolls(student, course) values ('310', 'c5'); insert into enrolls(student, course) values ('s11', '641'); insert into enrolls(student, course) values ('s11', '642'); insert into enrolls (student, course) values ('812', 'c41'); insert into enrolls (student, course) values ('512', 'c42'); I 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')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

More Books

Students also viewed these Databases questions

Question

Explain the LAMP framework.

Answered: 1 week ago

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

Know what customers expect from the firm when they complain.

Answered: 1 week ago

Question

Understand why customers complain.

Answered: 1 week ago