Relational algebra help
I'm new to relational algebra and finding it difficult. I've answered a few questions; however, they where relatively simple. Could do with help开发者_Go百科 with these though.
Database
Patient (PatientCode, PatientSurname, PatientFirstname, PatientSex, PatientAge,
PatientOccupation, PatientHeight, PatientWeight, PatientAddress)
Doctor (DoctorCode, DoctorSurName, DoctorFirstName, DoctorPrivateAddress,
MobileNo, Doctor Specialisim)
Operation (Operation Code, PatientCode, DoctorCode, Date, Time, Result,
OperationType)
Is_Seen_By (PatientCode, DoctorCode, Date, Time)
Queries
Find the surname and gender of the patients that have been operated on by doctor "DR333" and results have not been successful.
Find the code of the operations that have been done on the 18th of November 2010 and have been successful. Please also list the name of the doctors which were involved with the operation.
This may or may not be totally wrong, I'm back from a very long computer sabbatical. The SQL for it should be something like:
Q1:
SELECT Patient.PatientSurname, Patient.PatientSex
FROM Patient INNER JOIN Operation
ON Operation.PatientCode = Patient.PatientCode
INNER JOIN DOCTOR ON Operation.DoctorCode = Doctor.DoctorCode
WHERE Operation.Result = "fail"
AND Doctor.DoctorCode = "DR333"
Q2:
SELECT Operation.OperationCode, Doctor.DoctorFirstName
FROM Operation INNER JOIN Doctor ON Operation.DoctorCode = Doctor.DoctorCode
WHERE Operation.Date = "18/11/2010"
AND Operation.Result = "success"
精彩评论