Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1: Consider a database design with two relations Emp(Name, DName, Salary) and D

ID: 3548789 • Letter: Q

Question

Q1: Consider a database design with two relations Emp(Name, DName, Salary) and Dept(DName , MName).

Name value as an employee, Dname value as a department and MName as a manager.

Write a create table statement for the Dept table.


A) A department has one manager who is an employee. Name is the primary key in Emp.

B) A department has one manager who is an employee. Name is not the primary key in Emp.


Q2: Express the following SQL queries.

      List tuples with pairs of names of students who have the same mentors.

Person (Name, ID,   Address, DOB)

Instructor   (InstructorID, Rank, Salary)

Student (StudentID,   Classification, GPA, MentorID, CreditHours)

Course (CourseCode,   CourseName, PreReq)

Offering (CourseCode,   SectionNo, InstructorID)

Enrollment   (CourseCode, SectionNo, StudentID,   Grade)

Explanation / Answer

1)A) create table dept(dname varchar(20),mname varchar(20) as foreign key references emp(name));

B) create table dept(dname varchar(20),mname varchar(20) as candidate key);

2) select p.name,p.id,s.mentorID from person p,student s where p.id=student.studentID group by s.mentorID ;