Consider the following information about a university database:
• Each project is managed by one professor. And each project is worked on by one or more professors. but professors can manage and/or work on multiple projects.
• Each project is worked on by one or more graduate students. When graduate students work on a project, a professor must supervise their work on the project. Graduate students can work on multiple projects, in which case they will have a supervisor for each one.
• Departments have a professor who runs the department. professors work in one or more departments, and for each department that they work in, a time percentage is associated with their job.
• Graduate students have one major department. Each graduate student has another, more senior graduate student who advises him or her on what courses to take(advisor).
Professors have an SSN, a name, an age, a rank, and a research specialty. Projects have a project number, a sponsor name (e.g., NSF), a starting date, an ending date, and a budget. Graduate students have an SSN, a name, an age, and average degrees
Departments have a department number, a department name, and a main office.
Create user smith with privilege that allow him to create tables and DB.
Write DDL statements to create the tables.
Write Queries for the following:
a. insert the sample data shown above into the tables
b. Find all information of projects who have managed by each professor
c. Find the names and degrees of graduate students whose degree is better than some graduate students called ali.
d. write a query to retrieve the name of graduate student and student advisor name of all graduate student.
e. Find the number of graduate students who have the same average degrees, average degrees and display new column as average_degrees*average_degrees/2 for each graduate student, and list in the order of age.
f. Write a query to retrieve name of professor, department name and project, for all projects whose budget is greater than 400.
g. Select all those professors who age in the range 30 to 40 and don’t have any rank.
h. List all professors whose name begins with ‘A’ or ‘L’ and age large than 30.
i. List full details of departments that don’t have any graduate students.
j. Find the name and the age of the youngest professors
k. Count the number of different professors names.
l. Find the names of student who have work in all projects.
m. Find the name and the age of the youngest graduate student (use subquery).
n. Find the names of professors supervising graduate students that age >22.
o. Find the ids of professors who have work in an IT department or Science department.
p. Find the names of graduate students who have works on projects with budget >300, and list in the order of budget.
q. Find the ids and names of professors who have work in two different department on the same time.
r. Find the ids and names of professors who managed two different project on the same start date.
s. Find the names of professors who have works in at least one project.
t. Change the name of professor ‘Alex’ to Ali.
u. Delete the record for the student whose name is ‘Ali’ and age 22.
v. add new column to project table with constraint unique and add a default value for it then create view that view names of professors and name of project