2

Assume that you have designed the following schema of relations:

  • COURSES (CID, CNAME)
  • STUDENTS(SID, SNAME, FAV_CIDS)

However, you can not have a relation with set valued attributes (Did not really understand what was meant by this) and you need to convert it to a normal form. What is the normal form and the resulting schema?

We are studying SQL at school. Could not really make out which normal form this was in and functional dependencies.

  • 2
    Hint: Take a closer look at FAV_CIDS. – sticky bit May 7 '18 at 14:55
  • Yoy may find this answer of help. – MDCCL May 7 '18 at 15:17
0

You first need to know what's the relationship between those two entities: Courses and Students. But, you also need to know the abstraction of those entities into your database schema; we all know that a Student could be enrolled in many Courses, and a Course could contain many Students. The relationship between them are many-to-many.

The way to enforce a many-to-many relationship is by creating a table apart that will store as Foreign Keys the Students, and Courses Primary Keys. Both foreign keys will compound the table's primary key. This will gives to you the flexibility to store many courses, and many students.

However, check below how the tables should look like:

  • Courses(CourseId (PK), CourseName)
  • Students(StudentId (PK), StudentName)
  • StudentsCourses(StudentId (FK)(PK), CourseId (FK)(PK))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.