Given the following relational database schema:
Student = (SSN, Name, Major)
Course = ( CourseNumber , CourseTitle, NumberOfUnits, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00.
Enrollment = (SSN , CourseNumber, Grade)
Express the following queries using SQL statements with minimum number of tables and operations.
a. List the SSN and Name of every student who has no grade in at least one course.
b. List the name of every student who enrolled in at least two courses.
c. List the name of every student who hasn’t taken any course.
d. List the SSN and the name of every student who does not have a grade in any course, i.e all her or his grades are null
e. List the SSN and Name of all students who do not have the grade A in any course.
Answer)
a.
select SSN, Name from Student where SSN in (
select distinct SSN from Enrollment where Grade is null
);
b.
select Name from Student inner join Enrollment on Student.SSN =
Enrollment.SSN
group by Student.SSN having count(Enrollment.CourseNumber) >
1;
c.
select Name from Student where SSN not in (
select distinct SSN from Enrollment
);
d.
select SSN, Name from Student where SSN in (
select distinct SSN from Enrollment where Grade is null
);
e.
select SSN, Name from Student where SSN not in (
select distinct SSN from Enrollment where Grade = 'A'
);
**Please Hit Like if you appreciate my answer. For further doubts on the question or answer please drop a comment, I'll be happy to help. Thanks for posting.**
Given the following relational database schema: Student = (SSN, Name, Major) Course = ( CourseNumber ,...
Given the following relational database schema: Student = (SSN, Name, Major) Course = ( CourseNumber , CourseTitle, NumberOfUnits, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00. Enrollment = (SSN , CourseNumber, Grade) Express the following queries using AQL statements with minimum number of tables and operations. List the name of every student whose name starts with the letter S and ends with the letter M, and has earned the grade B in at least one course.
Student = (SSN, Name, Major) Course = ( CourseNumber, PrerequisiteCourseNumber, Course Title, NumberUnits) Section = ( CourseNumber, Quarter, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00PM. Enrollment = (SSN,CourseNumber, Quarter, Grade)// Grade is either Null or a letter grade. Express the following queries using appropriate SQL statements with a minimum number of operations: 1. List every two CourseNumber and their titles which have the same prerequisites. 2. List the name of every student and SSN who has completed...
Please do these carefully. Student = (SSN, Name, Major) Course = ( CourseNumber, PrerequisiteCourseNumber, Course Title, NumberUnits) Section = ( CourseNumber, Quarter, RoomNumber, DayTime), where DayTime is of the form MW 1:0-2:00PM. Enrollment = (SSN,CourseNumber, Quarter, Grade)// Grade is either Null or a letter grade. Express the following queries using appropriate SQL statements with a minimum number of operations: 1. List the name of every student and SSN who has not taken any course more than once. 2. List every...
You are given the following relational schema (keys bolded): Employee(SSN, Name) Faculty(SSN) (Faculty(SSN) references Employee(SSN)) Staff(SSN, ManagerSSN) (Staff(SSN) references Employee(SSN); Staff(ManagerSSN) references Staff(SSN)) Student(PersonNo, Name) Course(CourseNo, Title) Offering(CourseNo, Semester, InstructorSSN, Credit) (Offering(CourseNo) references Courses(CourseNo); Offering(InstructorSSN) references Faculty(SSN)) Enrolls(CourseNo, Semester, PersonNo, Grade) (Enrolls(CourseNo, Semester) references Offering(CourseNo, Semester); Enrolls(PersonNo) references Student(PersonNo)) ---------------------------------------------------------------------------------------------------- Decompile the above schema into an E-R schema representing the same information.
(Taken from Exercise 5.15) Consider the following relations for a database that keeps track of student enrollment in courses and the books adopted for each course: STUDENT(SSN, Name, Major, Bdate) COURSE(Course#, Cname, Dept) ENROLL(SSN, Course#, Quarter, Grade) BOOK_ADOPTION(Course#, Quarter, Book_ISBN) TEXT(Book_ISBN, Book_Title, Publisher, Author) Draw a relational schema diagram specifying the foreign keys for this schema.
Can someone please help me solve the following database management
question a - d please help
uestion-4 The relational database schema of Question-3 is reproduced here. COURSE (NUMBER, TITLE, ENROLLED) RANK-1 (CNUMBER, R1-SSN) RANK-2 (CNUMBER, R2-SSN) TALLEST (CNUMBER, TALL-SSN) STUDENT (SSN, NAME, MAJOR, SEX, GPA) Formulate the following queries in soL. (30] (a) List the course numbers in which "Jack Hernandez" is the first ranked student. You are not allowed to use any JOIN operation and your answer must be...
1. Consider the following database. Note that it distinguishes between a course and the class of that course in a particular year. Courses can have prerequisites (aka a prereq), which is again a course. Person(UPI, givenname, surname) with key UPI Courses(course, title, program) with key course Classes(classnr, course, year) with key classnr Enrollments(UPI, classnr) Grades(UPI, classnr, grade) Prereqs(course, prereq) Teachers(UPI, classnr) With natural foreign key constraints given by common attribute names. 1. List all UPIs of all teachers who teach...
2. Consider the following database and answer the questions below SPORT ENROLLMENT STUDENT COURSE ST ST TITLE 313 1313 50s0 Basketbal 8989 Basketbal 007 COMP203A 7007 COMP20e 007 ames Bond 302 Database Systems COMP203 Computer Or n Brown 00 CoMP302 A o0 3un SmuCOMP42daedDatabase Systems 3 13 COMP 209 70 5050 Susan Smith COMP447 nced Database S 1313 COMP2O3A 1313 COMP302 5050 COMP20 C 1313 COMP42 7007 Write the SQL statement that displays the names of the students who have...
Give the following queries in the relational algebra using the following relational schema: Student (sid, name, age, address, email, cgpa) enrolledIn (sid, modulecode, grade) module (modulecode, modulename, credits, lecturername) a) What are the names of students enrolled in module code “cs3020”? b) Give the module code of all the modules that are taught by the teacher named “Altaf”? c) Who teaches the module with code”cs1500”? d) Give the name of all the teachers teaching the student with id”12f6778”.