Question
Suppose the following tables are part of a project management database of a company, where keys are bold: E( ssn , name, salary) stores the
Suppose the following tables are part of a project management database of a company, where keys are bold: E(ssn, name, salary) stores the information of employees, P(pid, title, budget) stores the information of projects, and M(ssn, pid, start, end) stores the information of management of projects by employees.
1) Write an SQL query to return the ssns of employees that manage at least two projects, one is finished (end < today), and the other is still ongoing ( start =< today =< end).
2) Write an SQL query to delete all the projects from table P that are NOT managed by any employee.
3) Define an SQL view PNum (pid, num) that gives the number of employees that manages project pid.
4) Write an SQL query to return the ssn of employees that manage each project in P.
5) Write an SQL CREATE ASSERTION statement to force the constraint An employee needs to manage at least one project
6) Write an SQL CREATE ASSERTION statement to enforce the constraint that an employee never manages two projects that overlap in time.
7) Define an SQL view Budget(ssn, totalbudget) that summarizes the total budget of projects that an employee manages.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started