0% found this document useful (0 votes)
67 views13 pages

DBMS Project

This document describes a student project to create a University Management System database. The project involves: 1. Creating entity relationship diagrams to model the university data. This includes entities like courses, subjects, students, and teachers. 2. Designing tables in a MySQL database based on the entity relationship diagrams. Tables are created for courses, subjects, students, teachers, and relationships between entities. 3. Populating the tables with sample data and writing SQL queries to retrieve and manipulate the data, such as listing students in particular courses or teachers teaching multiple subjects. The goal of the project is to apply concepts of database design and management like entity relationships, table structures, and SQL queries to a real world domain

Uploaded by

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

DBMS Project

This document describes a student project to create a University Management System database. The project involves: 1. Creating entity relationship diagrams to model the university data. This includes entities like courses, subjects, students, and teachers. 2. Designing tables in a MySQL database based on the entity relationship diagrams. Tables are created for courses, subjects, students, teachers, and relationships between entities. 3. Populating the tables with sample data and writing SQL queries to retrieve and manipulate the data, such as listing students in particular courses or teachers teaching multiple subjects. The goal of the project is to apply concepts of database design and management like entity relationships, table structures, and SQL queries to a real world domain

Uploaded by

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

DELHI TECHNOLOGICAL UNIVERSITY

DBMS(CO-202)
PROJECT

MADE BY:
Name​-AVIRAL YADAV
Roll No​.-2K18/CO/102
Topic​- University Management System
A2 Group 2
Aim​: The aim of this project is to familiarise the students with the various
concepts of database management such as Entity Relationship Model and
the use of basic query language commands and clauses of Data Definition
Language(DDL) and Data Manipulation Language(DML).

Problem​: To create a University Management System and give a brief


description about the ER models, the queries which are required to create
it. The report should contain -

1. Description of the model


2. ER models
3. Tables from ER Models
4. Creation/Updation of Tables(Sample Entries)
5. Some simple queries on the database after its creation.

DESCRIPTION

With the ever increasing advancement in Technology, handling the records


of the students​ ​and the staff members has become way much easier.

A University Management System provides a basic database to store the


information of the branch,subjects ,students and teachers in the university.

Here in this database we have-

1. Course table -​ stores the various courses/branches that the


University offers.
2. Subject Table- ​stores the different subjects that are present in each
branch offered by the University.
3. Student Table- ​stores the information of the students of the
University(for ex- their address,their course in which they are
enrolled, their roll number etc.)
4. Teachers Table- ​the information of the teachers of the University(for
ex- the department in which they are employed, the subjects they
teach , their roll number etc.)
ER DIAGRAM
An Entity Relationship Model displays the various entities involved in the
system, their attributes and the relationship between them.

Entity​: ​An Entity is a thing or an object that is distinguishable from


others,or which can be uniquely identified.

Attribute​: ​An Attribute describes the various elementary features of the


entity.

Relationship​: ​A Relationship is the association or the sharing of data


between two separate entities.
Converting ER diagram to tables
SOME PROPERTIES OBSERVED FROM THE TABLE:

RELATIONSHIPS IN THE TABLE-

1. Student Teacher - MANY MANY - ​This is because many teachers


can teach the same student or there may also be a possibility that
many students study from the same teacher.
2. Teacher-Subject - MANY MANY - ​This is because many Teachers
can teach the same subject or there may be a possibility that many
subjects can be taught by the same teacher.
3. Student- Course - ONE ONE - ​This is because a student can enroll
in only one branch.For the simplicity of the database and
understanding , I have assumed that a course may have only one
student. Although generally there may be a case where their many
students enrolled within the same course.
4. Course- Subject - ONE MANY - ​This is because of the fact that
there can be many subjects in a course but not the other way round.

COMPOSITE ATTRIBUTES-

We can observe from the ER diagram that the Composite attributes are-

1. Door
2. Street
3. City
4. State
5. Country

And it’s all coming from the address attribute.


Creating Database
mysql> CREATE DATABASE DBMSPROJECT ; 
Query OK, 1 row affected (0.01 sec) 
mysql> T 
Database changed 
 

Creating Tables
TABLE COURSE​(for storing the courses/branches)
TABLE CREATION:
mysql> CREATE TABLE COURSE( 
-> COURSE_ID VARCHAR(10) PRIMARY KEY NOT NULL, 
-> COURSE_NAME VARCHAR(30) NOT NULL, 
-> ); 
Query OK, 0 rows affected (0.02 sec) 

TABLE ENTRY:
mysql> INSERT INTO COURSE VALUES 
-> ('CO','Computer Science'), 
-> ('EC','Electronics and Communication'), 
-> ('CE','Civil Engineering'), 
-> ('BT','Bio-Tech Engineering'); 
Query OK, 4 rows affected (0.01 sec) 
Records: 4 Duplicates: 0 Warnings: 0 
 
mysql> SELECT * FROM COURSE; 
 

 
 
 
 
TABLE SUBJECT(​for storing the subjects in a course)
TABLE CREATION:
mysql> CREATE TABLE SUBJECT( 
-> SUBJECT_ID VARCHAR(10) PRIMARY KEY NOT NULL, 
-> COURSE_ID VARCHAR(10) NOT NULL, 
-> SUBJECT_NAME VARCHAR(30) NOT NULL, 
-> FOREIGN KEY(COURSE_ID) REFERENCES COURSE(COURSE_ID) 
-> ); 
Query OK, 0 rows affected (0.02 sec) 
 
TABLE ENTRY: 
mysql> INSERT INTO SUBJECT VALUES 
-> ('CO_101','CO','Operating Systems'), 
-> ('CO_102','CO','DBMS'), 
-> ('CO_103','CO','Digital Electronics'), 
-> ('EC_101','EC','Digital Electronics'), 
-> ('EC_102','EC','Analog Electronics'), 
-> ('CE_101','CE','Building and Construction'), 
-> ('CE_102','CE','Earthquake Proofing'), 
-> ('BT_101','BT','Biology'), 
-> ('BT_102','BT','Marine Sciences'); 
Query OK, 9 rows affected (0.00 sec) 
Records: 9 Duplicates: 0 Warnings: 0 
 
mysql> SELECT * FROM SUBJECT; 

 
 
TABLE STUDENT​(for storing the information of students)
TABLE CREATION:
mysql> CREATE TABLE STUDENT( 
-> STUDENT_ID VARCHAR(10) PRIMARY KEY NOT NULL, 
-> STUDENT_NAME VARCHAR(30) NOT NULL, 
-> COURSE_ID VARCHAR(10) NOT NULL, 
-> DOB DATE NOT NULL, 
-> DOOR VARCHAR(20) NOT NULL, 
-> STREET VARCHAR(20) NOT NULL, 
-> CITY VARCHAR(20) NOT NULL, 
-> STATE VARCHAR(20) NOT NULL, 
-> COUNTRY VARCHAR(20) NOT NULL, 
-> FOREIGN KEY (COURSE_ID) REFERENCES COURSE(COURSE_ID) 
-> ); 
Query OK, 0 rows affected (0.02 sec) 

TABLE ENTRY: 
mysql> INSERT INTO STUDENT VALUES 
-> ('CO102','AVIRAL YADAV','CO','2000-10-20','ABC','CIVIL 
LINES','DELHI','DELHI','INDIA'), 
-> ('EC001','HARSHIL PANWAR','EC','2000-10-3','GFG','SANTA 
CRUZ','MUMBAI','MAHARASHTRA','INDIA'), 
-> ('CE002','AJAY 
SHARMA','CE','2000-10-17','FGF','ALABAMA','ATLANTA','GEORGIA','USA'), 
-> ('BT103', 'NEEL 
GUPTA','BT','1999-7-10','DEE','SAKET','JAIPUR','RAJASTHAN','INDIA'); 
Query OK, 4 rows affected (0.01 sec) 
Records: 4 Duplicates: 0 Warnings: 0 
 
mysql> SELECT * FROM STUDENT; 
 

 
 

 
 
 
 
 
 
TABLE TEACHERS​(for storing the information of
teachers)

TABLE CREATION: 
mysql> CREATE TABLE TEACHERS( 
-> TEACHER_ID VARCHAR(10) PRIMARY KEY NOT NULL, 
-> TEACHER_NAME VARCHAR(30) NOT NULL, 
-> DEPARTMENT VARCHAR(10) NOT NULL, 
-> FOREIGN KEY (DEPARTMENT) REFERENCES COURSE(COURSE_ID) 
-> ); 
Query OK, 0 rows affected (0.03 sec) 
 
TABLE ENTRY: 
mysql> INSERT INTO TEACHERS VALUES 
-> ('001CO','ROHIT BENIWAL','CO'), 
-> ('002CO','RAHUL KUMAR','CO'), 
-> ('001EC','MS CHAUDHARY','EC'), 
-> ('002EC','MANIKA CHAUDHARY','EC'), 
-> ('001CE','R.V. RAO','CE'), 
-> ('001BT','N.S. RAGHAVAN','BT'); 
Query OK, 6 rows affected (0.01 sec) 
Records: 6 Duplicates: 0 Warnings: 0 
 
mysql> SELECT * FROM TEACHERS; 

 
 
 
 
 
 
Creating Derived Tables
TEACHER_SUBJECTS TABLE
Created to cover the case that many many relationships of teachers and the
subjects they teach.

Cases-

1. A teacher can teach multiple subjects


2. A subject can be taught by multiple teachers
3. A subject which is not taught by anyone

TABLE CREATION:
mysql> CREATE TABLE TEACHER_SUBJECTS( 
-> TEACHER_ID VARCHAR(10) NOT NULL , 
-> SUBJECT_ID VARCHAR(10) NOT NULL , 
-> FOREIGN KEY(SUBJECT_ID) REFERENCES SUBJECT(SUBJECT_ID), 
-> FOREIGN KEY(TEACHER_ID) REFERENCES TEACHERS(TEACHER_ID) 
-> ); 
Query OK, 0 rows affected (0.03 sec) 
TABLE ENTRY: 
mysql> INSERT INTO TEACHER_SUBJECTS VALUES 
-> ('001EC','CO_103'), 
-> ('001EC','EC_101'), 
-> ('002EC','EC_101'), 
-> ('002EC','EC_102'), 
-> ('001CO','CO_101'), 
-> ('002CO','CO_102'), 
-> ('001CE','CE_101'), 
-> ('001CE','CE_102'), 
-> ('001CE','CE_102'), 
-> ('001BT','BT_102'); 
Query OK, 10 rows affected (0.01 sec) 
Records: 10 Duplicates: 0 Warnings: 0 
TABLE STUDENT_TEACHER
Created to cover the case that many many relationships of teachers and the
students they teach.

Cases-

1. A teacher can teach multiple students


2. A student can be taught by multiple teachers
3. A student which is not taught by anyone

TABLE CREATION:
mysql> CREATE TABLE STUDENT_TEACHERS( 
-> STUDENT_ID VARCHAR(10) NOT NULL, 
-> TEACHER_ID VARCHAR(10) NOT NULL, 
-> SUBJECT_ID VARCHAR(10) NOT NULL, 
-> FOREIGN KEY(TEACHER_ID) REFERENCES TEACHERS(TEACHER_ID), 
-> FOREIGN KEY(SUBJECT_ID) REFERENCES SUBJECT(SUBJECT_ID), 
-> FOREIGN KEY(STUDENT_ID) REFERENCES STUDENT(STUDENT_ID) 
-> ); 
Query OK, 0 rows affected (0.01 sec) 

TABLE ENTRY: 
mysql> INSERT INTO STUDENT_TEACHERS VALUES  
-> ('CO102','001EC','CO_103'),  
-> ('EC001','002EC','EC_101'), 
-> ('EC001','002EC','EC_102'), 
-> ('CE002','001CE','CE_101'), 
-> ('CE002','001CE','CE_102'),  
-> ('BT103','001BT','BT_102'); 
Query OK, 6 rows affected (0.00 sec) 
Records: 6 Duplicates: 0 Warnings: 0 

 
 
 
 
SQL QUERIES
1. Displaying the details of all students of CO and EC branch
mysql> SELECT * FROM STUDENT WHERE (COURSE_ID='CO' OR COURSE_ID='EC'); 

2. List the details of all the Teachers of EC department teaching


more than 1 subject
mysql> SELECT * FROM TEACHERS T INNER JOIN TEACHER_SUBJECTS TS ON 
T.TEACHER_ID=TS.TEACHER_ID  
-> GROUP BY (T.TEACHER_ID)  
-> HAVING COUNT(T.TEACHER_ID)>1 AND (T.DEPARTMENT='EC'); 

 
 
3. List all the subjects of BT and CE department
mysql> SELECT * FROM SUBJECT WHERE COURSE_ID='BT' OR COURSE_ID='CE' ; 

 
 
 
4. List all the subjects studied by the student of CO branch
mysql> SELECT S.STUDENT_ID ,S.STUDENT_NAME,F.SUBJECT_ID,F.SUBJECT_NAME FROM 
STUDENT S   
-> INNER JOIN SUBJECT F 
-> ON F.COURSE_ID=S.COURSE_ID 
-> WHERE S.COURSE_ID='CO';  

5. List all the details of the subjects taught to the students of EC


branch and the teacher that teaches them
mysql> SELECT 
X.STUDENT_ID,S.STUDENT_NAME,X.SUBJECT_ID,F.SUBJECT_NAME,X.TEACHER_ID,T.TEACHER
_NAME FROM STUDENT_TEACHERS X 
-> INNER JOIN STUDENT S 
-> ON S.STUDENT_ID=X.STUDENT_ID 
-> INNER JOIN TEACHERS T 
-> ON X.TEACHER_ID=T.TEACHER_ID 
-> INNER JOIN SUBJECT F 
-> ON F.SUBJECT_ID=X.SUBJECT_ID 
-> WHERE S.STUDENT_ID LIKE "EC%"; 

 
 
CONCLUSION:

Through this case study, we have learnt how to convert our database and
create our tables from the ER diagram we created and to perform various
DDL and DML operations on our database to get the desired result.Overall
in this case study, we have learnt a practical approach to the database we
created.

You might also like