-1

Table : Class

Here the className is unique

classId| className
-------|---------
    1  |  1st Class   
    2  |  2nd Class
    3  |  3rd Class
    4  |  4th Class

Table: Subject In the Subject table class can have many subjectName but a class can have a unique subjectName

subjectId|classID |subjectName
---------|--------|----------
    1    |    1   | English   
    2    |    1   | Maths
    3    |    1   | Social
    4    |    1   | Sports    
    5    |    2   | English  
    5    |    2   | Maths
    5    |    2   | Social
    5    |    2   | Sports

Table: Lesson

In the Lesson table many lessons can be added to a subjectID

lessonId |classID | subjectID| lessonName
---------|--------|----------|------------
    1    |  1     |   1      | Lesson 1 -The Art
    2    |  1     |   1      | Lesson 2- The soup
    3    |  1     |   2      | Lesson 1- Algebra 
    4    |  1     |   2      | Lesson 2 - Addittion

my question is should i add classID in lesson table because classID is already know because of subjectID in Subject table. Is adding classID in Lesson table is redundancy? is subjectID enough in **lesson** table? what is the good practise?

Table : Video

Similarly i have Video table which is related to lessonID. a user can add multiple video by selecting lesson.

videoId  |lessonId |classId | subjectId| VideoName
---------|-------- |--------|----------| ----------

My problem is same here as Lesson table. videoID is referenced to lessonID. here also should we add classID and subjectID? because by lessonID we can identify subjectId from Subject table and by subjectId we can identify classID from Class table. is adding classID and subjectId in video table is redundancy?

I am asking this question for best practises.

1

Redundancy is usually a no-no. Try to avoid it.

Think of your universe in terms of "Entities". Model an Entity in a database "table". Then design the "Relationships" between them.

You seem to have 4 Subjects, not 8.

Consider a many-to-many mapping table between the 4 Classes and the 4 Subjects.

I am not clear on the concept of Lesson, instead let me develop how to think of it:

  • How many different Lessons are there? That is how many rows to have in the Lessons table.
  • How is a "lesson" related to a "subject and/or a "class".
  • For "many-to-many", make another table.
  • For "one-to-many", simply have an id in one table for JOINing to the other table.

That is, "Relationships" are modeled as many:many or 1:many, as mentioned above.

Once you have done all of that, there is nothing further to do for "normalization".

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.