TarikAli's avatar

Main Table with more many to many tables

i have

courses table

courses_types : every course has many types

courses_times : every course has many times

courses_genders : every course has many genders

the price of the course depends on type , time , gender

course01, gender01, type01 has price

course01, gender02, type01 has price

course01, gender01, type02 has price

and so on

where to put the price field

where to put the price

0 likes
3 replies
SilenceBringer's avatar
Level 56

you can make the model like CourseOption (or CourseVariant, or something similar) with the fields:

  • id
  • course_id
  • gender_id
  • type_id
  • price
  • ... //timestamps and others
1 like
TarikAli's avatar

@SilenceBringer Ok and in this case will delete the other tables ? just this table will take the whole relations ?

SilenceBringer's avatar

@TarikAli I do not know the whole your application, but for now it looks 1 new table will be enough instead of a lot of pivots

Please or to participate in this conversation.