I have a case to make a student course, which also contains schedules for students. And I making a schedule model with Flask-SQLAlchemy and use PostgreSQL as its database.
here is the snippet of my current code:
class DayNameList(enum.Enum):
Sunday = 'Sunday'
Monday = 'Monday'
Tuesday = 'Tuesday'
Wednesday = 'Wednesday'
Thursday = 'Thursday'
Friday = 'Friday'
Saturday = 'Saturday'
def __str__(self):
return self.value
class Schedule(db.Model):
__tablename__ = 'schedule'
id = db.Column(db.Integer, primary_key=True)
schedule_day = db.Column(db.Enum(DayNameList, name='schedule_day'))
start_at = db.Column(db.Time())
end_at = db.Column(db.Time())
# ...
# ...
In my case there is two schedule day for each week for students.
In my current code, the schedule_day column is an Enum type.
So, my questions are, should I making the schedule_day to be an ARRAY Enum ..?, if so how about the start_at and end_at column..?, should I also convert its to ARRAY..? and any example how to do that..?
Or should I add a new column, i.e schedule_day_2 or what..?
What is the best practice..? Any help would be appreciate, Thanks :)