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 > Patient - complaint (terbary relationship question)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-13-10, 02:31
Abu Ali Abu Ali is offline
Registered User
 
Join Date: Jan 2010
Posts: 1
Unhappy Patient - complaint (terbary relationship question)

Hi everyone, hope you'll doin' just fine.

I have a project about a hospital, which we are required to design a database for it .

anyway I have a ternary relationship between patient, complaint and treatment and it's many to many, so I'll have four tables.

Patient, Complaint, Treatment and Patient_Complaint_Treatment.

I was asked a question which is :

Display a list of patients and their complaints, treatments and dates of treatment.

to be in the picture, the date of treatment is in the treatment table < can you explain more.

so how can I write the SELECT statment to answer the question and which table should be used in ternary relationship in general ?


Thank very much,
Reply With Quote
  #2 (permalink)  
Old 01-13-10, 10:15
blindman blindman is offline
World Class Flame Warrior
 
Join Date: Jun 2003
Location: Ohio
Posts: 11,719
You don't have a tertiary relationship. Not all treatments are applicable to all complaints.

You should have five tables:
Patient (PatientID)
Complaint (ComplaintID)
Treatment (TreatmentID)
ComplaintTreatment (ComplaintTreatmentID, [ComplaintID, TreatmentID])
Patient Treatment (PatientTreatmentID, [PatientID, ComplaintTreatmentID])
__________________
If it's not practically useful, then it's practically useless.

blindman
www.chess.com: "sqlblindman"
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