For every exchange, we need to know who the participants and administrators
are; this links the tables
exchanges and
members. We'll call this table
participants.
participants
| exchange_id |
member_id |
role |
| 1001 |
4 |
member |
| 1001 |
8 |
admin |
| 1001 |
20 |
admin |
| 1012 |
4 |
both |
| 1012 |
31 |
member |
This table links a member (via
member_id)
to a gift exchange (via
exchange_id) and
denotes their role in the exchange;
role
can be one of
member,
admin, or
both. An administrator of an exchange is
someone who can see who is assigned to give a gift to whom; usually this
person is not a participant, but the option exists to allow this.
We want it to be possible for the administrator of a gift exchange to invite
people into the exchange; however, those people might not be registered with
the web site yet. We'll make two tables, one for each possibility:
invite_member (linking
exchanges and
members) and
invite_guest (linking
exchanges and
guests).
invite_member
| exchange_id |
member_id |
| 1001 |
31 |
This table invites a member to an exchange on behalf of the exchange's
administrator(s).
invite_guest
| exchange_id |
guest_id |
| 1001 |
53 |
This table invites a guest to an exchange on behalf of the exchange's
administrator(s).
Now we need a table that lists who is giving to whom in which exchange.
This table effectively links
three tables together: two instances
of
members and one instance of
exchanges.
assignments
| exchange_id |
giver_id |
receiver_id |
| 1001 |
4 |
x |
| 1001 |
4 |
y |
| 1012 |
4 |
z |
This table defines a particular recipient for a particular giver in a
particular exchange.
We also want the ability to set up restrictions about who
can't
give to whom. For instance, if you don't want a husband to be his wife's
Secret Santa (and vice versa), you need to state that somewhere. This is
represented in the
exceptions table, which
is modelled very much like the
assignments
table. These can only be defined by administrators, so that the participants
can't be picky and choosy about who they get.
exceptions
| exchange_id |
giver_id |
receiver_id |
| 1001 |
4 |
31 |
| 1001 |
31 |
4 |
This table defines a giver-receiver relationship that is not to be allowed
for a particular exchange. This exception is strictly one-way: if we did
not have the second row, that would mean Jeff could not be Kristin's Secret
Santa, but Kristin could be Jeff's. The second row stops that from being
possible.
Another helpful feature would be to keep track of electronic wish lists,
whether hosted on another website (such as Amazon.com), stored in a Word
document, or just entered into the web site as text. The
wishlist table does just that.
wishlist
| id |
member_id |
type |
data |
| 1 |
4 |
URL |
http://... |
| 2 |
4 |
file |
/path/to/list.txt |
This table defines a wishlist for a member (and as is shown, a member
can have more than one wishlist).
We then want to link wishlists to exchanges.
wishlist_link
| wishlist_id |
exchange_id |
| 1 |
0 |
| 2 |
1012 |
The special
exchange_id value of
0 denotes a wishlist that is active for
all of the gift exchanges the owner of that list is involved in.
More tables might come into existence later.