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

Database System Final Project

The document describes designing a relational database for a school to store student, teacher, course, exam and other related data. It includes entity relationship diagram and tables with columns. Sample data is provided. Various queries to retrieve data from the database are listed.

Uploaded by

Agu
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)
44 views

Database System Final Project

The document describes designing a relational database for a school to store student, teacher, course, exam and other related data. It includes entity relationship diagram and tables with columns. Sample data is provided. Various queries to retrieve data from the database are listed.

Uploaded by

Agu
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/ 9

Database System Final-Project

School Database

By
Ganesh Marella (CWID: 50303006)
Mahi (CWID: 111111111)
Introduction:
A Database is an organized collection of data, typically stored electronically in a computer system. A
Database is usually controlled by a database management system (DBMS). Database helps any
organization/business to manage and access data in more efficient way for a long period of time. Since
its first launch into the market in the year 1979, Database system has evolved a lot to handle the
increasing data much more effectively making it easy for the end-users to access the data from the
beginning of the time to till date seamlessly.

Goal:
Our goal is to design a relational database for a school to store and manage its records for a long time to
come.

Business Purpose:
To create a relational database that helps school management to store and manage their information
like students data, teachers information, exams, books and courses.

So, what is relational database?


In the relational database model, data is stored in tables. This means any record can be related to any
other record, and new relations can be easily added. This structure sets up relational databases as an
efficient, flexible, and intuitive way to store information. They can be accessed by any application.

What are its benefits?


 Manageability: A relational database (RDB) is easy to manipulate, each table of data can be
updated without disrupting the others.
 Flexibility: If you need to update your data, you only have to do it once – no more having to
change multiple files one at a time. And it’s pretty simple to extend your database. If your
records are growing, a relational database is easily scalable to grow with your data.
 Avoid errors: There’s no room for mistakes in a relational database because it’s easy to check for
mistakes against data in other parts of the records. And since each piece of information is stored
at a single point, you don’t have the problem of old versions clouding the picture.

Where to start?
Any relational database design starts with sorting what information goes into a table and how its
contents/entities are related to the information stored in other tables. We collect all this information
and represent it in a diagrammatical format called ER diagram.

So, what is this ER diagram and what does it have to do with relational
database?
An Entity Relationship (ER) Diagram is a type of flowchart that illustrates how “entities” such as people,
objects or concepts relate to each other within a system. ER Diagrams are most often used to design or
debug relational databases in the fields of software engineering, business information systems,
education and research.
ER diagrams are related to data structure diagrams (DSDs), which focus on the relationships of
elements within entities instead of relationships between entities themselves. ER diagrams also are
often used in conjunction with data flow diagrams (DFDs), which map out the flow of information for
processes or systems.

ER diagram for our school database:

Tables and columns:


As Tables(columns)

 Exam (exam_id, name, course_id)


 Course (course_id, name)
 Class (class_id, course_id, status)
 Teacher (teacher_id, email, phone, fname, lname, course_id)
 Books (book_id, name, author, availability, return_date, student_id)
 Course_student (student_id, course_id)
 Student (student_id, email, fname, lname, dob, phone, date_of_joining, parent_id)
 Exam_result (exam_id, student_id, course_id, result)
 Parent (parent_id, email, fname, lname, phone)
 Attendance (date, student_id, status)

How these tables share data with each other’s?


Using Primary key and Foreign key. Primary key ensures the data in specific column is unique and
Foreign key is a column or group of columns in a relational database table that provides link between
data in two tables.

What happens when we update a Primary Key in one table?


We should update all the foreign keys that reference the updated key.

Is it safe to update a Primary key in a production database?


Yes, by using locks. So other users who have access to modifying the information are prevented from
doing so till the current user releases the lock in order to maintain integrity of the data.

File to create database with sample date:

List of Queries:

#Get all student details of the school

select * from student;


#Get the student detials who are of class 1

select * from student where student_id IN (select student_id from course_student where course_id IN
(select course_id from class where class_id = 1));

#Get the student details who are of course Course1

select * from student where student_id IN (select student_id from course_student where course_id IN
(select course_id from course where name like "course1"));

#Get the parent details of the student 15

select * from parent where parent_id IN (select parent_id from student where student_id = 15);

#Get the teacher details who are of course 4


select * from teacher where course_id = 4;

#Get the available books

select * from books where availability = 1; (resulted 200 rows)

#Get the student details who borrowed the book "Aperiam fugit aut consectetur ve"

select CONCAT(fname,CONCAT(" ", lname)) AS NAME from student where student_id IN (select
student_id from books where name = 'Quia sit eum quis.');

#Get the number of students who attended the clasees on date "2022-03-31"

select count(*) from attendance where status = 1 AND DATE = "2022-03-31";

#Get the exam results of the class 2


select student.student_id, CONCAT(student.fname, CONCAT(" ",student.lname)) AS NAME,
exam_result.result from exam_result RIGHT JOIN student ON exam_result.student_id =
student.student_id where course_id IN (select course_id from class where class_id = 2);

#Get the student details who failed in the exams

select student.student_id, CONCAT(student.fname, CONCAT(" ",student.lname)) AS NAME,


exam_result.result from exam_result RIGHT JOIN student ON exam_result.student_id =
student.student_id where result =0;

#Get the student details who failed in the exams and borrowed a book

select student.student_id, CONCAT(student.fname, CONCAT(" ",student.lname)) AS NAME,


exam_result.result from exam_result RIGHT JOIN student ON exam_result.student_id =
student.student_id where result = 0 AND student.student_id IN (select student_id from books where
availability = 0);

#Get the return date of the book borrowed by student 15

select return_date from books where student_id = 16 AND availability = 0;

#Get the exam name and corresponding course name where most of the students failed

select exam.name, course.name from exam RIGHT JOIN course on exam.course_id = course.course_id
where exam.exam_id IN (select exam_id from (select DISTINCT exam_id, SUM(CASE WHEN result = 0
THEN 1 ELSE 0 END) as count from exam_result where result = 0 group by exam_id order by count desc
limit 1) as T);

#Get the teacher and course name where most of the students failed

select exam.name as exam_name, course.name as course_name, CONCAT(teacher.fname, CONCAT("


",teacher.lname)) as teacher_name from exam RIGHT JOIN course on exam.course_id =
course.course_id LEFT JOIN teacher ON teacher.course_id=course.course_id where exam.exam_id IN
(select exam_id from (select DISTINCT exam_id, SUM(CASE WHEN result = 0 THEN 1 ELSE 0 END) as
count from exam_result where result = 0 group by exam_id order by count desc limit 1) as T);

#Get the parent details of the students who failed in the exams

select CONCAT(student.fname , CONCAT(" ", student.lname)) as student_name, CONCAT(parent.fname ,


CONCAT(" ", parent.lname)) as parent_name,parent.email as parent_email,parent.phone as
parent_phone from parent RIGHT JOIN student on parent.parent_id = student.student_id where
student.student_id IN (select student_id from exam_result where result = 0);

You might also like