Reputation: 375
I have the following database so far:
Person model
Student model inherits from Person, no added functionality
Lecturer model same as Student
Course model
leader = ForeignKey to Lecturer (1 Lecturer can have many courses)
students = ManytoMany with Student (Many students can take many courses)
Card model
student = OneToOne with student (1 card per 1 student).
Event model
course = ForeignKey to Course (One course can have many events)
Now my question is; I want to mark students present in an event based on the following criteria. On creation of Event, marked students need to be empty. Later I will create a view that will register a Card ID. The Card model has a 1-1 relationship with student. Student is many-many with Course. Course is a FK to Event.
How do I go about doing this?
Upvotes: 2
Views: 144
Reputation: 12571
If it were me, I might use a dedicated Attendance table (something like the following):
class Attendance(Model):
student = models.ForeignKey('Student')
event = models.ForeignKey('Event')
present = models.BooleanField(default=True)
You could swap out the student field for a Card instead, if that's what you desire (but since it's a one-to-one, it doesn't really matter). The default value for the present
field could also be swapped, depending on how you want to treat entries in this table.
Upvotes: 1