Dbms Project Mainnn
Dbms Project Mainnn
SYSTEMS
SEMESTER V
YEAR: 3RD
Project Title:
SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
Page | 1
INDEX
Page | 2
Hostel Database Management System
1. PROBLEM DESCRIPTION
Page | 3
2. ER DIAGRAM
Page | 4
Entities:
1. Hostel
2. Students
3. Fees
4. Room
5. Furniture
6. Mess
7. Mess employee/staff
8. Visitor
Hostel:
Many institutes provide the facility of hostel for boys and girls.
But we are mentioning only boys here , almost all the working is same in both hostels.
Reason:
We are taking the entity named as hostel because from here data will move to other entities
and we will manage the database.
This entity will manage the data of students in hostel.
Attributes:
If we talk about the attributes, there can be many but we have mention only few those will be
more help full to make the project workable and simple.
Primary Key:
Building_num because one institute can have more than one block or building so by assigning
the num it will be easy to track the data.
Constraints:
Primary key should be unique and cannot be null.
Page | 5
Data Flow:
Only administrator will get in the system and manage the database and check the status of
students and will allocate the room to new students.
It will also do the check and balance of mess.
The data will move from here to different side like the branches of tree.
Students:
Students will be in hostel or hostel has students.
Reason:
The reason for choosing this entity is that ,student is the main entity in the hostel and we will
keep the database of students and logically related things with the students.
Attributes:
Studend_id, Student_name , father_name,department, room_id, cell_no, age, DOB etc
These are selected so that hostel administration can easily manage the whole information about
student and through different perspectives students can be accessed by hostel management.
Primary Key:
Student_id is the primary key and it can’t be null.
Constraints:
Primary key should be unique and cannot be null.
When primary key move to the other relation and join the tables the values should be same.
Data Flow:
The admin will enter the data of students (this entity), on the basis of different attributes like
age, department the administrator will assign the room so that the students of same age fellow
and alike department can share the room.
Page | 6
Room:
Students come in the hostel to get the room.
Reason:
Room will be allotted to different students, so the students can be accessed by the attributes of
room as well.
Attributes:
There can be many attribute in this entity
No_of_students, Students_name, furniture_id ,student_id can be added as a foreign key to
relate the both entities.
As we have composite foreign key this is coming from admin to student and then student to
room.
Primary Key:
Room_id is the primary key and it can’t be null.
Constraints:
Primary key should be unique and cannot be null.
As we have composite foreign key in this table which is of boys_hostel_admin and student so
there data-type size and values should be same.
Data Flow:
We can also see that there is a composite foreign key which is of boys_hostel_admin and
student so data will flow from admin to student and student to room.
But in ER diagram we can see there is direct relation of admin and room so admin can retrieve
the condition and data of room directly as well.
Fees:
Page | 7
Obviously when students will live in the hostel they will submit fee.
Reason:
This is weak entity here because if the student will exist then fee will be submitted other-wise
not.
When students will live in hostel there will be fees charges on the monthly basis.
Attributes:
There will be few attributes because it is the weak entity and just made to
keep the fees status of student.
Primary Key:
student_id is the primary key and it can’t be null.
Constraints:
student_id is the primary key and foreign key as well. it can’t be null.
Data Flow:
The data will follow the route, admin to student and then fees.
Admin will check the student status by getting in the student entity and fees is a weak entity
attached to the student so admin will be able to check the fees status of student.
Furniture:
Reason:
The reason for adding this entity is to just track the either students are getting the facilities
promised by the institute or not.
Attributes:
Furniture_type: chair, table etc
Page | 8
Datatype And Size:
Each attribute have the suitable datatype and size according to the requirement.
Primary Key:
Furniture_id
Constraints:
Primary key should be unique and cannot be null.
Foreign key (room_id) will be same as values in room relation
Data Flow:
The data come from room boys_hostel_admin will track through it.
Mess:
Students will get the facility of mess
Reason:
Students will get the facility of mess. It can be considered as marketing strategy so more
students will come in this hostel because every hostel do not give this facility.
Attributes:
There will be mess incharge , who will handle the mess, there will be monthly expenses of each
student, students name to know which have got their meal or not.
Mess timing can be added to make the environment much better.
Primary Key:
Mess_incharge will be the primary key
Constraints:
Primary key should be unique and cannot be null.
Data Flow:
Page | 9
Admin will check the mess staff and then staff will manage it.
Mess employees:
Reason:
There will be staff in mess and hostel as well.
Some will work in mess and others like sweepers in hostel and many more.
Attributes:
Employee_name, address, salary, cell_no etc are the attributes used in this entity.
Primary Key:
Employee_id is used as a primary key.
Constraints:
Primary key should be unique and cannot be null.
Mess_incharge will be foreign key in this table.
Data Flow:
The data will flow from admin to staff and then mess.
Visitors:
Reason:
This entity is added as the extra entity so that our project can be look complete from every
aspect.
Attributes:
Student_id,visitor_name,time_in,time_out,date these are the attributes to check what time
visitor came and when he/she will leave the hostel.
Page | 10
Datatype And Size:
Each attribute have the suitable datatype and size according to the requirement.
Primary Key:
CNIC is considered as primary key.
Constraints:
Primary key should be unique and cannot be null.
Student_id will be the foreign key in this.
Data Flow:
This is the optional entity and data will come from student and admin.
Admin can log in to see the student data in which visitor is also attached with the foreign key
so admin can keep eye on the visitor position of every student.
Page | 11
2. SQL>create table room
(room_id int (10) not null, capacity int (10) not null, hostel_id int (10) not null,
name_of_student varchar (40) not null, room_status varchar(10) not null, constraint b_pk
primary key (room_id), constraint c_fk foreign key (hostel_id) references boys_hostel
(hostel_id));
SQL>drop table room;
SQL>insert into room values
(2001,'2','1001','Rahul and Kartik','full'),
(2002,'2','1001','Harsh and Abhijeet','full'),
(2003,'2','1001','Raghav and Mukesh','full'),
(2004,'2','1001','Asif and Hussain','full'),
(2005,'2','1001','Anurag and Ayush','full'),
(2006,'2','1001','Anshuman','not_full'),
(2007,'2','1001','Ashu and Tejan','full'),
(2008,'2','1001','Kritik and Chirag','full'),
(2009,'2','1001','Shubhang','not_full'),
(2010,'2','1001','Faiz','not_full'),
(2011,'2','1001','Gandharv','not_full');
SQL>select * from room;
Page | 12
(103,' Harsh ','Sunil Kumar','management','Bihar','03xx-xxxxxxx','21','13-feb-92','1001',2002),
(104,'Abhijeet','Mohit Iyer',' CSE ','Mumbai','03xx-xxxxxxx','22','1-may-91','1001',2003),
(105,'Raghav,'Manoj Singh','CSE','Jamshedpur','03xx-xxxxxxx','21','19-apri-92','1001',2003),
(106,'Mukesh','Anil Kumar','management','Delhi’,'03xx-xxxxxxx','23','28-may-
90','1001',2002),
(107,' Asif ','M.Tareek','CSE','Kolkata','03xx-xxxxxxx','22','19-april-91','1001',2004),
(108,'Hussain','M.Hassan','CSE','Kolkata','03xx-xxxxxxx','20','1-sep-93','1001',2005),
(109,'Anurag,'Vivek Yadav','management','Allahabad','03xx-xxxxxxx','21','20-sep--
92','1001',2005),
(110,'Ayush','Sanjay Kumar','CSE','Lucknow','03xx-xxxxxxx','22','1-may-91','1001',2006),
(111,'Anshuman,'Anshul Sharma','CSE’,'peshawer','03xx-xxxxxxx','22','1-march-
91','1001',2007),
(112,'Ashu','Alok Kumar','CSE’,'Chennai','03xx-xxxxxxx','23','20-march-90','1001',2007),
(113,'Tejan','Harpeet Singh','CSE','Punjab','03xx-xxxxxxx','21','14-aug-92','1001',2008),
(114,' Kritik,'Aman Patni','CSE','Udaipur','03xx-xxxxxxx','21','20-april-92','1001',2008),
(115,’Chirag’,'Sunil Agarwal', 'Electrical engineering','Thailand','03xx-xxxxxxx','22','2-sep-
91','1001',2009),
(116,'Subhang','Arindam Sharma', 'Electrical engineering','Lucknow','03xx-xxxxxxx','23','2-
jun-90','1001',2010),
(117,'faiz','Aamir Ahmad', 'Electrical engineering','Delhi','03xx-xxxxxxx','21','2-sep-
99','1001',2011);
SQL>select * from student;
Page | 13
5. SQL>create table staff
(emp_name varchar (40) not null, emp_id int (20) not null, emp_address varchar (50) not null,
emp_salary int (20) not null, emp_cellno varchar (20) not null, hostel_id int (10) not null,
emp_designation varchar (40) not null, mess_incharge_Id varchar (20), constraint j_pk primary
key (emp_id), constraint h_fk foreign key (hostel_id) references boys_hostel (hostel_id),
constraint i_fk foreign key (mess_incharge_id) references mess (mess_incharge_id));
SQL>drop table staff;
SQL>insert into staff values
('Vinod','8321','Potheri','15000','03xx-xxxxxxx','1001','cook','9321')
('Ramu','8322','Gudvencheri','15042','03xx-xxxxxxx','1001','sweeper','null'),
('Sahil','8323','Potheri','15042','03xx-xxxxxxx','1001','mess manager','9322'),
('Rohit','8324','Potheri','12050','03xx-xxxxxxx','1001','sweeper','null'),
('Kumar','8325','Gudvencheri','18000','03xx-xxxxxxx','1001','technician','null'),
('Mahesh','8326','Potheri','18000','03xx-xxxxxxx','1001','technician','null'),
('Mukesh','8327','Potheri','12050','03xx-xxxxxxx','1001','laundryman','null');
SQL>select * from staff;
Page | 14
(4569,'114','Prateek','7:00 PM','8:45 PM','Harsh','4-may-19'),
(4560,'116','Suhail','8:00 AM','9:56 AM','Kunal','23-april-19');
SQL>select * from visitor;
Page | 15
(fee_year varchar (40) not null, fee_status varchar (40) not null, student_id int (10) not null,
student_name varchar (40) not null, constraint o_pk primary key (fee_month_year,student_id),
constraint p_fk foreign key (student_id) references student (student_id));
SQL>drop table Fee;
SQL>insert into Fee values
('2019','paid','101','Raghav'),
('2019','not paid','102','Chirag'),
('2019','paid','103','Ashu'),
('2019','not paid','104','Anshuman'),
('2019','paid','105','Faiz'),
('2019','paid','106','Tejan'),
('2019','piad','107','Subhang'),
('2019','paid','108','Kritik'),
('2019','not paid','109','Anurag'),
('2019','paid','110','Ayush'),
('2019','not paid','111','Abhijeet'),
('2019','paid','112','Hussain');
SQL>select * from fee;
2. Display the room id of the students who are enrolled for the course CSE.
Page | 16
5. Display the name of the students who stay in the hostel and study management.
8. List the name of students who have not paid their fees.
4. Find the count of mess employees with salaries greater than 30000.
Page | 17
5. Display the combined list of rooms with their students.
7. List the name of students who have not paid their fees using view with name as
“notpaid”.
SQL>create view notpaid as select student_name from fee where fee_status=”paid”; select *
from notpaid.
8. List the out time of visitor having id 4861 using view statement.
SQL>select capacity from room where furniture_id in (select furniture id from furniture where
furniture_type=”good”);
10. List the visitor name of the students with age less than 15.
SQl>select visitor_name from visitor where student_id in (select student_id from students
where age<15);
Page | 18