"rkc" <rk*@yabba.dabba.do.rochester.rr.nope> wrote in message
news:o8****************@twister.nyroc.rr.com...
"Stewart Allen" <sa****@ThisPartNotVailid.wave.co.nz> wrote in message
news:bu**********@news.wave.co.nz...
Membership is an intermediate table between Member and Group so there's
a many to many relationship between the two. The rate is assigned to the group which includes the duration of the amount the group pays and the total
amount of members at that time.
I have a couple of question regarding this.
How do you store the duration when they're still enrolled? e.g.
MemID FName LName
1 Joe Smith
2 Sue Smith
3 Fred Smith
All belong tho the same family so special rates apply.
Joe joined first and the rate is $20.00 per period. Sue joins 2 months
later and now that rate is $30.00 for both of them. Fred joins 3 months later
and now the rate is $40.00 for all three of them. 1 month later Sue leaves
so the rate reduces back down to $30.00. Joe and Fred are still enrolled at
the club so how do you store the duration if the membership is still
current? If Joe started 1 year back and the payment periods are monthly, the total
amount that this family is supposed to have paid is $350.00. After 1
more month of membership the total due is $380.00.
With my example above and the Membership table having 2 FKs to create
the PK, what happens when the case arises when Sue leaves or is the
StartDate a FK too?
First, the Group table doesn't need the RateID. It's retrieved from the
Rate table
on an individual basis.
My thought was that the Membership table would track one membership period
for one member. The GroupId would be used to count the number of members
in that group at the time the fee is paid. Every member would be in a
group, even
if that member is the only person in the group. The fee would be based on
the number of people in the Group and the duration of the membership. The
amount due would be taken from the Rate table based on the number of
members and the length of time signed up for.
So when Joe comes in to sign up for another month on 2/1/2004 Sue's
membership that expired on 1/1/2004 isn't counted.
Something like
SELECT Count(*) as NumberOfMembers
FROM MemberShip
WHERE GroupID = [Joe's Group ID]
AND EndDate > [Sign up Date]
AND MemberID <> [Joe's Member ID]
Thanks rkc. I'll have a good look at this and see if I can modify what I've
done.
Here's my current table structure:
**tblMembers**
MemberID (PK)
FamilyID (FK) from table FamilyNames
FName
LName
etc
**tblFamilyNames**
FamilyID (PK)
FamilyName
**tblMembership**
MemberID (FK) from tblMembers
MemTypeID (FK) from tblMembershipTypes
StartDate
EndDate
The first 3 fields combine to create a primary key
**tblFamilyRates**
RateID (PK)
FamilyID (FK) from tblFamilyNames
Rate
StartDate
EndDate
**tblMembershipTypes**
MemTypeID (PK)
MemType
**tblFeesPaid**
FeesID (PK)
FamilyID (FK) from tblFamilyNames
DatePaid
AmountPaid
ReceiptNo
**Relationships**
tblFamilyNames 1-M tblMembers
tblFamilyNames 1-M tblFamilyRates
tblFamilyNames 1-M tblFeesPaid
tblMembers 1-M tblMembership
tblMembershipTypes 1-M tblMembership
The FamilyRates table records what that family is supposed to pay at any
given period of time. If the EndDate is null in a record that means that
this is the family's current rate. Whenever somebody of this family enrols
or leaves, this table is updated with the EndDate field completed and a new
record created with the new Rate and StartDate. This table doesn't get
touched again until the number of members in this family changes again.
The Membership table records when a member joins and quits. It's on the many
side of the Members because they sometimes rejoins so this needs to be
recorded. If the EndDate field is null, it means that the member is still
enrolled.
When somebody joins they're assigned to an existing family or a new family
is created if they haven't got any brothers/sisters etc that are already
enrolled. Dev's fConcatChild function is used to link all family members
together. This way it's the family that pays the fees not the individual
even if there is only one person that belongs to that family.
What I forgot to mention in my original post was that some families don't
pay on time, maybe miss a couple of payments over 6 months and then start
paying regularly again. It may seem that they're up to date because they're
paying regularly but they are behind.
Finding out the total a family has paid is easy and also the total number of
family members enrolled at any given time period is also easy. What I'm
after is to find out how much the family is supposed to have paid from the
time the first member joined to now when other members of the family have
joined and left which effects how much the family pays at that period of
time. e.g. $20.00 for 1, $30.00 for 2, $40.00 for 3.
Is my table design correct? I'll redesign the whole database if necessary.
Stewart