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

SQL questions: (2) A relation R(A,B,C,D,E) has exactly four superkeys: CDE, ACDE

ID: 3751640 • Letter: S

Question

SQL questions:

(2) A relation R(A,B,C,D,E) has exactly four superkeys: CDE, ACDE, BCDE and ABCDE. State the canddiate key(s).

(3) It is known that R(A,B,C,D,E) have two candidate keys A and BCDE. How many superkeys are there?

(4) Consider the relation

Enrollment(StudentId, CourseId, InstructorId, Grade).

It stores grades of courses students enrolled in, together with the id of the instructors of the courses. For example, ('S1', 'C101', 'F402', 'A') indicates that the studnet 'S1' has enrolled in the course 'C101', taught by instructor 'F402', and received a grade of 'A'. A student can take many courses but may not have grades yet (semesters not yet completed, for example). A course may have many students but may not have an official instructor.

(a) Can StudentId have a null value?
(b) Can CourseId have a null value?
(c) Can InstructorId have a null value?
(d) Can Grade have a null value?
(e) Show the candidate key(s).

Explanation / Answer

Answer 2:

candidate keys:

Answer 3:

candidate keys: A and BCDE

Any combination of attributes that include those is a super key.

there is a formula for this

Super keys of(A) + Super keys of(BCDE) – Super keys of(ABCDE)
=> 2^(n – 1) + 2^(n – 4) – 2^(n – 5)

where n is no of attributes: n=5

therefore we get,

2^4+2^1-2^0

=17 super keys

Answer 4:

a)No, because studentId represents student and that cannot be null

b)No, because student should have atleast one applied course.

c) No,because student should ahve atleast one instructor for the course.

d)Yes,because studentcan have many cources but may not have grade as semester is not over.

e) candidate keys : (studentId), (studentId courseId instructorId )

Hope you understand the answer, Thank you!