0% found this document useful (0 votes)
5 views4 pages

Training 1

The document outlines the SQL schema for a database containing tables related to a training program, including persons, semesters, programs, grades, departments, specializations, faculties, courses, students, attendance, results, and exam schedules. Each table includes specific constraints such as primary keys, foreign keys, and checks to ensure data integrity. The schema is designed to manage various aspects of an educational institution's operations.

Uploaded by

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

Training 1

The document outlines the SQL schema for a database containing tables related to a training program, including persons, semesters, programs, grades, departments, specializations, faculties, courses, students, attendance, results, and exam schedules. Each table includes specific constraints such as primary keys, foreign keys, and checks to ensure data integrity. The schema is designed to manage various aspects of an educational institution's operations.

Uploaded by

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

-----------------------------------------------------------------------------------

-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE training1.persons
(
person_id NUMBER(5) ,
person_name VARCHAR2(50) constraint nn_persons_name not null,
person_email VARCHAR2(50) ,
person_contact_no VARCHAR2(15),
person_gender CHAR(1),
person_dob DATE,
CONSTRAINT pk_persons PRIMARY KEY(person_id),
CONSTRAINT uk_persons_email UNIQUE(person_email),
CONSTRAINT uk_persons_contact UNIQUE(person_contact_no),
CONSTRAINT ck_persons_gender CHECK(person_gender in ('M', 'F', 'O'))
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE semesters
(
sem_id NUMBER(2),
sem_desc VARCHAR2(10),
CONSTRAINT pk_semesters_id PRIMARY KEY(sem_id),
CONSTRAINT ck_semesters_desc CHECK(LENGTH(sem_id)<=10)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE programs
(
program_id NUMBER(3),
program_name VARCHAR2(30),
CONSTRAINT pk_program_id PRIMARY KEY(program_id)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE grades
(
grade_id CHAR(1),
grade_desc VARCHAR2(10),
CONSTRAINT pk_grades_id PRIMARY KEY(grade_id),
CONSTRAINT ck_grades_desc CHECK(grade_id in ('S', 'A', 'B', 'C', 'D', 'E',
'P', 'F'))
);
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE departments
(
department_id NUMBER(3),
department_name VARCHAR2(30) NOT NULL,
department_hod VARCHAR2(10),
department_budget NUMBER(10, 2),
CONSTRAINT pk_department_id PRIMARY KEY(department_id)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE specilizations
(
specilization_id NUMBER(3),
specilization_name VARCHAR2(50),
department_id NUMBER(3),
program_id NUMBER(3),

CONSTRAINT pk_specilizations_id PRIMARY KEY(specilization_id),


CONSTRAINT fk01_specilizations_department FOREIGN KEY(department_id)
REFERENCES departments(department_id),
CONSTRAINT fk02_specilizations_programs FOREIGN key(program_id) REFERENCES
programs(program_id)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE faculties
(
faculty_id VARCHAR2(10),
date_of_joining DATE,
faculty_designation VARCHAR2(30),
person_id NUMBER(5),
department_id NUMBER(3),

CONSTRAINT pk_faculties_id PRIMARY KEY(faculty_id),


CONSTRAINT fk01_faculties_person_id FOREIGN KEY(person_id) REFERENCES
persons(person_id),
CONSTRAINT fk02_faculties_department_id FOREIGN KEY(department_id)
REFERENCES departments(department_id)
);

ALTER TABLE departments


ADD CONSTRAINT CK_departments_hod
FOREIGN KEY(department_hod) REFERENCES faculties(faculty_id);
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE courses
(
course_id NUMBER(3),
course_name VARCHAR2(30),
faculty_id VARCHAR2(10),
course_credits NUMBER(2),
department_id NUMBER(3),
specilization_id NUMBER(3),

CONSTRAINT pk_courses_id PRIMARY KEY(course_id),


CONSTRAINT pk_courses_credits CHECK(LENGTH(course_credits) < 10),
CONSTRAINT fk01_courses_faculty_id FOREIGN KEY(faculty_id) REFERENCES
faculties(faculty_id),
CONSTRAINT fk02_courses_department_id FOREIGN KEY(department_id)
REFERENCES departments(department_id),
CONSTRAINT fk03_courses_specilization_id FOREIGN KEY(specilization_id)
REFERENCES courses(course_id)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE students
(
student_id VARCHAR2(10),
person_id NUMBER(3),
program_id NUMBER(3),
department_id NUMBER(3),
year_of_joining NUMBER(4),
specilization_id NUMBER(3),

CONSTRAINT pk_students_id PRIMARY KEY(student_id),


CONSTRAINT fk01_students_persons_id FOREIGN KEY(person_id) REFERENCES
persons(person_id),
CONSTRAINT fk02_students_program_id FOREIGN KEY(program_id) REFERENCES
programs(program_id),
CONSTRAINT fk03_students_department_id FOREIGN KEY(department_id)
REFERENCES departments(department_id),
CONSTRAINT fk04_students_specilization_id FOREIGN KEY(specilization_id)
REFERENCES specilizations(specilization_id)
);

-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE attendance
(
student_id VARCHAR2(10),
percentage NUMBER(5, 2),
course_id NUMBER(3),
eligibility CHAR(1),

CONSTRAINT ck_attendance_percentage CHECK(percentage <= 100),


CONSTRAINT ck_attendace_eligibility CHECK(eligibility in ('Y', 'N')),
CONSTRAINT pk_attendace_sid_cid PRIMARY KEY(student_id, course_id),
CONSTRAINT fk01_attendance_student_id FOREIGN KEY(student_id) REFERENCES
students(student_id),
CONSTRAINT fk02_attendance_course_id FOREIGN KEY(course_id) REFERENCES
courses(course_id)
);
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE results (
grade_id CHAR(1),
marks NUMBER(5, 2),
course_id NUMBER(3),
student_id VARCHAR2(10),
sem_id NUMBER(2),

CONSTRAINT ck_results_marks CHECK (marks <= 100),


CONSTRAINT pk_results_cid_sid_sem_id PRIMARY KEY (grade_id, course_id,
student_id, sem_id),
CONSTRAINT fk01_results_grade_id FOREIGN KEY (grade_id) REFERENCES
grades (grade_id),
CONSTRAINT fk02_results_course_id FOREIGN KEY (course_id) REFERENCES
courses (course_id),
CONSTRAINT fk03_results_student_id FOREIGN KEY (student_id) REFERENCES
students (student_id),
CONSTRAINT fk04_results_sem_id FOREIGN KEY (sem_id) REFERENCES
semesters (sem_id)
);
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------------------------
CREATE TABLE exam_schedules
(
course_id NUMBER(3),
exam_date DATE,
exam_time TIMESTAMP,
faculty_id VARCHAR2(10),

CONSTRAINT fk01_exam_course_id FOREIGN KEY(course_id) REFERENCES


courses(course_id),
CONSTRAINT fk02_exam_faculty_id FOREIGN KEY(faculty_id) REFERENCES
faculties(faculty_id)
);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy