0

So I'm using Python/Django to build a truffle-hunting app and I'm using the Django ORM to define my PostgreSQL database.

One thing I would like to do is permit users to schedule the behavior of robots that hunt for truffles in the forest.

I can turn these robots on or off with no problem, but what I want to do now is enable the user to set up schedules -- for instance, perhaps a user only wants his truffle-robot to go truffle-hunting on Wednesdays, or on the third Thursday after every other full moon, or every day, but only between the hours of 1 - 6 AM, etc.

Assume I already have a table called TruffleRobot that contains the TruffleRobotID, the kind of truffles it is designed to scout for, the digging method it employs, etc.

class TruffleRobot(models.Model):
    id              = models.CharField(max_length=20, primary_key=True)
    target_truffles = models.ForeignKey(TruffleType, null=False)
    digging_method  = models.ForeignKey(DiggingMethod, null=False)
    color           = models.CharField(max_length=20)

I now want to be able to define truffle-hunting schedules in a TruffleHuntingSchedule table and then easily switch the schedule that a truffle-robot adheres to.

So I suppose I will add a column called 'truffle_hunting_schedule' to my TruffleRobot table and this column will be a foreign key specifying a schedule as laid out in my TruffleHuntingSchedule table. So this robot should be able to tell whether it should go hunting or not by querying its hunting schedule.

My problem is that I'm not sure how to define this 'TruffleHuntingSchedule' table. Any suggestions?

class TruffleHuntingSchedule(models.Model):
    hunting_schedule_id = models.CharField(max_length=20, primary_key=True)
    what_about_mondays  = models.SomeField()
    how_about_tuesday   = models.SomeField()
    next_is_wednesday   = models.SomeField()
    can_i_hunt_before_noon = models.SomeField()
    etc
tadasajon
  • 14,276
  • 29
  • 92
  • 144

1 Answers1

0

My suggestion would be to keep it simple. Too many options confuse users. Having said that, here is a post regarding designing scheduling related tables.

Community
  • 1
  • 1