Not sure it is a correct SQL and would like to work backward converting SQL back to tuple relational calculus to check the correctness.
Let's say we come up this query to display the classes where all its requirement classes have been complete by all the participants who finished the introduction.
So we have two tables, progress and requirement. where progress: mId (string), cId (string) and requirement: : cId (string), rId (string) all the enrollment are kept in progress and all the requirements are specified requirement table.
mId:memeberId
cId:cId
rId:requirmentClassId
Select cId
From requirement r
Where r.rId in (Select distinct(cId)
From progress
Where mId in (Select mId
From progress
Where cId='intro'
)
);
We first select all the members from the progress table where they has done the intro session. Select mId From progress Where cId='intro'
Then we have all the members who finished the intro, so we can select all the other distinct classes has done by the members.
Select distinct(cId)
From progress
Where mId in (Select mId
From progress
Where cId='intro'
)
)
Now we have all the classes completed by all the members who finished the intro, now we can find out all the next possible class(es) that should be offered to all the members who finish the intro?
Ok, after I finish writing the question, I don't think this query is correct since now we have all the classes completed by all the members who took the intro, but not necessary all the classes is completed by individual student, correct ? Please check my work. any help is highly appreciated.
question from:
https://stackoverflow.com/questions/65935372/reversing-steps-converting-sql-query-back-to-tuple-relational-calculus 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…