Question
Students at your hometown high school have decided to organize their social network using databases. So far, they have collected information about sixteen students in
Students at your hometown high school have decided to organize their social network using databases. So far, they have collected information about sixteen students in four grades, 9-12. Here's the schema:
Q1.) If ID1 and ID2 are friends, then we consider ID1 and ID2 like each other. For a pair of friend (ID1, ID2) in the Friend table, if either the record (ID1, ID2) or (ID2, ID1) is missing in the Likes table, we consider the information on the friend pair (ID1, ID2) is incomplete in the Likes table. Find out all friend pairs with incomplete information in the Likes table, with no duplicates.
Highschooler ( ID, name, grade ) English: There is a high school student with unique ID and a given first name in a certain grade.
Friend ( ID1, ID2 ) English: The student with ID1 is friends with the student with ID2. Friendship is mutual, so if (123, 456) is in the Friend table, so is (456, 123).
Likes ( ID1, ID2 ) English: The student with ID1 likes the student with ID2. Liking someone is not necessarily mutual, so if (123, 456) is in the Likes table, there is no guarantee that (456, 123) is also present.
/* Delete the tables if they already exist */ drop table if exists Highschooler; drop table if exists Friend; drop table if exists Likes; /* Create the schema for our tables */ create table Highschooler(ID int, name text, grade int); create table Friend(ID1 int, ID2 int); create table Likes(ID1 int, ID2 int); /* Populate the tables with our data */ insert into Highschooler values (1510, 'Jordan', 9); insert into Highschooler values (1689, 'Gabriel', 9); insert into Highschooler values (1381, 'Tiffany', 9); insert into Highschooler values (1709, 'Cassandra', 9); insert into Highschooler values (1101, 'Haley', 10); insert into Highschooler values (1782, 'Andrew', 10); insert into Highschooler values (1468, 'Kris', 10); insert into Highschooler values (1641, 'Brittany', 10); insert into Highschooler values (1247, 'Alexis', 11); insert into Highschooler values (1316, 'Austin', 11); insert into Highschooler values (1911, 'Gabriel', 11); insert into Highschooler values (1501, 'Jessica', 11); insert into Highschooler values (1304, 'Jordan', 12); insert into Highschooler values (1025, 'John', 12); insert into Highschooler values (1934, 'Kyle', 12); insert into Highschooler values (1661, 'Logan', 12); insert into Friend values (1510, 1381); insert into Friend values (1510, 1689); insert into Friend values (1689, 1709); insert into Friend values (1381, 1247); insert into Friend values (1709, 1247); insert into Friend values (1689, 1782); insert into Friend values (1782, 1468); insert into Friend values (1782, 1316); insert into Friend values (1782, 1304); insert into Friend values (1468, 1101); insert into Friend values (1468, 1641); insert into Friend values (1101, 1641); insert into Friend values (1247, 1911); insert into Friend values (1247, 1501); insert into Friend values (1911, 1501); insert into Friend values (1501, 1934); insert into Friend values (1316, 1934); insert into Friend values (1934, 1304); insert into Friend values (1304, 1661); insert into Friend values (1661, 1025); insert into Friend select ID2, ID1 from Friend; insert into Likes values(1689, 1709); insert into Likes values(1709, 1689); insert into Likes values(1782, 1709); insert into Likes values(1911, 1247); insert into Likes values(1247, 1468); insert into Likes values(1641, 1468); insert into Likes values(1316, 1304); insert into Likes values(1501, 1934); insert into Likes values(1934, 1501); insert into Likes values(1025, 1101);
Step 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