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 > table structure for inbox

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-10, 03:20
tassadaque tassadaque is offline
Registered User
 
Join Date: Jun 2010
Posts: 9
Question table structure for inbox

Hi
I am trying to create inbox table in which entries may came from multiple tables. For example in my inbox entries may be received memos and and received circulars.
How can i have multiple foreign keys to the inbox table. One option may be to add foreign key for each parent table. I want to make design flexible so that if in future if i want to join more tables with this inbox table it can be done easily.
I read somewhere about composite foreign keys does they apply here?
Reply With Quote
  #2 (permalink)  
Old 08-16-10, 04:34
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
You can add as many foreign keys as the design requires, and if the design requires it you can have composite foreign keys too.

There is not enough information to give you answers specific to your situation.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 08-16-10, 05:24
tassadaque tassadaque is offline
Registered User
 
Join Date: Jun 2010
Posts: 9
Post

Thanks for the reply. could you please define composite foreign key for me and when it is used.
is there any way to workaround multiple foreign keys.
In my case Memo tables are as follows
==========
MemoMaster
==========
MemoID PK
ThroughEmpID FK
MemoDate
Subject
MemoText
==========
MemoDetail
==========
MemoDetailID PK
MemoID FK
EmployeeID FK
AckDate

Almost similar structure is for Circular

Can you suggest the possible inbox table structure
Reply With Quote
  #4 (permalink)  
Old 08-16-10, 05:47
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
A composite foreign key is used in all but the most trivial databases that use natural keys for the primary keys.
I don't know if you are using surrogate keys or not, but looking at what you have posted it seems likely, in which case you would not use composite foreign keys.

NOTE that "multiple foreign keys" and "composite foreign keys" are not the same thing.

It seems to me you could do with stopping now and reading up relational database design and concepts. This is the best whistle stop tour of the subject I know of:
The Relational Data Model, Normalisation and effective Database Design
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #5 (permalink)  
Old 08-16-10, 06:29
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,243
sounds like you want some for of sub/super types

top level table identifies a type of message/communication
and stores all relevent data common to all forms of communication
then for each type you hav a sub table which stores datat relevent to just that communication

so that could be
table: inbox
id
communicationtype
timeofevent

emailtable
inboxID
emailfrom
emailcontents

memo
ID
inboxid
URLtoDocument

telecon
ID
inboxid
whowith
notesofconversation

suggest you google sub/super types
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #6 (permalink)  
Old 08-17-10, 01:56
tassadaque tassadaque is offline
Registered User
 
Join Date: Jun 2010
Posts: 9
Thanks for your reply i will get back to u soon after studying as u suggested

Last edited by tassadaque; 08-17-10 at 03:53.
Reply With Quote
Reply

Tags
database design, relation, relational database

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