views:

180

answers:

3

i want to come up with a generic (if possible) schema to use for a number of different events that i am managing. These events can be weddings, birthday parties, etc

So for i have 3 main tables

  1. Contact Table - with the usual info like address, phone, etc
  2. Events Table - list of events with some info like date, location, etc
  3. Now i am trying to figure out the best to capture the event data where we want to keep track across adults and children. I have a EventInfo table right now with the below fields (not complete but you should get the point)

EventID
ContactID
NumberofAdultsInvited
NumberofChildrenInvited
Responded (yes, no)
NumberofAdultsAttending
NumberofChildrenAttending

It seems strange that i need these repetitive fields for adults and children but i can't think of any other way. I dont want to put NumberAdults and NumberofChildren in the contact table because number of children doesn't necessarily equal numberofChildreninvited (sometimes adults are just invited)

any ideas how i can clean up this schema or is the above maybe the best i can get.

NOTE: In the contact table, there is one entry for the family (as it has one address) so there are not fields stored per person within a family

A: 

[T]he contact right now is the whole family as one invitation is sent to one family

In that case, and absent any other requirements, I'd probably suggest a similar route to what you've already proposed.

The redundant fields aren't an issue, since they are tracking a unique fact about the Invitation, not the contact.

I'd probably keep a separate table for the Response (with number attending, which may be different from number invited) or an Attendee table, but it's not really necessary given your current requirements.

Mark Brackett
the contact right now is the whole family as one invitation is sent to one family. are you saying that i should seperate a family table from a person table
ooo
A: 

Do you need to track the indiviual invitations and responses?

If so you could have a separate table for Invitations and their statuses. Then you could obtain your counts from queries against that table.

If you are simply keeping a track of counts I might normalise to separate tables for InvitationCount with a discriminator column for Adult, Child or anything else. This avoids hard coding into your schema just two categories of invitation. Perhpas in the future you might have more categories (eg. Customers, Clients, Participants, Observers, Performers, Musicians, Donors, Honorary members ...)

djna
i need to track how many people are invited and how many people say yes / no
ooo
A: 

Here's how I'd model the database based on the provided info:

EVENTS

  • EVENT_ID
  • ADDRESS_ID

INVITATIONS

  • CONTACT_ID
  • EVENT_ID
  • RESPONDED

CONTACTS

  • CONTACT_ID

It's not a good idea to model a contact to be encompassing an entire family. It makes it easier to invite & track things if a contact represents a person rather than a household. After all, a household can have anywhere from 0 to ~18 kids, and may not include a significant other. Each person, assuming teens & up, will have unique contact info (IE: cell phone(s), work numbers, email, etc). This also makes it easier to determine headcount...

The invitations table allows you to summarize invitations & confirmations:

  SELECT e.event_name,
         SUM(invited.contact_id) 'total_invited',
         SUM(confirmed.contact_id) 'total_invitations_confirmed'
    FROM EVENT e
    JOIN INVITATIONS invited ON invited.event_id = e.event_id
    JOIN INVITATIONS confirmed ON confirmed.event_id = e.event_id
                            AND confirmed.responded = 'Y'
GROUP BY e.event_id, e.event_name

Just need to join to CONTACTS table to determine age and then be able to subcategorize the invitations between adults & children.

FAMILIAL_RELATIONS

  • CONTACT_ID
  • RELATED_CONTACT_ID
  • RELATION_TYPE (parent, child, aunt/uncle, cousin, blacksheep etc)

Use this table to rollup to get household members...


CONTACT_METHODS

  • CONTACT_ID
  • METHOD_TYPE (phone, cell, biz phone, fax, email, IM, etc)
  • METHOD_VALUE

CONTACT_ADDRESS_XREF

  • CONTACT_ID
  • ADDRESS_ID
  • ADDRESS_TYPE (home, business, etc)

ADDRESSES

  • ADDRESS_ID
  • ADDRESS_1
  • ADDRESS_2
  • ADDRESS_3
  • ADDRESS_4
  • CITY
  • PROV_STATE
  • POSTAL_CODE
  • COUNTRY

You'll notice I made a one to one relationship with EVENTS and ADDRESSES, while supporting one-to-many contact to addresses. Locations will be relatively static, compared to people. This format would allow you to easily check which event locations are popular, so you could use the information to get better rates in the future.

Regarding addresses for the same household: That's why the ADDRESSES is a separate table - you don't need to retype it for each person, just associate to the correct address record.

OMG Ponies
if i store contacts as single people instead of households, i have some fields that dont work any more like "Mailing Name" which would be "Thompson Family"
ooo
also, the address info is for the contacts so everyone in the same household would have identical information in address fields
ooo
@oo: Updated answer based on your concerns.
OMG Ponies