bhikas dbms 4

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name – Vikas

Roll no.-2202161630115

EXPEIMENT NO.-4

OBJECTIVE:- create a university database for maintaining information releated to student , corse,and
grade. The student have following attributes name,stdno,class,measure. courses(course name,course
no.,department) section(section id,course no, semester , year, instructor), grade
maintained(studentno,section id,grade), prerequistes(course no,prerequistes id).

SQL QUERY:-

CREATE TABLE Student (

StdNo INT PRIMARY KEY,

Name VARCHAR(100),

Class VARCHAR(50),

Measure VARCHAR(50) );

CREATE TABLE Course (

CourseNo INT PRIMARY KEY, CourseName VARCHAR(100),

Department VARCHAR(50) );

CREATE TABLE Prerequisites (

CourseNo INT,

PrerequisiteID INT,

PRIMARY KEY (CourseNo, PrerequisiteID),

FOREIGN KEY (CourseNo) REFERENCES Course(CourseNo),

FOREIGN KEY (PrerequisiteID) REFERENCES Course(CourseNo));

CREATE TABLE Section (

SectionID INT PRIMARY KEY,

CourseNo INT,

Semester VARCHAR(20),

Year INT,
Instructor VARCHAR(100),

FOREIGN KEY (CourseNo) REFERENCES Course(CourseNo));

CREATE TABLE Grade (

StdNo INT,

SectionID INT,

Grade CHAR(2),

PRIMARY KEY (StdNo, SectionID),

FOREIGN KEY (StdNo) REFERENCES Student(StdNo),

FOREIGN KEY (SectionID) REFERENCES Section(SectionID));

INSERT INTO Student (StdNo, Name, Class, Measure)

VALUES

(1, 'Prashant', '3B', 'Computer Science'),

(2, 'Piyush', '3B', 'Computer Science');

INSERT INTO Course (CourseNo, CourseName, Department)

VALUES

(101, 'DBMS', 'AI&DS'),

(102, 'BIA', 'AI&DS');

INSERT INTO Section (SectionID, CourseNo, Semester, Year, Instructor)

VALUES

(1, 101, '5th', 2024, 'Mr.Himanshu '),

(2, 102, '5th', 2024, 'Hemant Yadav');

INSERT INTO Grade (StdNo, SectionID, Grade)

VALUES

(1, 1, 'A'),

(2, 2, 'B');
INSERT INTO Prerequisites (CourseNo, PrerequisiteID)

VALUES

(101, 102);

SELECT * FROM Student;

SELECT * FROM Course; SELECT * FROM Section;

SELECT * FROM Grade;

SELECT * FROM Prerequisites;

You might also like