I could not get a hint on how to write SQL queries for A and B for the following schema.
Programme (Pid:int, Department:string...)
Employee (Eid:int, Department:string..)
Participation (Pid:int, Eid:int, ..)
A. Names of programmes participated by all employees
B. Names of employees participating in all his department's programmes.
Any guidelines would be helpful.
Haven't tried these, but this is what I would be thinking:
SELECT pg.Name
FROM Participation AS p INNER JOIN Programme AS pg ON p.Pid = pg.Pid
GROUP BY p.Pid
HAVING COUNT(*) = (SELECT COUNT(*) FROM Employeee)
SELECT e.Name
FROM Participation AS p INNER JOIN Employee AS e ON p.Eid = e.Eid
INNER JOIN Programme AS pg ON pg.Pid = p.Pid
WHERE pg.Department = e.Department
GROUP BY p.Eid, e.Department, e.Name
HAVING COUNT(*) = (SELECT COUNT(*)
FROM Programme AS pg2
WHERE pg2.Department = e.Department)