0% found this document useful (0 votes)
12 views7 pages

University Management System

The document outlines the steps to create a University Management System database using MySQL, including the creation of tables for Students, Departments, Courses, Enrollments, Professors, and TeachingAssignments. It provides SQL commands for creating these tables, inserting initial data, and querying the data for various purposes. This setup serves as a foundational structure for managing university-related information.

Uploaded by

viralpatel9816
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)
12 views7 pages

University Management System

The document outlines the steps to create a University Management System database using MySQL, including the creation of tables for Students, Departments, Courses, Enrollments, Professors, and TeachingAssignments. It provides SQL commands for creating these tables, inserting initial data, and querying the data for various purposes. This setup serves as a foundational structure for managing university-related information.

Uploaded by

viralpatel9816
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/ 7

Step 1: Create the Database

First, create a database for the university management system.

CREATE DATABASE UniversityManagementSystem;


USE UniversityManagementSystem;

Step 2: Create Tables


1. **Students** Table
CREATE TABLE Students (
student_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
date_of_birth DATE,
gender ENUM('Male', 'Female', 'Other'),
email VARCHAR2(100),
phone_number INT,
address TEXT,
department_id INT
);
2. **Departments** Table
CREATE TABLE Departments (
department_id INT AUTO_INCREMENT PRIMARY KEY,
department_name VARCHAR(100)
);
Change
3. **Courses** Table
CREATE TABLE Courses (
course_id INT AUTO_INCREMENT PRIMARY KEY,
course_name VARCHAR(100),
department_id INT,
credits INT
);

4. **Enrollments** Table
CREATE TABLE Enrollments (
enrollment_id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT,
course_id INT,
enrollment_date DATE,
grade VARCHAR(2)
);
5. **Professors** Table
CREATE TABLE Professors (
professor_id INT AUTO_INCREMENT PRIMARY KEY,
first_name VARCHAR(50),
last_name VARCHAR(50),
department_id INT,
email VARCHAR(100),
phone_number VARCHAR(15)
);

6. **TeachingAssignments** Table
CREATE TABLE TeachingAssignments (
assignment_id INT AUTO_INCREMENT PRIMARY KEY,
professor_id INT,
course_id INT,
semester VARCHAR(10)
);
Step 3: Insert Initial Data
Insert some initial data into the tables.

1. **Insert Departments**
INSERT INTO Departments (department_name) VALUES ('Computer
Science');
INSERT INTO Departments (department_name) VALUES
('Mathematics');
INSERT INTO Departments (department_name) VALUES ('Physics');
change
2. **Insert Courses**
INSERT INTO Courses (course_name, department_id, credits) VALUES
('Data Structures', 1, 4);
INSERT INTO Courses (course_name, department_id, credits) VALUES
('Calculus', 2, 3);
INSERT INTO Courses (course_name, department_id, credits) VALUES
('Quantum Mechanics', 3, 4);

3. **Insert Students**
INSERT INTO Students (first_name, last_name, date_of_birth, gender,
email, phone_number, address, department_id)
VALUES ('John', 'Doe', '2000-05-15', 'Male', '[email protected]',
'1234567890', '123 Main St', 1);
INSERT INTO Students (first_name, last_name, date_of_birth, gender,
email, phone_number, address, department_id)
VALUES ('Jane', 'Smith', '1999-11-20', 'Female',
'[email protected]', '0987654321', '456 Maple Ave', 2);

4. **Insert Professors**
INSERT INTO Professors (first_name, last_name, department_id,
email, phone_number)
VALUES ('Alice', 'Johnson', 1, '[email protected]',
'1112223333');

INSERT INTO Professors (first_name, last_name, department_id,


email, phone_number)
VALUES ('Bob', 'Williams', 2, '[email protected]',
'4445556666');

5. **Insert Enrollments**
INSERT INTO Enrollments (student_id, course_id, enrollment_date,
grade)
VALUES (1, 1, '2023-01-15', 'A');

INSERT INTO Enrollments (student_id, course_id, enrollment_date,


grade)
VALUES (2, 2, '2023-01-15', 'B');
6. **Insert Teaching Assignments**
INSERT INTO TeachingAssignments (professor_id, course_id,
semester)
VALUES (1, 1, 'Spring 2023');

INSERT INTO TeachingAssignments (professor_id, course_id,


semester)
VALUES (2, 2, 'Spring 2023');

### Step 4: Query the Data


You can run various queries to manage and retrieve data. Here are a
few examples:

1. **Retrieve all students**


SELECT * FROM Students;

2. **Retrieve all courses offered by a specific department**


SELECT * FROM Courses WHERE department_id = 1;

3. **Get the list of courses a student is enrolled in**


SELECT Courses.course_name
FROM Enrollments
JOIN Courses ON Enrollments.course_id = Courses.course_id
WHERE Enrollments.student_id = 1;
4. **Get the professors teaching a specific course**
SELECT Professors.first_name, Professors.last_name
FROM TeachingAssignments
JOIN Professors ON TeachingAssignments.professor_id =
Professors.professor_id
WHERE TeachingAssignments.course_id = 1;

This basic setup provides a foundation for a University Management


System using MySQL. You can expand on this by adding more tables,
constraints, and relationships as needed.

You might also like