0% found this document useful (0 votes)
30 views

Data Base Management System

This document discusses an entity relationship model and its implementation in a relational database. It defines entities like professors, students, projects and their attributes. It then shows how these entities are normalized and implemented as tables in a MySQL database. Finally, it provides examples of queries that can be used to retrieve information from these tables like names of professors without ongoing projects, names of students and their supervisors, budgets of professor's projects between 2005-2010, and professors with total project worth greater than average.

Uploaded by

Waseel sultan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Data Base Management System

This document discusses an entity relationship model and its implementation in a relational database. It defines entities like professors, students, projects and their attributes. It then shows how these entities are normalized and implemented as tables in a MySQL database. Finally, it provides examples of queries that can be used to retrieve information from these tables like names of professors without ongoing projects, names of students and their supervisors, budgets of professor's projects between 2005-2010, and professors with total project worth greater than average.

Uploaded by

Waseel sultan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Part 1: ER Model

Part 2: Relational Model

1NF
Professor

SSN name age rank research specialty


Projects

project number sponsor name starting date ending date budget

Graduate students

SSN name age degree program

Project linvestigator

Project coinvestigators

Department

department no department main office


name

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> select * from project;


mysql> create table student(usn varchar(10) primary key, name varchar(20), age int, degree
varchar(10),supervisor int,foreign key(supervisor) references professor(pid));

mysql> select * from student;

mysql> create table co_investigator(pno int, pid int,foreign key(pno) references project(pno),
foreign key(pid) references professor(pid));

mysql> select * from co_investigator;

mysql> show tables;

Part 4: Queries: Design and implement 10 meaningful queries.


Retrieve the names of all professors who do not have an ongoing project of more than 1 lakh.

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.

mysql> select s.name,p.name,pr.sponsor from student s,professor p,project pr where


p.pid=s.supervisor and p.pid=pr.investigator;

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;

List the professors who work on all the projects.

mysql> select distinct p.name from professor p, project pr where p.pid=pr.investigator;

You might also like