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

LAB1

The document contains SQL code to create tables and insert data into a university database with tables for students, professors, courses, departments, and grades. The code sets up the database schema and populates the tables with sample data.

Uploaded by

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

LAB1

The document contains SQL code to create tables and insert data into a university database with tables for students, professors, courses, departments, and grades. The code sets up the database schema and populates the tables with sample data.

Uploaded by

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

Course: CSE2004 Professor: ELAKIA E Slot: C1+C2

Exercise: LAB1 Name: Rishabh Varshney Submission date: 11th may

Code snippets:
Schema SQL:
CREATE TABLE Students (

student_id INT PRIMARY KEY,

student_name VARCHAR(50),

department VARCHAR(50),

age INT,

gender VARCHAR(10)

);

CREATE TABLE Professors (

professor_id INT PRIMARY KEY,

professor_name VARCHAR(50),

department VARCHAR(50),

specialization VARCHAR(50)

);

CREATE TABLE Courses (

course_id INT PRIMARY KEY,

course_name VARCHAR(50),

department VARCHAR(50),
credits INT,

professor_id INT,

FOREIGN KEY (professor_id) REFERENCES Professors (professor_id)

);

CREATE TABLE Departments (

department_id INT PRIMARY KEY,

department_name VARCHAR(50),

location VARCHAR(50)

);

CREATE TABLE Grades (

student_id INT,

course_id INT,

grade VARCHAR(2),

PRIMARY KEY (student_id, course_id),

FOREIGN KEY (student_id) REFERENCES Students (student_id),

FOREIGN KEY (course_id) REFERENCES Courses (course_id)

);

Query SQL:
INSERT INTO Students (student_id, student_name, department, age, gender)

VALUES

(1, 'John Doe', 'Computer Science', 21, 'Male'),

(2, 'Jane Smith', 'Electrical Engineering', 20, 'Female'),

(3, 'Janus Smite', 'Electrical IT', 21, 'male'),

(4, 'Emily Davis', 'Computer Science', 19, 'Female'),

(5, 'Michael Brown', 'Electrical Engineering', 21, 'Male'),

(6, 'Sophia Wilson', 'Mechanical Engineering', 20, 'Female'),

(7, 'James Taylor', 'Computer Science', 22, 'Male'),

(8, 'Olivia Moore', 'Electrical Engineering', 19, 'Female'),

(9, 'Ethan Anderson', 'Mechanical Engineering', 20, 'Male'),

(10, 'Ava Martinez', 'Computer Science', 21, 'Female'),


(11, 'Noah Thompson', 'Electrical Engineering', 22, 'Male'),

(12, 'Emma Garcia', 'Mechanical Engineering', 20, 'Female'),

(13, 'Liam Hernandez', 'Computer Science', 19, 'Male'),

(14, 'Isabella Miller', 'Electrical Engineering', 21, 'Female'),

(15, 'Mason Turner', 'Mechanical Engineering', 20, 'Male'),

(16, 'Sophia White', 'Computer Science', 21, 'Female'),

(17, 'Benjamin Lewis', 'Electrical Engineering', 20, 'Male'),

(18, 'Amelia Clark', 'Mechanical Engineering', 22, 'Female'),

(19, 'Jacob Hall', 'Computer Science', 19, 'Male'),

(20, 'Mia Young', 'Electrical Engineering', 21, 'Female');

INSERT INTO Professors (professor_id, professor_name, department, specialization)

VALUES

(1, 'Dr. Robert Anderson', 'Computer Science', 'Artificial Intelligence'),

(2, 'Dr. Emily Thompson', 'Electrical Engineering', 'Power Systems'),

(3, 'Dr. Michael Clark', 'Mechanical Engineering', 'Thermodynamics'),

(4, 'Dr. Sarah Johnson', 'Computer Science', 'Data Science'),

(5, 'Dr. Mark Davis', 'Electrical Engineering', 'Control Systems'),

(6, 'Dr. Jessica Wilson', 'Mechanical Engineering', 'Fluid Mechanics'),

(7, 'Dr. Christopher Taylor', 'Computer Science', 'Machine Learning'),

(8, 'Dr. Olivia Moore', 'Electrical Engineering', 'Signal Processing'),

(9, 'Dr. Ethan Anderson', 'Mechanical Engineering', 'Heat Transfer'),

(10, 'Dr. Ava Martinez', 'Computer Science', 'Natural Language Processing'),

(11, 'Dr. Noah Thompson', 'Electrical Engineering', 'Renewable Energy'),

(12, 'Dr. Emma Garcia', 'Mechanical Engineering', 'Robotics'),

(13, 'Dr. Liam Hernandez', 'Computer Science', 'Computer Networks'),

(14, 'Dr. Isabella Miller', 'Electrical Engineering', 'Wireless Communication'),

(15, 'Dr. Mason Turner', 'Mechanical Engineering', 'Mechatronics'),

(16, 'Dr. Sophia White', 'Computer Science', 'Computer Vision'),

(17, 'Dr. Benjamin Lewis', 'Electrical Engineering', 'Microelectronics'),

(18, 'Dr. Amelia Clark', 'Mechanical Engineering', 'Structural Analysis'),


(19, 'Dr. Jacob Hall', 'Computer Science', 'Database Systems'),

(20, 'Dr. Mia Young', 'Electrical Engineering', 'Power Electronics');

INSERT INTO Courses (course_id, course_name, department, credits, professor_id)

VALUES

(1, 'Introduction to Programming', 'Computer Science', 3, 1),

(2, 'Digital Electronics', 'Electrical Engineering', 4, 2),

(3, 'Thermodynamics', 'Mechanical Engineering', 3, 3),

(4, 'Data Structures and Algorithms', 'Computer Science', 3, 4),

(5, 'Power Systems Analysis', 'Electrical Engineering', 4, 5),

(6, 'Mechanics of Materials', 'Mechanical Engineering', 3, 6),

(7, 'Database Management Systems', 'Computer Science', 3, 7),

(8, 'Control Systems Engineering', 'Electrical Engineering', 4, 8),

(9, 'Thermal Engineering', 'Mechanical Engineering', 3, 9),

(10, 'Artificial Intelligence', 'Computer Science', 3, 10),

(11, 'Renewable Energy Systems', 'Electrical Engineering', 4, 11),

(12, 'Fluid Dynamics', 'Mechanical Engineering', 3, 12),

(13, 'Computer Networks', 'Computer Science', 3, 13),

(14, 'Digital Signal Processing', 'Electrical Engineering', 4, 14),

(15, 'Machine Design', 'Mechanical Engineering', 3, 15),

(16, 'Computer Vision and Pattern Recognition', 'Computer Science', 3, 16),

(17, 'Microelectronics and VLSI Design', 'Electrical Engineering', 4, 17),

(18, 'Finite Element Analysis', 'Mechanical Engineering', 3, 18),

(19, 'Software Engineering', 'Computer Science', 3, 19),

(20, 'Power Electronics', 'Electrical Engineering', 4, 20);

INSERT INTO Departments (department_id, department_name, location)

VALUES

(1, 'Computer Science', 'Building A'),

(2, 'Electrical Engineering', 'Building B'),

(3, 'Mechanical Engineering', 'Building C'),


(4, 'Civil Engineering', 'Building D'),

(5, 'Chemical Engineering', 'Building E'),

(6, 'Biomedical Engineering', 'Building F'),

(7, 'Aerospace Engineering', 'Building G'),

(8, 'Industrial Engineering', 'Building H'),

(9, 'Environmental Engineering', 'Building I'),

(10, 'Material Science and Engineering', 'Building J'),

(11, 'Architectural Engineering', 'Building K'),

(12, 'Information Technology', 'Building L'),

(13, 'Software Engineering', 'Building M'),

(14, 'Data Science', 'Building N'),

(15, 'Telecommunications Engineering', 'Building O'),

(16, 'Chemistry', 'Building P'),

(17, 'Physics', 'Building Q'),

(18, 'Mathematics', 'Building R'),

(19, 'Biology', 'Building S'),

(20, 'Business Administration', 'Building T');

INSERT INTO Grades (student_id, course_id, grade)

VALUES

(1, 2, 'B+'),

(2, 1, 'A-'),

(3, 3, 'B+'),

(4, 1, 'B-'),

(5, 2, 'A+'),

(6, 3, 'A'),

(7, 1, 'C+'),

(8, 2, 'A-'),

(9, 3, 'B+'),

(10, 1, 'A'),

(11, 2, 'B'),
(12, 3, 'A-'),

(13, 1, 'B+'),

(14, 2, 'B-'),

(15, 3, 'A+'),

(16, 1, 'A-'),

(17, 2, 'B+'),

(18, 3, 'C'),

(19, 2, 'B'),

(20, 3, 'C+');

SELECT * FROM Students;

Execution and output results:


Database Fetch results

You might also like