Вы находитесь на странице: 1из 12

Design problem: 1 Database And Management System

Submitted to: Submitted By: Miss Jaspreet Kaur Kumari Shikha Roll No. 20 SECTION: A1811

Problem: A database is to be designed for a University to monitor students' progress throughout their course of study. The students are reading for a degree (such as B.Tech, B.Tech (Hons) MCA, etc) within the framework of the modular system. The University provides a number of courses, each being characterized by its code, title, credit value, course coordinator, teaching staff and the department they come from. A course is co-ordinated by a course coordinator who shares teaching duties with one or more lecturers. A lecturer may teach more than one course. Students are free to choose any course they wish but the following rules must be observed: some courses require pre-requisites courses and some degree programs have compulsory courses. The database is also to contain some information about students including their numbers, names, addresses, degrees they read for, and their past performance (i.e. courses taken and examination results). Represent the complete scenario with the help of ER Diagram and design logical schema for this database. Also specify desirable constraints and justify your design approach even in a single small step.

Relation of entities
University offers degrees: one to many Degrees has departments: many to many relation Lecturer belongs to department: many to one relation Department offers courses: one to many relation Lecturer teach courses: many to many relation Instructor plan courses: one to one relation Instructor shares duties with lecturer: one to many relation Student studies courses: many to many relation Student acquire grades: many to one relation Some courses has prerequisite: one to one relation

Identification of Entities and Relations in ER Diagram


university(university_id, university_name,degree) courses (course_code, course_name, credit, hours, dept_id) department ( dept_id, dept_name, HOD)

lecturer (faculty_id, f_name, l_name, salary, phone_no, email, dept_id, inst_id) instructor(inst_id,f_name,l_name,salary,phone_no,email, course_code) students (reg_no, f_name, l_name, address, CGPA) grades ( registration_no, letter_grade, course_code) studies (course_code, reg_no) teach (faculty_id, course_code) prerequisites (course_code, prerequisites)

ER Diagram
(please see the attachment with this document for clear view of diagram)

Entity Relationship Key

courses
course_code course_name credit_value hours dept_id

department
dept_id dept_name H.O.D

lecturer
faculty_id f_name l_name salary phone_no email dept_id inst_id

instructor
inst_id f_name l_name salary phone_no email course_code

students
reg_no f_name l_name address grades

studies
course_code reg_no

teach
faculty_id course_code

prerequisites
course_code Prerequisites

Logical Schema of the ER diagram

Logical schema concentrates on describing entities, data types, relationships and constraints.
university Name UNIVERSITY_ID UNIVERSITY_NAME courses Name COURSE_CODE COURSE_NAME CREDIT HOURS DEPT_ID department Name DEPT_ID DEPT_NAME HOD lecturer Name FACULTY_ID F_NAME L_NAME SALARY PHONE_NO EMAIL DEPT_ID INST_ID Null? NOT NULL NOT NULL Type NUMBER(10) VARCHAR2(20) VARCHAR2(20) NUMBER(10) NUMBER(10) VARCHAR2(30) NUMBER(10) NUMBER(10) Null? NOT NULL NOT NULL Type NUMBER(10) VARCHAR2(20) VARCHAR2(10) Null? NOT NULL NOT NULL NOT NULL NOT NULL Type VARCHAR2(20) VARCHAR2(20) NUMBER(10) NUMBER(10) NUMBER(10) Null? NOT NULL NOT NULL Type NUMBER(10) VARCHAR2(20)

instructor Name Null? Type

INST_ID F_NAME L_NAME SALARY PHONE_NO EMAIL COURSE_CODE student Name REG_NO F_NAME L_NAME ADDRESS CGPA studies Name COURSE_CODE REG_NO

NOT NULL NOT NULL

NOT NULL

NUMBER(10) VARCHAR2(20) VARCHAR2(20) NUMBER(10) NUMBER(10) VARCHAR2(20) VARCHAR2(20) Type NUMBER(10) VARCHAR2(20) VARCHAR2(20) VARCHAR2(20) NUMBER(10)

Null? NOT NULL NOT NULL NOT NULL

Null?

Type VARCHAR2(20) NUMBER(10)

teach Name FACULTY_ID COURSE_CODE has Name COURSE_CODE PREREQUISITES Null? NOT NULL Type VARCHAR2(20) VARCHAR2(50) Null? Type NUMBER(10) VARCHAR2(20)

Entities with desirable constraints university( university_id <primary key>, university_name <NOT NULL constraint>) courses (course_code <primary key> , course_name <NOT NULL constraint>, credit <check greater than or equal to 1>, hours <check less than 60 hours> , dept_id <foreign key referred to department_id of department>)

department ( dept_id <primary key>, dept_name <NOT NULL constraint>, HOD) lecturer (faculty_id <primary key>, f_name <NOT NULL constraint>, l_name, salary, phone_no, email, dept_id <foreign key referred to department_id of department>, inst_id <foreign_key referred to inst_id of instructor>) instructor(inst_id <primary key>, f_name <NOT NULL constraint>, l_name, salary, phone_no, email<NOT NULL constraint>, course_code id <foreign key referred to course_code of courses>) students (reg_no<primary key>, f_name<NOT NULL constraint>, l_name, address<NOT NULL constraint>, CGPA) grades ( reg_no<foreign key referred to reg_no of student>, letter_grade, course_code <foreign key referred to course_code of courses>) Relations with desirable constraints studies (course_code <foreign key referred to course_code of courses>, reg_no <foreign key referred to reg_no of student>) teach (faculty_id <foreign_key referred to inst_id of instructor>,

course_code <foreign key referred to course_code of courses>) has (course_code <foreign key referred to course_code of courses>, prerequisites)

Creating tables
CREATE TABLE university( university_id VARCHAR(20) primary key, University_name VARCHAR(50) NOT NULL); CREATE TABLE courses ( course_code VARCHAR(20) Primary Key, course_name VARCHAR(20) NOT NULL, credit NUMBER(10) NOT NULL, hours NUMBER(10) NOT NULL, dept_id NUMBER(10) REFERENCES department(dept_id));

CREATE TABLE department( dept_id NUMBER(10) primary key, dept_name VARCHAR(20) NOT NULL, HOD VARCHAR(10));

CREATE TABLE instructor( inst_id NUMBER(10) primary key, f_name VARCHAR(20) NOT NULL, l_name VARCHAR(20), salary NUMBER(10), phone_no NUMBER(10), email VARCHAR(20) NOT NULL,

course_code VARCHAR(20) REFERENCES courses(course_code));

CREATE TABLE lecturer (faculty_id NUMBER(10) primary key, f_name VARCHAR(20) NOT NULL, l_name VARCHAR(20), salary NUMBER(10), phone_no NUMBER(10), email VARCHAR(30), dept_id NUMBER(10) REFERENCES department(dept_id), inst_id NUMBER(10) REFERENCES instructor(inst_id));

CREATE TABLE students ( reg_no NUMBER(10) primary key, f_name VARCHAR(20) NOT NULL, l_name VARCHAR(20), address VARCHAR(20) NOT NULL, CGPA NUMBER(10));

CREATE TABLE grades (registration_no NUMBER(10), letter_grade VARCHAR(2), course_code VARCHAR(20)); CREATE TABLE studies (course_code VARCHAR(20) REFERENCES courses(course_code), reg_no NUMBER(10) REFERENCES students(reg_no));

CREATE TABLE teach (faculty_id NUMBER(10) REFERENCES lecturer(faculty_id), course_code VARCHAR(20) REFERENCES courses(course_code)); CREATE TABLE has ( course_code VARCHAR(20) REFERENCES courses(course_code), prerequisites VARCHAR(50) NOT NULL);

Overview of tables created


university
university_id university_name

courses
course_code course_name credit_value hours dept_id

department
dept_id dept_name H.O.D

lecturer
faculty_id f_name l_name salary phone_no email dept_id inst_id

instructor
inst_id f_name l_name salary phone_no email course_code

students
reg_no f_name l_name address grades

teach
faculty_id course_code

studies
course_code reg_no

has
course_code Prerequisites

Вам также может понравиться