I'm trying to find the best solutions for operations on the following database:
Employee (EmployeeId, Surname, Salary, DepartmentId)
Department (DepartmentId, DeptName, City, Director)
Project (ProjectId, ProjectName, Budget, Director)
Works (EmpoyeeId, ProjectId)
My queries:
1 SQL query to find the surname of the employees who are directors of a department.
SELECT Surname
FROM Employee
WHERE Employee.EmployeeId IN (
SELECT Department.Director
FROM Department
);
2 SQL query to find the employee surname and salary of all employees who work in Haarlem.
SELECT Surname, Salary, City
FROM Employee,Department
WHERE Department.City = ‘Haarlem’;
3 SQL query to find the names of the projects whose budget is higher than 100 and the surnames of the employees who work on them.
SELECT ProjectName, Budget, Surname
FROM Project, Employee, Works
WHERE Project.Budget > 100
AND Works.EmployeeId = Employee.EmployeeId
AND Works.ProjectId = Project.ProjectId;
Are there any better ways to get the information needed?