Question

I'm just hoping for guidelines, NOT answers.

How is a left outer join written in Relational Calculus?

Here is the statement I wrote in algebraic notation:

Doctor (⟕) Doctor.Doc_id = Duty.Doc_id Duty

(a left outer join symbol)

And here's the calculus notation I wrote:

{S|∃ D ∈ Doctor (∃ C ∈ Duty (D.Doc_id = C.Doc_id ^
 S.Doc_id = D.Doc_id ^
 S.Doc_fName = D.Doc_fName ^
 S.Doc_lName = D.Doc_lName ^
 S.Position = D.Position ^
 S.Qualification = D. Qualification ^
 S.YearsExperience = D.YearsExperience ^
 S.Dept_id = D.Dept_id ^
 S.Duty_id = D.Duty_id ^
 S.Staff_id = D.Staff_id ^
 S.Date = D.Date ^
 S.Duty_type = D.Duty_type ^
 S.Max_no = D.Max_no ^
 S.Given_no = D.Given_no ^
 S.Avaliable_no = D.Avaliable_no ^
 S.Current_no = D.Current_no ^
 S.Room_no = D.Room_no)}

I understand that outer join means everything in the relation will be displayed. But I don't know how else to write it where it will be displayed.

Was my calculus notation right? If not, what did I do wrong?

Was it helpful?

Solution

This is the translation to SQL for your formula that starts with

{S|∃ D ∈ Doctor (∃ C ∈ Duty (D.Doc_id = C.Doc_id ^ (etc..) ) ) }

SELECT * FROM S
    WHERE EXISTS (SELECT * FROM Doctor D
        WHERE EXISTS (SELECT * FROM Duty C
             WHERE (D.Doc_id = C.Doc_id)
             AND (etc...)));

So I guess the answer is no, this is not a left outer join.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top