0

I am currently learning database modelling and struggling to model the following requirement. I have a user and sports_club table. User can only join a sports_club if three existing users of the club approve his request. If the number of members in club are less than three then all the existing members (whatever 2, 1 ) need to approve his request. My table looks something like this:

enter image description here

I am struggling to model this approval process in my database? Could anyone help me here? Sports club can have any number of users.

1 Answer 1

1

Add a self-reference to User. Call this reference "approved by". I'd suggest implementing this as a separate table but if you're absolutely sure you'll only ever need three approvers it can be colums in the user table.

As a current member approves an application count the number of approvals, compare it to the number of required approvals, and the number of current members and proceed accordingly. Remember to account for the case where the current applicant is the first to apply to a club.

I think it's an error to make a user exclusive to one club. Wouldn't it be good to know that the same person plays polo, frisbee, netball and Jai-Alai? It would be better to have an intersection table called Membership.

2
  • Yes if the club members are more than three that we need three approvals.
    – python
    Nov 12, 2015 at 1:19
  • If you need three approvals if the number of members of the club are more than 3, otherwise if the the members are less 3, you need approvals from all of them.
    – python
    Nov 12, 2015 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.