Professional Documents
Culture Documents
Experiment 1: Aim:-Experiment To Design EER Diagram For Given Case Study, Convert It Into Relational
Experiment 1: Aim:-Experiment To Design EER Diagram For Given Case Study, Convert It Into Relational
Experiment 1: Aim:-Experiment To Design EER Diagram For Given Case Study, Convert It Into Relational
Aim :- Experiment to Design EER diagram for given case study, convert it into relational
model (Schema) and execute different types of queries, procedures and triggers on it.
Queries:7,Procedure:-2,functions:-1,Trigger-2
Case Study :-
The students are evaluated only on the basis of their exams marks and the
projects that they do for their curriculum. This database is for storing data about all the
projects and assignments done by a particular student so that the person evaluating them
has easy access to all the data.
EER Diagram :-
Table Creation :-
Trigger 1 :-
Inserts user into corresponding tables depending on their role attribute
if @role = 'student'
begin
insert into Student(users_id) values(@user_id)
end
else
begin
insert into Staff(users_id) values(@user_id)
end
end
Output :-
Users
Staff
Student
Trigger 2:-
create trigger insert_values_evaluation on Evaluation_criteria for insert as
begin
declare @type as varchar(20), @evaluation_id as int
select @type=evaluation_type from inserted
select @evaluation_id = evaluation_id from inserted
if @role = ‘project’
begin
insert into Project(evaluation_id, project_name) values(@evaluation_id, ‘default’)
end
else
begin
insert into Assignment(evaluation_id) values(@evaluation_id)
end
end
Output:-
Evaluation_criteria table :-
Project table:-
Procedure 1:-
create procedure get_projects @student_id as int
as
begin
declare @project_ids Table (project_id int, project_name varchar(30));
insert into @project_ids select distinct Project.project_id, project_name from Project,
Works_on where student_id = @student_id
select * from @project_ids
end
Output :-
Procedure 2:-
while @iterator<@length
begin
select Assignment.assignment_id, Assignment.assignment_name
from Assignment where evaluation_id=(
select evaluation_id from @evaluations where id=@iterator
);
set @iterator=@iterator+1;
end
end
Output:-
Function:-
Create function student_count()
returns table as
Return (select class_id,count(*) as No_of_students from belongs_to as b,student as s
where b.users_id=s.users_id group by class_id)
Output:-
Complex Queries :-
1. Display avg score for all projects of a particular student
Output :-
Output :-
6.Display the name of staff who has posted maximum number of assignments.
select u.users_name from users as u where u.users_id = (select users_id from staff
where staff_id = (select staff_id from max_assign where count = (select max(count)
from max_assign)))
Output :-
7. Display marks of all projects for a particular student.
Output :-