Assessing the normal form for a relation with a multi-valued attribute

database-designdependenciesnormalizationrelational-theory

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.

Best Answer

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))