Download as odt, pdf, or txt
Download as odt, pdf, or txt
You are on page 1of 7

ST.

XAVIER’S COLLEGE
(Affiliated to Tribhuvan University)
Maitighar, Kathmandu

Database Management System #6

SUBMITTED BY:
Sandesh Pathak
018BSCIT035

SUBMITTED TO:
Sarjan Shrestha
Supervisor/Lecturer
Department of Computer Science
Edusanjal.com is a website that aims to provide complete details of education in Nepal. This
website has a collection of colleges, universities, courses, programmes and many other
information related to higher education. There are several colleges listed on this website with all
of their relevant information. Those who are confused about a college or a course can browse
this site and research on different colleges and universities.

1 Entity Relationship Diagram (ERDs)


2 Relation Schema Representation
SQL SCRIPT TO DEFINE THE DATABASE

---------------------------------
-- The DDL script to replicate the database
-- of edusanjal.com
---------------------------------

CREATE DATABASE
IF NOT EXISTS edusanjal;

USE edusanjal;

----------------------------------
----- TABLES FOR COURSES
----------------------------------

CREATE TABLE nationality(


nationality_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
nationality_type VARCHAR(25) NOT NULL
);

CREATE TABLE levels(


level_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
level_name VARCHAR(100) NOT NULL
nationality_id INT NOT NULL,
FOREIGN KEY (nationality_id) REFERENCES
nationality(nationality_id)
);

CREATE TABLE faculties(


faculty_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
faculty_name VARCHAR(100) NOT NULL,
nationality_id INT NOT NULL,
level_id INT NOT NULL,
FOREIGN KEY (nationality_id) REFERENCES
nationality(nationality_id),
FOREIGN KEY (level_id) REFERENCES levels(level_id)
)

----------------------------------
----- TABLES FOR COLLEGES
----------------------------------
CREATE TABLE university(
university_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
university_name VARCHAR(100) NOT NULL,
nationality_id INT NOT NULL,
FOREIGN KEY nationality_id REFERENCES nationality(nationality_id)
);

CREATE TABLE ownership_type(


ownership_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
ownership_name VARCHAR(100) NOT NULL
);

CREATE TABLE category(


category_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
category_name VARCHAR(100) NOT NULL
);

CREATE TABLE district(


district_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
district_name VARCHAR(100)
);
CREATE TABLE course(
course_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
course_name VARCHAR(255)
);

CREATE TABLE college(


college_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
college_name VARCHAR(255) NOT NULL,
ownership_id INT NOT NULL,
university_id INT NOT NULL,
category_id INT NOT NULL,
district_id INT NOT NULL,
course_id INT NOT NULL,

FOREIGN KEY ownership_id REFERENCES ownership_type(ownership_id),


FOREIGN KEY university_id REFERENCES university(university_id),
FOREIGN KEY category_id REFERENCES category(category_id),
FOREIGN KEY district_id REFERENCES district(district_id),
FOREIGN KEY course_id REFERENCES course(course_id)
);

You might also like