Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 relational algebra

Author  Topic 

afebmunn
Starting Member

4 Posts

Posted - 2008-12-17 : 17:43:55
Relational Algebra Help SQL
I have the following table :

Patient (PatientCode, PatientSurname, PatientFirstname, PatientSex, Age, PatientOccupation, PatientHeight, PatientWeight, PatientAddress)

Doctor (DoctorCode, DoctorSurName, DoctorFirstName, DoctorPrivateAddress, MobileNo, Function)

Operation (Operation Code, PatientCode, DoctorCode, Date, Time, Result, OperationType)

Is_Seen_By (PatientCode, DoctorCode, Date, Time).


2 - i need in relational algebra form 2 find :

1. Find the surname and gender of the patients that have been operated on by doctor "DR20" and results have been successful.
2. Find the code of the operations that have been done on the 15th of December of 2008 and have been successful.
3. Find the first name, surnames and address of the patients that have had at least one operation with broken limb.
4. Find the details of all patients that have shared any doctors with the patient that has the code “P555".
5. Find the surname, gender and age of the patients that have been seen by doctor "DR55" and have been operated on by doctor “DR9”.


**** for the first one i have came up with : -

R1: select doctor where doctor code ="DR20"
R2: R1 NAT JOIN Patient
R3: Project R2 over patientsurname, patientsex

stuck on last bit can somebody help?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-18 : 01:13:47
show what you've tried so far for last bit and then we will help you
Go to Top of Page

afebmunn
Starting Member

4 Posts

Posted - 2008-12-18 : 08:10:46
R1: select doctor where doctor code ="DR20"
R2: R1 NAT JOIN Patient
R3: Project R2 over patientsurname, patientsex
R4: select opearation where result ="successful"

im sure there is something wrong here some ppl told me i should maybe have onli up to R3. thanks for your help
Go to Top of Page

afebmunn
Starting Member

4 Posts

Posted - 2008-12-18 : 13:53:11
?
Go to Top of Page

hanbingl
Aged Yak Warrior

652 Posts

Posted - 2008-12-18 : 14:53:23
[code]
Select PatientSurname, PatientSex
From Patient p inner join Operation o
on p.PatientCode = o.PatientCode
inner join Doctor d
on d.DoctorCode = o.DoctorCode
where DoctorCode = 'DR20' and o.Result = 'successful'
[/code]
Go to Top of Page

afebmunn
Starting Member

4 Posts

Posted - 2008-12-18 : 16:49:39
ok thanks alot. i done the second 1 is this correct?

select operation code, result,
where date ="15th december 2008" >?
Go to Top of Page
   

- Advertisement -