Database Design Guide-Student
Database Design Guide-Student
This guide will help the student to create a database on the Student Management
System. It will help to manage the below functionalities.
Student details
Instructor details
Course details
Enrollment details
Score
Feedback
We will use MySQL as the DBMS to create the database and its related operations.
1. Introduction to MySQL
MySQL is an open-source relational database management system (RDBMS) that
uses structured query language (SQL) to manage and manipulate data in a
database. It is widely used for various applications, from small web applications to
large enterprise systems.
2. Installation of MySQL
MySQL can be installed on various operating systems, including Windows, macOS,
and Linux. Here are the general steps to install MySQL:
Windows:
Download the MySQL installer from the official website.
https://dev.mysql.com/downloads/installer/
Run the installer and follow the on-screen instructions.
Choose the installation type (Typical, Complete, or Custom). Recommended
Custom.
Set a root password for the MySQL server.
Identify Entities
Start by identifying the main entities in your system. These are the objects or
concepts about which you want to store data.
Each entity should correspond to a table in your database.
Define Attributes
For each entity, list the attributes (properties or fields) that describe it.
These attributes will become columns in the corresponding database table.
Identify Relationships
Determine how entities are related to each other. There are three types of
relationships: one-to-one (1:1), one-to-many (1:N), and many-to-many (N:M).
Represent these relationships using lines connecting the entities.
One to Many
Many to One
Many to Many
Cardinality Notation
Cardinality represents the number of times an entity of an entity set participates in a
relationship set. Or we can say that the cardinality of a relationship is the number of
tuples (rows) in a relationship.
Use notation (such as Crow's Foot Notation or Chen Notation) to indicate the
cardinality of each relationship.
Cardinality describes how many instances of one entity are related to how
many instances of another entity.
Common notations include:
One (1)
Zero or one (0..1)
Many (N)
Zero or many (0..N)
Optional:
Add Attributes and Constraints
Include additional information in your ERD, such as primary keys, foreign keys,
and constraints (e.g., unique constraints).
*** Now let’s identify the attributes and relationships of each entity for the Student
Management System.
Student
Attributes:
StudentID (Primary Key)
FirstName
LastName
DateOfBirth
Gender
Email
Phone
Relationships:
One Student can enroll in more than one Course (One-to-Many)
Course
Attributes:
CourseID (Primary Key)
CourseTitle
Credits
Relationships:
Many Course is taught by one Instructor (Many-to-One)
Instructor
Attributes:
InstructorID (Primary Key)
FirstName
LastName
Email
Relationships:
One Instructor teaches many Courses (One-to-Many)
One Instructor has many Students (One-to-Many)
Enrollment
Attributes:
EnrollmentID (Primary Key)
EnrollmentDate
StudentID(Foreign key)
CourseID(Foreign Key)
InstructorID(Foreign key)
Relationships:
One Student maps to Many Enrolment ids (One-to-Many)
Many Enrolment ids map to one Course (Many-to-One)
Score
Attributes:
ScoreID (Primary Key)
CourseID (Foreign key)
StudentID (Foreign Key)
DateOfExam
CreditObtained
Relationships:
Many ScoreIDs will map to one Student (Many-to-one)
Many ScoresIDs will map to one Course (Many-to-one)
Feedback
Attributes:
FeedbackID (Primary Key)
StudentID (Foreign key)
Date
InstructorName
Feedback
Relationships:
One Student will maps to Many Feedbacks (One-to-Many)
Table Structure
1. Student
2. Course
3. Instructor
4. Enrollment
5. Score
6. Feedback
Now, let’s create the ER diagram to visually represent the entities and relationships.
ERD Diagram
In this ERD:
Students can enroll, and each course can have multiple students, creating a
many-to-many relationship.
The Enrollment entity serves as a bridge table between Student and Course
entities to represent this relationship.
Multiple courses can be taught by one Instructor (many-to-one relationship).
Each Instructor can teach multiple courses (one-to-many relationship).
A student can give multiple feedbacks
Student may have scores of multiple courses
4. Creating a Database
Using MySQL server, create a new database for your student management system.
You can do this with SQL commands or through the graphical interface.
5. Using a Database
Before performing any operations on a database, you need to select it using the USE
statement:
USE StudentManagementSystem;
USE StudentManagementSystem;
7. Insert records
Add data to your tables to work with. This step helps you test your database.
-- Insert students
-- Insert courses
-- Insert instructor
—--Insert Score
INSERT INTO Score
(ScoreID,StudentID,CourseID,CreditObtained,DateOfExam)VALUES
('SC101','S101','C101','12','2022-10-10'),
('SC102','S102','C101','10','2022-10-10');
8. Select records
Write SQL queries to retrieve and manage data.
For example:
9. Update records
UPDATE Students
PN: Ideally no data should be deleted from any tables. You can use an additional
column to set the status of that record to ‘Active/Inactive’, etc. Or you can use an
Archive table to move the unnecessary records out of the main table.