If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > General > Database Concepts & Design > Members with Different Detail tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-16-09, 12:05
mailman mailman is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
Members with Different Detail tables

Hi all.

I've got a strange issue I've never ran into before, and I'm wondering what the best design method might be for this problem. The one I've come up with below feels flawed using a flagging system:

I've got MEMBER's. Each MEMBER can have a different level of detail associated to their account. To try and keep this different information organized, this is my proposed solution:

MEMBER
----------
id (pk)


MEMBER_MEMBER_DETAIL_REL
----------
member_ID (fk)
member_detail_ID (fk) // id of one of the tables below
member_detail_type_flag (char) // This tells you which table to look at.


MEMBER_DETAIL_REGULAR
----------
id (pk)
// extra member details here


MEMBER_DETAIL_UNPAID
----------
id (pk)
// extra member details here


MEMBER_DETAIL_AFFILIATE
----------
id (pk)
// extra member details here


MEMBER_DETAIL_SPONSOR
----------
id (pk)
// extra member details here
Reply With Quote
  #2 (permalink)  
Old 06-16-09, 12:08
mailman mailman is offline
Registered User
 
Join Date: Jun 2009
Posts: 2
My other idea was...

My other idea was to simply link each table to the MEMBER TABLE directly, and put the flag in the MEMBER table that tell me which child table to look at for the details. Maybe that's a better solution?!?!?

Anyway, I look forward to any replies. Thanks.
Reply With Quote
  #3 (permalink)  
Old 06-16-09, 13:50
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
the flag in the members table which tells you which detail table to look in...

... implies two SELECTs, one for the member, then an "if" statement in your application language which controls which of the details tables you go after next

better would be, if there aren't ~too~ many different details tables, simply to LEFT OUTER JOIN to all of them

that's just one query instead of two

for further information, search supertype/subtype

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On