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

University Management System Solution

Uploaded by

vikaskr733
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

University Management System Solution

Uploaded by

vikaskr733
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

University Management System

1.1 University Management System Informal


Description
ABC University is a large institution with several campuses. Each campus has a different
name, address, distance to the city center and the only bus running to the campus. Each
campus has one club. The name of the club, the building in which the club is located, the
phone number of the club and the multiple sports which club offers, should all be recorded.

The University consists of a number of faculties, such as the Art Faculty, the Science Faculty,
and so on. Each faculty has a name, dean and building. A faculty may be divided into a
number of schools, for example, the Science Faculty has a School of Physics and a School
of Chemistry. Each school belongs to one faculty only and is located on just one campus,
but one campus maybe the location of many schools.

Every school has name and an building assigned to. Each school offers different programmes
and each programme can be offered by only one school. Each programme has a unique code,
title, level and duration. Each programme comprises several courses, different programmes
have different courses. Each course has a unique code and course title. Some courses may
have one or more prerequisite courses and one course can be the prerequisite course of some
other courses.

Each of the students is enrolled in a single programme of study which involves a fixed core
of courses specific to that programme as well as a number of electives taken from other
programmes. Students work on courses and are awarded a grade in any course if he/she
passes the course. Otherwise the student has to re-take the failed course. The system needs
to record the year and term in which the course was taken and the grade awarded to the
student. Every student has a unique ID. The system also keeps the student name, birthday
and the year he/she enrolled in the course.

The school employs lecturers to teach the students. A lecturer is allowed to work for one
school only. Each lecturer is assigned an ID which is unique across the whole university.
The system keeps the lecturer’s name, title and the office room. A supervisor maybe in
charge of several lecturers, but a lecturer, however reports to only one supervisor. A lecturer
can teach many different courses. A course may also have been taught by many different
lecturers.

The university is operated by committees. Each faculty has to have a number of committees
with the same titles across the university, such as the Faculty Executive, the Post Graduate
Studies Committee, the Health and Sanity Committee, and so on. The committees meet
regularly, such as weekly or monthly. The frequency is determined by the faculty involved.
A committee’s members are all lecturers. A lecturer may be a member of several committees.
Task1

The basic steps in producing the Logical Model are:

• Specify all entities.


• Find attributes for each entity.
• Specify primary keys for all entities.
• Find the relationships between different entities.
• Resolve many-to-many relationships.
• Perform normalization.

The basic steps in producing the Physical Model are:

• Convert entities into tables.


• Convert relationships into foreign keys.
• Convert attributes into columns.
• Modify the physical data model based on physical constraints/requirements.
1.2 University System Logical Model
1.3 University System Physical Model
1.4 University System Schema

CREATE TABLE CAMPUS(


CMPSNM VARCHAR(20) NOT NULL,
CMPSADDR VARCHAR(50),
DIST NUMERIC(8, 2),
BUSNO VARCHAR(10),
PRIMARY KEY (CMPSNM)
)
CREATE TABLE FACULTY(
FACNM VARCHAR(30) NOT NULL,
DEANNM VARCHAR(20),
FACBLD VARCHAR(20),
PRIMARY KEY (FACNM)
)
CREATE TABLE SCHOOL(
SCHLNM VARCHAR(30) NOT NULL,
CMPSNM VARCHAR(20) NOT NULL,
FACNM VARCHAR(30) NOT NULL,
SCHLBLD VARCHAR(20),
PRIMARY KEY (SCHLNM),
FOREIGN KEY (CMPSNM) REFERENCES CAMPUS (CMPSNM),
FOREIGN KEY (FACNM) REFERENCES FACULTY (FACNM)
)
CREATE TABLE PROGRAMME(
PROGCD CHAR(11) NOT NULL,
SCHLNM VARCHAR(30) NOT NULL,
PROGTITL VARCHAR(20),
PROGLVL VARCHAR(10),
PROGLEN VARCHAR(20),
PRIMARY KEY (PROGCD),
FOREIGN KEY (SCHLNM) REFERENCES SCHOOL (SCHLNM)
)
CREATE TABLE STUDENT(
STUID INTEGER NOT NULL,
PROGCD CHAR(11) NOT NULL,
STUNM VARCHAR(30),
STUBRTH DATE,
YRENRL INTEGER,
PRIMARY KEY (STUID),
FOREIGN KEY (PROGCD) REFERENCES PROGRAMME (PROGCD)
)
CREATE TABLE COURSE(
CRSECD CHAR(10) NOT NULL,
PROGCD CHAR(11) NOT NULL,
CRSETITL VARCHAR(20),
PRIMARY KEY (CRSECD),
FOREIGN KEY (PROGCD) REFERENCES PROGRAMME (PROGCD)
)
CREATE TABLE COURSE_STUDENT(
CRSECD CHAR(10) NOT NULL,
STUID INTEGER NOT NULL,
YRTKN CHAR(4),
SEMTKN VARCHAR(20),
GRDAWRD VARCHAR(10),
PRIMARY KEY (CRSECD, STUID),
FOREIGN KEY (STUID) REFERENCES STUDENT (STUID),
FOREIGN KEY (CRSECD) REFERENCES COURSE (CRSECD)
)
CREATE TABLE CLUB(
CLBNM VARCHAR(20) NOT NULL,
CMPSNM VARCHAR(20) NOT NULL,
CLBBLD VARCHAR(20),
PHNNO CHAR(12),
PRIMARY KEY (CLBNM),
FOREIGN KEY (CMPSNM) REFERENCES CAMPUS (CMPSNM)
)
CREATE TABLE SPORT(
SPRTNM VARCHAR(20) NOT NULL,
CLBNM VARCHAR(20) NOT NULL,
PRIMARY KEY (SPRTNM, CLBNM),
FOREIGN KEY (CLBNM) REFERENCES CLUB (CLBNM)
)
CREATE TABLE PRE_COURSE(
CRSECD CHAR(10) NOT NULL,
PRECRSECD CHAR(10) NOT NULL,
PRIMARY KEY (CRSECD, PRECRSECD),
FOREIGN KEY (CRSECD) REFERENCES COURSE (CRSECD),
FOREIGN KEY (PRECRSECD) REFERENCES COURSE (CRSECD)
)
CREATE TABLE LECTURER(
STFID INTEGER NOT NULL,
SCHLNM VARCHAR(30) NOT NULL,
SUPID INTEGER,
LECTNM VARCHAR(20),
LECTTITL VARCHAR(30),
OFFROOM VARCHAR(10),
PRIMARY KEY (STFID),
FOREIGN KEY (SCHLNM) REFERENCES SCHOOL (SCHLNM),
FOREIGN KEY (SUPID) REFERENCES LECTURER (STFID)
)
CREATE TABLE LECTURER_COURSE(
STFID INTEGER NOT NULL,
CRSECD CHAR(10) NOT NULL,
PRIMARY KEY (STFID, CRSECD),
FOREIGN KEY (CRSECD) REFERENCES COURSE (CRSECD),
FOREIGN KEY (STFID) REFERENCES LECTURER (STFID)
)
CREATE TABLE COMMITTEE(
COMMTITL VARCHAR(30) NOT NULL,
FACNM VARCHAR(30) NOT NULL,
MTFREQ VARCHAR(10),
PRIMARY KEY (COMMTITL, FACNM),
FOREIGN KEY (FACNM) REFERENCES FACULTY (FACNM)
)
CREATE TABLE COMMITTEE_LECTURER(
STFID INTEGER NOT NULL,
COMMTITL VARCHAR(30) NOT NULL,
FACNM VARCHAR(30) NOT NULL,
PRIMARY KEY (STFID, COMMTITL, FACNM),
FOREIGN KEY (STFID) REFERENCES LECTURER (STFID),
FOREIGN KEY (COMMTITL, FACNM) REFERENCES COMMITTEE (COMMTITL,
FACNM)
)

1.5 University System Interactive Queries

Query 1: List all the schools are located in 'Toronto Campus', and sort them by school
name.

SELECT SCHLNM AS SCHOOL_NAME


FROM SCHOOL
WHERE CMPSNM = 'Toronto Campus'
ORDER BY SCHLNM

Query 2: List all the programmes provided by 'science faculty'.

SELECT P.PROGCD AS PROGRAMME_CODE


FROM PROGRAMME P
INNER JOIN SCHOOL S ON P.SCHLNM = S.SCHLNM
INNER JOIN FACULTY F ON S.FACNM = F.FACNM
WHERE F.FACNM = 'science faculty'

Query 3: Give all the names of the lecturers who are the members of the committee and
sort by their name.

SELECT DISTINCT L.LECTNM AS LECTURER_NAME


FROM COMMITTEE_LECTURER CL
JOIN LECTURER L ON CL.STFID = L.STFID
ORDER BY L.LECTNM

Query 4: List all supervisor's name and the name of the lecturer they manage. Please sort
by supervisor name and lecturer name.

SELECT SUP.LECTNM AS SUPERVISOR_NAME,L.LECTNM AS LECTURER_NAME


FROM LECTURER SUP
INNER JOIN LECTURER L ON SUP.STFID = L.SUPID
ORDER BY SUP.LECTNM,L.LECTNM

Query 5: Give all the lecturers who are not the member of the committee.
SELECT STFID AS
STAFF_ID FROM LECTURER
WHERE STFID NOT IN (SELECT DISTINCT STFID FROM COMMITTEE_LECTURER)

Query 6: Give the total number of courses for each programme.


SELECT PROGCD AS PROGRAMME_CODE,COUNT(CRSECD) AS
NUMBER_OF_COURSE FROM COURSE
GROUP BY
PROGCD

Query 7: Give all the lecturers with the courses they are teaching. Sort by lecturer name.
SELECT L.LECTNM AS LECTURER_NAME,C.CRSETITL AS
COURSE_TITLE FROM LECTURER_COURSE LC
INNER JOIN LECTURER L ON LC.STFID = L.STFID
INNER JOIN COURSE C ON LC.CRSECD = C.CRSECD
ORDER BY L.LECTNM

Query 8: Give all the course titles and their corresponding prerequisite course titles.
SELECT C1.CRSETITL AS COURSE_TITLE,C2.CRSETITL AS
PRE_COURSE_TITLE FROM PRE_COURSE PC
INNER JOIN COURSE C1 ON PC.CRSECD = C1.CRSECD
INNER JOIN COURSE C2 ON PC.PRECRSECD =
C2.CRSECD

Query 9: Give the top 5 courses which have more students involved.
SELECT C.CRSECD AS COURSE_CODE,COUNT(SS.STUID) AS
NUMBER_OF_STUDENTS FROM COURSE_STUDENT SS
LEFT JOIN COURSE S ON SS.SUBJCD = S.SUBJCD
LEFT JOIN COURSE C ON S.CRSECD = C.CRSECD
GROUP BY C.CRSECD
ORDER BY NUMBER_OF_STUDENTS
DESC FETCH FIRST 5 ROWS ONLY

Query 10: Give any of the prerequisite courses was not took by any of the students
who enrolled into the university in 2010, and were taking the courses in
2011.

SELECT DISTINCT STUID,PC.PRECRSECD AS


PRE_COURSE FROM COURSE_STUDENT CS
RIGHT JOIN PRE_COURSE PC ON CS.CRSECD = PC.CRSECD
WHERE STUID IN (SELECT STUID FROM STUDENT WHERE YRENRL = 2010)
AND YRTKN = 2011
EXCEP
T
SELECT
STUID,CRSECD
FROM
COURSE_STUDENT
WHERE STUID IN (SELECT STUID FROM STUDENT WHERE YRENRL = 2010)
AND YRTKN = 2010

You might also like