Data Base Management System
Data Base Management System
1NF
Professor
Graduate students
Project linvestigator
Project coinvestigators
Department
runs
time
2nd NF
Part 3: Implementation
Tables
mysql> create table professor(pid int primary key, name varchar(20),age int, rank int, speciality
varchar(10));
mysql> select * from professor;
mysql> create table project(pno int primary key, sponsor varchar(20),sdate date,edate date,budjet
int,investigator int;
mysql> create table co_investigator(pno int, pid int,foreign key(pno) references project(pno),
foreign key(pid) references professor(pid));
mysql> select p.name from professor p,project pr where pr.budjet>100000 and pr.investigator=p.pid;
Retrieve the names of all graduate students along with their professors under whom they
work and project sponsor.
List the professors and sum of the budget of their projects started after 2005 but ended in 2010.
mysql> select p.name,sum(distinct (budjet)) from professor p,project where sdate>="2005-01-01" and
edate<="2010-04-10" and p.pid=investigator group by p.pid;
List the names of professors who has a total worth of project greater than the average budget of
projects sanctioned
mysql> select distinct p.name from professor p,project pr where pr.budjet > (select avg(budjet) from
project) and p.pid=pr.investigator;